mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Move spec files to specs directories in react-native/src/private (#43395)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43395 Changelog: [internal] This moves native module specs to `specs` directory to align with the general convention. Reviewed By: cortinico Differential Revision: D54680056 fbshipit-source-id: 8b6ae6187e2ffa9120159b7d1fa25957677e0f4f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9c9c7edeb3
commit
4799d0cc5c
@@ -8,8 +8,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import NativePerformance from '../../src/private/webapis/performance/NativePerformance';
|
||||
import Performance from '../../src/private/webapis/performance/Performance';
|
||||
import NativePerformance from '../../src/private/webapis/performance/specs/NativePerformance';
|
||||
|
||||
// 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()'
|
||||
|
||||
@@ -25,7 +25,7 @@ export default function generateCommonCxxModules(
|
||||
return {
|
||||
[path.join(jsPath, 'ReactNativeFeatureFlags.js')]:
|
||||
ReactNativeFeatureFlagsJS(featureFlagDefinitions),
|
||||
[path.join(jsPath, 'NativeReactNativeFeatureFlags.js')]:
|
||||
[path.join(jsPath, 'specs', 'NativeReactNativeFeatureFlags.js')]:
|
||||
NativeReactNativeFeatureFlagsJS(featureFlagDefinitions),
|
||||
[path.join(commonNativeModuleCxxPath, 'NativeReactNativeFeatureFlags.h')]:
|
||||
NativeReactNativeFeatureFlagsH(featureFlagDefinitions),
|
||||
|
||||
+2
-2
@@ -26,9 +26,9 @@ export default function (definitions: FeatureFlagDefinitions): string {
|
||||
|
||||
${DO_NOT_MODIFY_COMMENT}
|
||||
|
||||
import type {TurboModule} from '../../../Libraries/TurboModule/RCTExport';
|
||||
import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
||||
|
||||
import * as TurboModuleRegistry from '../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
${Object.entries(definitions.common)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import type {
|
||||
ReactNativeFeatureFlagsJsOnlyOverrides,
|
||||
} from './ReactNativeFeatureFlags';
|
||||
|
||||
import NativeReactNativeFeatureFlags from './NativeReactNativeFeatureFlags';
|
||||
import NativeReactNativeFeatureFlags from './specs/NativeReactNativeFeatureFlags';
|
||||
|
||||
const accessedFeatureFlags: Set<string> = new Set();
|
||||
let overrides: ?ReactNativeFeatureFlagsJsOnlyOverrides;
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ describe('ReactNativeFeatureFlags', () => {
|
||||
});
|
||||
|
||||
it('should provide default values for common flags and log an error if the method in the native module is NOT available', () => {
|
||||
jest.doMock('../NativeReactNativeFeatureFlags', () => ({
|
||||
jest.doMock('../specs/NativeReactNativeFeatureFlags', () => ({
|
||||
__esModule: true,
|
||||
default: {},
|
||||
}));
|
||||
@@ -44,7 +44,7 @@ describe('ReactNativeFeatureFlags', () => {
|
||||
it('should access and cache common flags from the native module if it is available', () => {
|
||||
const commonTestFlagFn = jest.fn(() => true);
|
||||
|
||||
jest.doMock('../NativeReactNativeFeatureFlags', () => ({
|
||||
jest.doMock('../specs/NativeReactNativeFeatureFlags', () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
commonTestFlag: commonTestFlagFn,
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @generated SignedSource<<a7c3c5ceb67150fda5e1fb6801f2c281>>
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTANT: Do NOT modify this file directly.
|
||||
*
|
||||
* To change the definition of the flags, edit
|
||||
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
|
||||
*
|
||||
* To regenerate this code, run the following script from the repo root:
|
||||
* yarn featureflags-update
|
||||
*/
|
||||
|
||||
import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
||||
|
||||
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+commonTestFlag?: () => boolean;
|
||||
+batchRenderingUpdatesInEventLoop?: () => boolean;
|
||||
+enableBackgroundExecutor?: () => boolean;
|
||||
+enableCustomDrawOrderFabric?: () => boolean;
|
||||
+enableFixForClippedSubviewsCrash?: () => boolean;
|
||||
+enableMicrotasks?: () => boolean;
|
||||
+enableMountHooksAndroid?: () => boolean;
|
||||
+enableSpannableBuildingUnification?: () => boolean;
|
||||
+inspectorEnableCxxInspectorPackagerConnection?: () => boolean;
|
||||
+inspectorEnableHermesCDPAgent?: () => boolean;
|
||||
+inspectorEnableModernCDPRegistry?: () => boolean;
|
||||
+skipMountHookNotifications?: () => boolean;
|
||||
+useModernRuntimeScheduler?: () => boolean;
|
||||
}
|
||||
|
||||
const NativeReactNativeFeatureFlags: ?Spec = TurboModuleRegistry.get<Spec>(
|
||||
'NativeReactNativeFeatureFlagsCxx',
|
||||
);
|
||||
|
||||
export default NativeReactNativeFeatureFlags;
|
||||
@@ -8,8 +8,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import NativePerformanceObserver from './NativePerformanceObserver';
|
||||
import {warnNoNativePerformanceObserver} from './PerformanceObserver';
|
||||
import NativePerformanceObserver from './specs/NativePerformanceObserver';
|
||||
|
||||
type EventCountsForEachCallbackType =
|
||||
| (() => void)
|
||||
|
||||
@@ -16,8 +16,6 @@ import type {PerformanceEntryList} from './PerformanceObserver';
|
||||
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
|
||||
import EventCounts from './EventCounts';
|
||||
import MemoryInfo from './MemoryInfo';
|
||||
import NativePerformance from './NativePerformance';
|
||||
import NativePerformanceObserver from './NativePerformanceObserver';
|
||||
import {ALWAYS_LOGGED_ENTRY_TYPES, PerformanceEntry} from './PerformanceEntry';
|
||||
import {warnNoNativePerformanceObserver} from './PerformanceObserver';
|
||||
import {
|
||||
@@ -26,6 +24,8 @@ import {
|
||||
} from './RawPerformanceEntry';
|
||||
import {RawPerformanceEntryTypeValues} from './RawPerformanceEntry';
|
||||
import ReactNativeStartupTiming from './ReactNativeStartupTiming';
|
||||
import NativePerformance from './specs/NativePerformance';
|
||||
import NativePerformanceObserver from './specs/NativePerformanceObserver';
|
||||
|
||||
type DetailType = mixed;
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,6 @@
|
||||
import type {HighResTimeStamp, PerformanceEntryType} from './PerformanceEntry';
|
||||
|
||||
import warnOnce from '../../../../Libraries/Utilities/warnOnce';
|
||||
import NativePerformanceObserver from './NativePerformanceObserver';
|
||||
import {PerformanceEntry} from './PerformanceEntry';
|
||||
import PerformanceEventTiming from './PerformanceEventTiming';
|
||||
import {
|
||||
@@ -19,6 +18,7 @@ import {
|
||||
rawToPerformanceEntry,
|
||||
rawToPerformanceEntryType,
|
||||
} from './RawPerformanceEntry';
|
||||
import NativePerformanceObserver from './specs/NativePerformanceObserver';
|
||||
|
||||
export type PerformanceEntryList = $ReadOnlyArray<PerformanceEntry>;
|
||||
|
||||
|
||||
+2
-2
@@ -8,11 +8,11 @@
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
import type {PerformanceEntryType} from './PerformanceEntry';
|
||||
import type {
|
||||
RawPerformanceEntry,
|
||||
RawPerformanceEntryType,
|
||||
} from './NativePerformanceObserver';
|
||||
import type {PerformanceEntryType} from './PerformanceEntry';
|
||||
} from './specs/NativePerformanceObserver';
|
||||
|
||||
import {PerformanceEntry} from './PerformanceEntry';
|
||||
import PerformanceEventTiming from './PerformanceEventTiming';
|
||||
|
||||
+3
-3
@@ -12,12 +12,12 @@ import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
||||
|
||||
// NOTE: Jest mocks of transitive dependencies don't appear to work with
|
||||
// ES6 module imports, therefore forced to use commonjs style imports here.
|
||||
const NativePerformanceObserver = require('../NativePerformanceObserver');
|
||||
const Performance = require('../Performance').default;
|
||||
const NativePerformanceObserver = require('../specs/NativePerformanceObserver');
|
||||
|
||||
jest.mock(
|
||||
'../NativePerformanceObserver',
|
||||
() => require('../__mocks__/NativePerformanceObserver').default,
|
||||
'../specs/NativePerformanceObserver',
|
||||
() => require('../specs/__mocks__/NativePerformanceObserver').default,
|
||||
);
|
||||
|
||||
describe('EventCounts', () => {
|
||||
|
||||
+4
-4
@@ -11,13 +11,13 @@
|
||||
const Performance = require('../Performance').default;
|
||||
|
||||
jest.mock(
|
||||
'../NativePerformance',
|
||||
() => require('../__mocks__/NativePerformance').default,
|
||||
'../specs/NativePerformance',
|
||||
() => require('../specs/__mocks__/NativePerformance').default,
|
||||
);
|
||||
|
||||
jest.mock(
|
||||
'../NativePerformanceObserver',
|
||||
() => require('../__mocks__/NativePerformanceObserver').default,
|
||||
'../specs/NativePerformanceObserver',
|
||||
() => require('../specs/__mocks__/NativePerformanceObserver').default,
|
||||
);
|
||||
|
||||
describe('Performance', () => {
|
||||
|
||||
Vendored
+3
-3
@@ -12,12 +12,12 @@ import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
||||
|
||||
// NOTE: Jest mocks of transitive dependencies don't appear to work with
|
||||
// ES6 module imports, therefore forced to use commonjs style imports here.
|
||||
const NativePerformanceObserver = require('../NativePerformanceObserver');
|
||||
const PerformanceObserver = require('../PerformanceObserver').default;
|
||||
const NativePerformanceObserver = require('../specs/NativePerformanceObserver');
|
||||
|
||||
jest.mock(
|
||||
'../NativePerformanceObserver',
|
||||
() => require('../__mocks__/NativePerformanceObserver').default,
|
||||
'../specs/NativePerformanceObserver',
|
||||
() => require('../specs/__mocks__/NativePerformanceObserver').default,
|
||||
);
|
||||
|
||||
describe('PerformanceObserver', () => {
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
||||
import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport';
|
||||
|
||||
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
|
||||
export type NativeMemoryInfo = {[key: string]: ?number};
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
||||
import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport';
|
||||
|
||||
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
|
||||
export type RawPerformanceEntryType = number;
|
||||
|
||||
+1
-1
@@ -14,8 +14,8 @@ import type {
|
||||
Spec as NativePerformance,
|
||||
} from '../NativePerformance';
|
||||
|
||||
import {RawPerformanceEntryTypeValues} from '../../RawPerformanceEntry';
|
||||
import NativePerformanceObserver from '../NativePerformanceObserver';
|
||||
import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
||||
|
||||
const marks: Map<string, number> = new Map();
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import type {
|
||||
Spec as NativePerformanceObserver,
|
||||
} from '../NativePerformanceObserver';
|
||||
|
||||
import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
||||
import {RawPerformanceEntryTypeValues} from '../../RawPerformanceEntry';
|
||||
|
||||
const reportingType: Set<RawPerformanceEntryType> = new Set();
|
||||
const isAlwaysLogged: Set<RawPerformanceEntryType> = new Set();
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
const NativePerformanceMock = require('../__mocks__/NativePerformance').default;
|
||||
const PerformanceObserver = require('../PerformanceObserver').default;
|
||||
const PerformanceObserver = require('../../PerformanceObserver').default;
|
||||
|
||||
describe('NativePerformanceMock', () => {
|
||||
jest.mock(
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
import NativePerformanceObserverMock from '../__mocks__/NativePerformanceObserver';
|
||||
import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
||||
import {RawPerformanceEntryTypeValues} from '../../RawPerformanceEntry';
|
||||
|
||||
describe('NativePerformanceObserver', () => {
|
||||
it('correctly starts and stops listening to entries in a nominal scenario', async () => {
|
||||
Reference in New Issue
Block a user