Skip to content

Commit

Permalink
Expose PerformanceObserver related classes in the global scope (#45539)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jul 22, 2024
1 parent a5bd64e commit 2551aee
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/react-native/Libraries/Core/setUpPerformanceObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

0 comments on commit 2551aee

Please sign in to comment.