diff --git a/packages/react-native/Libraries/Core/setUpPerformance.js b/packages/react-native/Libraries/Core/setUpPerformance.js index 6ed3fce86e5..a33afb30cae 100644 --- a/packages/react-native/Libraries/Core/setUpPerformance.js +++ b/packages/react-native/Libraries/Core/setUpPerformance.js @@ -8,8 +8,8 @@ * @format */ -import NativePerformance from '../WebPerformance/NativePerformance'; -import Performance from '../WebPerformance/Performance'; +import NativePerformance from '../../src/private/webapis/performance/NativePerformance'; +import Performance from '../../src/private/webapis/performance/Performance'; // In case if the native implementation of the Performance API is available, use it, // otherwise fall back to the legacy/default one, which only defines 'Performance.now()' diff --git a/packages/react-native/Libraries/Core/setUpPerformanceObserver.js b/packages/react-native/Libraries/Core/setUpPerformanceObserver.js index 20e0f32f5c9..47ed15546c2 100644 --- a/packages/react-native/Libraries/Core/setUpPerformanceObserver.js +++ b/packages/react-native/Libraries/Core/setUpPerformanceObserver.js @@ -12,5 +12,7 @@ import {polyfillGlobal} from '../Utilities/PolyfillFunctions'; polyfillGlobal( 'PerformanceObserver', - () => require('../WebPerformance/PerformanceObserver').default, + () => + require('../../src/private/webapis/performance/PerformanceObserver') + .default, ); diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformance.js b/packages/react-native/Libraries/WebPerformance/NativePerformance.js deleted file mode 100644 index 9793c230546..00000000000 --- a/packages/react-native/Libraries/WebPerformance/NativePerformance.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * 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 - */ - -export * from '../../src/private/specs/modules/NativePerformance'; -import NativePerformance from '../../src/private/specs/modules/NativePerformance'; -export default NativePerformance; diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.js b/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.js deleted file mode 100644 index 6edf1dc5c65..00000000000 --- a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * 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 - */ - -export * from '../../src/private/specs/modules/NativePerformanceObserver'; -import NativePerformanceObserver from '../../src/private/specs/modules/NativePerformanceObserver'; -export default NativePerformanceObserver; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 45f6fe77a99..24908c128b7 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -8914,238 +8914,6 @@ declare module.exports: Vibration; " `; -exports[`public API should not change unintentionally Libraries/WebPerformance/EventCounts.js 1`] = ` -"type EventCountsForEachCallbackType = - | (() => void) - | ((value: number) => void) - | ((value: number, key: string) => void) - | ((value: number, key: string, map: Map) => void); -declare export default class EventCounts { - get size(): number; - entries(): Iterator<[string, number]>; - forEach(callback: EventCountsForEachCallbackType): void; - get(key: string): ?number; - has(key: string): boolean; - keys(): Iterator; - values(): Iterator; -} -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/MemoryInfo.js 1`] = ` -"type MemoryInfoLike = { - jsHeapSizeLimit: ?number, - totalJSHeapSize: ?number, - usedJSHeapSize: ?number, -}; -declare export default class MemoryInfo { - _jsHeapSizeLimit: ?number; - _totalJSHeapSize: ?number; - _usedJSHeapSize: ?number; - constructor(memoryInfo: ?MemoryInfoLike): void; - get jsHeapSizeLimit(): ?number; - get totalJSHeapSize(): ?number; - get usedJSHeapSize(): ?number; -} -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/NativePerformance.js 1`] = ` -"export * from \\"../../src/private/specs/modules/NativePerformance\\"; -declare export default typeof NativePerformance; -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/NativePerformanceObserver.js 1`] = ` -"export * from \\"../../src/private/specs/modules/NativePerformanceObserver\\"; -declare export default typeof NativePerformanceObserver; -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/Performance.js 1`] = ` -"type DetailType = mixed; -export type PerformanceMarkOptions = { - detail?: DetailType, - startTime?: HighResTimeStamp, -}; -declare export class PerformanceMark extends PerformanceEntry { - detail: DetailType; - constructor(markName: string, markOptions?: PerformanceMarkOptions): void; -} -export type TimeStampOrName = HighResTimeStamp | string; -export type PerformanceMeasureOptions = { - detail?: DetailType, - start?: TimeStampOrName, - end?: TimeStampOrName, - duration?: HighResTimeStamp, -}; -declare export class PerformanceMeasure extends PerformanceEntry { - detail: DetailType; - constructor( - measureName: string, - measureOptions?: PerformanceMeasureOptions - ): void; -} -declare export default class Performance { - eventCounts: EventCounts; - get memory(): MemoryInfo; - get rnStartupTiming(): ReactNativeStartupTiming; - mark(markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark; - clearMarks(markName?: string): void; - measure( - measureName: string, - startMarkOrOptions?: string | PerformanceMeasureOptions, - endMark?: string - ): PerformanceMeasure; - clearMeasures(measureName?: string): void; - now(): HighResTimeStamp; - getEntries(): PerformanceEntryList; - getEntriesByType(entryType: PerformanceEntryType): PerformanceEntryList; - getEntriesByName( - entryName: string, - entryType?: PerformanceEntryType - ): PerformanceEntryList; -} -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/PerformanceEntry.js 1`] = ` -"export type HighResTimeStamp = number; -export type PerformanceEntryType = \\"mark\\" | \\"measure\\" | \\"event\\"; -export type PerformanceEntryJSON = { - name: string, - entryType: PerformanceEntryType, - startTime: HighResTimeStamp, - duration: HighResTimeStamp, - ... -}; -declare export const ALWAYS_LOGGED_ENTRY_TYPES: $ReadOnlyArray; -declare export class PerformanceEntry { - name: string; - entryType: PerformanceEntryType; - startTime: HighResTimeStamp; - duration: HighResTimeStamp; - constructor(init: { - name: string, - entryType: PerformanceEntryType, - startTime: HighResTimeStamp, - duration: HighResTimeStamp, - }): void; - toJSON(): PerformanceEntryJSON; -} -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/PerformanceEventTiming.js 1`] = ` -"export type PerformanceEventTimingJSON = { - ...PerformanceEntryJSON, - processingStart: HighResTimeStamp, - processingEnd: HighResTimeStamp, - interactionId: number, - ... -}; -declare export default class PerformanceEventTiming extends PerformanceEntry { - processingStart: HighResTimeStamp; - processingEnd: HighResTimeStamp; - interactionId: number; - constructor(init: { - name: string, - startTime?: HighResTimeStamp, - duration?: HighResTimeStamp, - processingStart?: HighResTimeStamp, - processingEnd?: HighResTimeStamp, - interactionId?: number, - }): void; - toJSON(): PerformanceEventTimingJSON; -} -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/PerformanceObserver.js 1`] = ` -"export type PerformanceEntryList = $ReadOnlyArray; -declare export class PerformanceObserverEntryList { - _entries: PerformanceEntryList; - constructor(entries: PerformanceEntryList): void; - getEntries(): PerformanceEntryList; - getEntriesByType(type: PerformanceEntryType): PerformanceEntryList; - getEntriesByName( - name: string, - type?: PerformanceEntryType - ): PerformanceEntryList; -} -export type PerformanceObserverCallback = ( - list: PerformanceObserverEntryList, - observer: PerformanceObserver, - droppedEntryCount?: number -) => void; -export type PerformanceObserverInit = - | { - entryTypes: Array, - } - | { - type: PerformanceEntryType, - durationThreshold?: HighResTimeStamp, - }; -declare export function warnNoNativePerformanceObserver(): void; -declare export default class PerformanceObserver { - _callback: PerformanceObserverCallback; - _type: \\"single\\" | \\"multiple\\" | void; - constructor(callback: PerformanceObserverCallback): void; - observe(options: PerformanceObserverInit): void; - disconnect(): void; - _validateObserveOptions(options: PerformanceObserverInit): void; - static supportedEntryTypes: $ReadOnlyArray; -} -export { PerformanceEventTiming }; -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/RawPerformanceEntry.js 1`] = ` -"declare export const RawPerformanceEntryTypeValues: { - UNDEFINED: 0, - MARK: 1, - MEASURE: 2, - EVENT: 3, -}; -declare export function rawToPerformanceEntry( - entry: RawPerformanceEntry -): PerformanceEntry; -declare export function rawToPerformanceEntryType( - type: RawPerformanceEntryType -): PerformanceEntryType; -declare export function performanceEntryTypeToRaw( - type: PerformanceEntryType -): RawPerformanceEntryType; -" -`; - -exports[`public API should not change unintentionally Libraries/WebPerformance/ReactNativeStartupTiming.js 1`] = ` -"type ReactNativeStartupTimingLike = { - startTime: ?number, - endTime: ?number, - initializeRuntimeStart: ?number, - initializeRuntimeEnd: ?number, - executeJavaScriptBundleEntryPointStart: ?number, - executeJavaScriptBundleEntryPointEnd: ?number, -}; -declare export default class ReactNativeStartupTiming { - _startTime: ?number; - _endTime: ?number; - _initializeRuntimeStart: ?number; - _initializeRuntimeEnd: ?number; - _executeJavaScriptBundleEntryPointStart: ?number; - _executeJavaScriptBundleEntryPointEnd: ?number; - constructor(startUpTiming: ?ReactNativeStartupTimingLike): void; - get startTime(): ?number; - get endTime(): ?number; - get initializeRuntimeStart(): ?number; - get initializeRuntimeEnd(): ?number; - get executeJavaScriptBundleEntryPointStart(): ?number; - get executeJavaScriptBundleEntryPointEnd(): ?number; -} -" -`; - exports[`public API should not change unintentionally Libraries/WebSocket/NativeWebSocketModule.js 1`] = ` "export * from \\"../../src/private/specs/modules/NativeWebSocketModule\\"; declare export default typeof NativeWebSocketModule; diff --git a/packages/react-native/Libraries/WebPerformance/BoundedConsumableBuffer.h b/packages/react-native/src/private/webapis/performance/BoundedConsumableBuffer.h similarity index 100% rename from packages/react-native/Libraries/WebPerformance/BoundedConsumableBuffer.h rename to packages/react-native/src/private/webapis/performance/BoundedConsumableBuffer.h diff --git a/packages/react-native/Libraries/WebPerformance/EventCounts.js b/packages/react-native/src/private/webapis/performance/EventCounts.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/EventCounts.js rename to packages/react-native/src/private/webapis/performance/EventCounts.js diff --git a/packages/react-native/Libraries/WebPerformance/MemoryInfo.js b/packages/react-native/src/private/webapis/performance/MemoryInfo.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/MemoryInfo.js rename to packages/react-native/src/private/webapis/performance/MemoryInfo.js diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformance.cpp b/packages/react-native/src/private/webapis/performance/NativePerformance.cpp similarity index 100% rename from packages/react-native/Libraries/WebPerformance/NativePerformance.cpp rename to packages/react-native/src/private/webapis/performance/NativePerformance.cpp diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformance.h b/packages/react-native/src/private/webapis/performance/NativePerformance.h similarity index 100% rename from packages/react-native/Libraries/WebPerformance/NativePerformance.h rename to packages/react-native/src/private/webapis/performance/NativePerformance.h diff --git a/packages/react-native/src/private/specs/modules/NativePerformance.js b/packages/react-native/src/private/webapis/performance/NativePerformance.js similarity index 100% rename from packages/react-native/src/private/specs/modules/NativePerformance.js rename to packages/react-native/src/private/webapis/performance/NativePerformance.js diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.cpp b/packages/react-native/src/private/webapis/performance/NativePerformanceObserver.cpp similarity index 100% rename from packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.cpp rename to packages/react-native/src/private/webapis/performance/NativePerformanceObserver.cpp diff --git a/packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h b/packages/react-native/src/private/webapis/performance/NativePerformanceObserver.h similarity index 100% rename from packages/react-native/Libraries/WebPerformance/NativePerformanceObserver.h rename to packages/react-native/src/private/webapis/performance/NativePerformanceObserver.h diff --git a/packages/react-native/src/private/specs/modules/NativePerformanceObserver.js b/packages/react-native/src/private/webapis/performance/NativePerformanceObserver.js similarity index 100% rename from packages/react-native/src/private/specs/modules/NativePerformanceObserver.js rename to packages/react-native/src/private/webapis/performance/NativePerformanceObserver.js diff --git a/packages/react-native/Libraries/WebPerformance/Performance.js b/packages/react-native/src/private/webapis/performance/Performance.js similarity index 99% rename from packages/react-native/Libraries/WebPerformance/Performance.js rename to packages/react-native/src/private/webapis/performance/Performance.js index e8c4c492cfd..92befaae912 100644 --- a/packages/react-native/Libraries/WebPerformance/Performance.js +++ b/packages/react-native/src/private/webapis/performance/Performance.js @@ -13,7 +13,7 @@ import type {HighResTimeStamp, PerformanceEntryType} from './PerformanceEntry'; import type {PerformanceEntryList} from './PerformanceObserver'; -import warnOnce from '../Utilities/warnOnce'; +import warnOnce from '../../../../Libraries/Utilities/warnOnce'; import EventCounts from './EventCounts'; import MemoryInfo from './MemoryInfo'; import NativePerformance from './NativePerformance'; diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEntry.js b/packages/react-native/src/private/webapis/performance/PerformanceEntry.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/PerformanceEntry.js rename to packages/react-native/src/private/webapis/performance/PerformanceEntry.js diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp b/packages/react-native/src/private/webapis/performance/PerformanceEntryReporter.cpp similarity index 100% rename from packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp rename to packages/react-native/src/private/webapis/performance/PerformanceEntryReporter.cpp diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.h b/packages/react-native/src/private/webapis/performance/PerformanceEntryReporter.h similarity index 100% rename from packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.h rename to packages/react-native/src/private/webapis/performance/PerformanceEntryReporter.h diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEventTiming.js b/packages/react-native/src/private/webapis/performance/PerformanceEventTiming.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/PerformanceEventTiming.js rename to packages/react-native/src/private/webapis/performance/PerformanceEventTiming.js diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceObserver.js b/packages/react-native/src/private/webapis/performance/PerformanceObserver.js similarity index 99% rename from packages/react-native/Libraries/WebPerformance/PerformanceObserver.js rename to packages/react-native/src/private/webapis/performance/PerformanceObserver.js index 8114257be1d..c8caee14662 100644 --- a/packages/react-native/Libraries/WebPerformance/PerformanceObserver.js +++ b/packages/react-native/src/private/webapis/performance/PerformanceObserver.js @@ -10,7 +10,7 @@ import type {HighResTimeStamp, PerformanceEntryType} from './PerformanceEntry'; -import warnOnce from '../Utilities/warnOnce'; +import warnOnce from '../../../../Libraries/Utilities/warnOnce'; import NativePerformanceObserver from './NativePerformanceObserver'; import {PerformanceEntry} from './PerformanceEntry'; import PerformanceEventTiming from './PerformanceEventTiming'; diff --git a/packages/react-native/Libraries/WebPerformance/RawPerformanceEntry.js b/packages/react-native/src/private/webapis/performance/RawPerformanceEntry.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/RawPerformanceEntry.js rename to packages/react-native/src/private/webapis/performance/RawPerformanceEntry.js diff --git a/packages/react-native/Libraries/WebPerformance/ReactNativeStartupTiming.js b/packages/react-native/src/private/webapis/performance/ReactNativeStartupTiming.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/ReactNativeStartupTiming.js rename to packages/react-native/src/private/webapis/performance/ReactNativeStartupTiming.js diff --git a/packages/react-native/Libraries/WebPerformance/__mocks__/NativePerformance.js b/packages/react-native/src/private/webapis/performance/__mocks__/NativePerformance.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__mocks__/NativePerformance.js rename to packages/react-native/src/private/webapis/performance/__mocks__/NativePerformance.js diff --git a/packages/react-native/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js b/packages/react-native/src/private/webapis/performance/__mocks__/NativePerformanceObserver.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js rename to packages/react-native/src/private/webapis/performance/__mocks__/NativePerformanceObserver.js diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/BoundedConsumableBufferTest.cpp b/packages/react-native/src/private/webapis/performance/__tests__/BoundedConsumableBufferTest.cpp similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/BoundedConsumableBufferTest.cpp rename to packages/react-native/src/private/webapis/performance/__tests__/BoundedConsumableBufferTest.cpp diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/EventCounts-test.js b/packages/react-native/src/private/webapis/performance/__tests__/EventCounts-test.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/EventCounts-test.js rename to packages/react-native/src/private/webapis/performance/__tests__/EventCounts-test.js diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/NativePerformanceMock-test.js b/packages/react-native/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/NativePerformanceMock-test.js rename to packages/react-native/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/NativePerformanceObserverMock-test.js b/packages/react-native/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/NativePerformanceObserverMock-test.js rename to packages/react-native/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/Performance-test.js b/packages/react-native/src/private/webapis/performance/__tests__/Performance-test.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/Performance-test.js rename to packages/react-native/src/private/webapis/performance/__tests__/Performance-test.js diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp b/packages/react-native/src/private/webapis/performance/__tests__/PerformanceEntryReporterTest.cpp similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp rename to packages/react-native/src/private/webapis/performance/__tests__/PerformanceEntryReporterTest.cpp diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceObserver-test.js b/packages/react-native/src/private/webapis/performance/__tests__/PerformanceObserver-test.js similarity index 100% rename from packages/react-native/Libraries/WebPerformance/__tests__/PerformanceObserver-test.js rename to packages/react-native/src/private/webapis/performance/__tests__/PerformanceObserver-test.js diff --git a/packages/rn-tester/js/examples/Performance/PerformanceApiExample.js b/packages/rn-tester/js/examples/Performance/PerformanceApiExample.js index 427d6058640..08a1629fe19 100644 --- a/packages/rn-tester/js/examples/Performance/PerformanceApiExample.js +++ b/packages/rn-tester/js/examples/Performance/PerformanceApiExample.js @@ -10,13 +10,13 @@ */ 'use strict'; -import type MemoryInfo from 'react-native/Libraries/WebPerformance/MemoryInfo'; -import type ReactNativeStartupTiming from 'react-native/Libraries/WebPerformance/ReactNativeStartupTiming'; +import type MemoryInfo from 'react-native/src/private/webapis/performance/MemoryInfo'; +import type ReactNativeStartupTiming from 'react-native/src/private/webapis/performance/ReactNativeStartupTiming'; import RNTesterPage from '../../components/RNTesterPage'; import * as React from 'react'; import {Button, StyleSheet, Text, View} from 'react-native'; -import Performance from 'react-native/Libraries/WebPerformance/Performance'; +import Performance from 'react-native/src/private/webapis/performance/Performance'; const {useState, useCallback} = React; const performance = new Performance();