mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use the right interfaces for PerformanceLongTaskTiming (#45526)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45526 Changelog: [internal] Just using the right interfaces so we can expose them in the global scope and do refinements as necessary using `instanceof`. Reviewed By: rshest Differential Revision: D59911144 fbshipit-source-id: 9779e3220f2c6f81955f54506f97142f0f4ffdd4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2a91a703cc
commit
2680198b09
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
// flowlint unsafe-getters-setters:off
|
||||
|
||||
import type {PerformanceEntryJSON} from './PerformanceEntry';
|
||||
|
||||
import {PerformanceEntry} from './PerformanceEntry';
|
||||
|
||||
export type PerformanceLongTaskTimingJSON = {
|
||||
...PerformanceEntryJSON,
|
||||
attribution: $ReadOnlyArray<TaskAttributionTiming>,
|
||||
...
|
||||
};
|
||||
|
||||
export class TaskAttributionTiming extends PerformanceEntry {}
|
||||
|
||||
const EMPTY_ATTRIBUTION: $ReadOnlyArray<TaskAttributionTiming> =
|
||||
Object.preventExtensions([]);
|
||||
|
||||
export class PerformanceLongTaskTiming extends PerformanceEntry {
|
||||
get attribution(): $ReadOnlyArray<TaskAttributionTiming> {
|
||||
return EMPTY_ATTRIBUTION;
|
||||
}
|
||||
|
||||
toJSON(): PerformanceLongTaskTimingJSON {
|
||||
return {
|
||||
...super.toJSON(),
|
||||
attribution: this.attribution,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
RawPerformanceEntryType,
|
||||
} from './specs/NativePerformanceObserver';
|
||||
|
||||
import {PerformanceLongTaskTiming} from './LongTasks';
|
||||
import {PerformanceEntry} from './PerformanceEntry';
|
||||
import PerformanceEventTiming from './PerformanceEventTiming';
|
||||
import {PerformanceMark, PerformanceMeasure} from './UserTiming';
|
||||
@@ -37,6 +38,13 @@ export function rawToPerformanceEntry(
|
||||
processingEnd: entry.processingEnd,
|
||||
interactionId: entry.interactionId,
|
||||
});
|
||||
} else if (entry.entryType === RawPerformanceEntryTypeValues.LONGTASK) {
|
||||
return new PerformanceLongTaskTiming({
|
||||
name: entry.name,
|
||||
entryType: rawToPerformanceEntryType(entry.entryType),
|
||||
startTime: entry.startTime,
|
||||
duration: entry.duration,
|
||||
});
|
||||
} else if (entry.entryType === RawPerformanceEntryTypeValues.MARK) {
|
||||
return new PerformanceMark(entry.name, {
|
||||
startTime: entry.startTime,
|
||||
|
||||
Reference in New Issue
Block a user