mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Move Web performance APIs to private directory (#42769)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42769 Changelog: [internal] These APIs are not currently enabled in OSS, so moving the modules should be safe and not considered a breaking change. Reviewed By: NickGerleman Differential Revision: D53267565 fbshipit-source-id: edd3daa7c5043e44e5fd4b1af074093ed3ef4152
This commit is contained in:
1 parent
a68ae2e2cc
commit
b97f3e779a
32 files changed
+10
-266
No files matched your search
@@ -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()'
|
||||
|
||||
@@ -12,5 +12,7 @@ import {polyfillGlobal} from '../Utilities/PolyfillFunctions';
|
||||
|
||||
polyfillGlobal(
|
||||
'PerformanceObserver',
|
||||
() => require('../WebPerformance/PerformanceObserver').default,
|
||||
() =>
|
||||
require('../../src/private/webapis/performance/PerformanceObserver')
|
||||
.default,
|
||||
);
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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<string, number>) => 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<string>;
|
||||
values(): Iterator<number>;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
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<PerformanceEntryType>;
|
||||
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<PerformanceEntry>;
|
||||
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<PerformanceEntryType>,
|
||||
}
|
||||
| {
|
||||
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<PerformanceEntryType>;
|
||||
}
|
||||
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;
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -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';
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -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';
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user