Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module.exports = {
'<rootDir>/packages/react-native/src/react-private-interface.js',
'^react-native/setup-env$':
'<rootDir>/packages/react-native/src/setup-env.js',
'^react-native/unstable-internals-do-not-use$':
'<rootDir>/packages/react-native/src/unstable-internals-do-not-use.js',
},
setupFiles: ['./packages/jest-preset/jest/local-setup.js'],
fakeTimers: {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import typeof * as TmockComponent from '../mockComponent';
import typeof TActivityIndicator from 'react-native/Libraries/Components/ActivityIndicator/ActivityIndicator';
import typeof {ActivityIndicator as TActivityIndicator} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import typeof * as TmockComponent from '../mockComponent';
import typeof TImage from 'react-native/Libraries/Image/Image';
import typeof {Image as TImage} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import typeof * as TmockComponent from '../mockComponent';
import type {ModalProps} from 'react-native/Libraries/Modal/Modal';
import type {ModalProps} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/RefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

import type {RefreshControlProps} from 'react-native/Libraries/Components/RefreshControl/RefreshControl';
import type {RefreshControlProps} from 'react-native';
import type {HostComponent} from 'react-native/src/private/types/HostComponent';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
import typeof TScrollView from 'react-native/Libraries/Components/ScrollView/ScrollView';
import typeof {ScrollView as TScrollView} from 'react-native';
import type {ScrollViewNativeProps} from 'react-native/Libraries/Components/ScrollView/ScrollViewNativeComponentType';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
import typeof TText from 'react-native/Libraries/Text/Text';
import typeof {Text as TText} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
import typeof TTextInput from 'react-native/Libraries/Components/TextInput/TextInput';
import typeof {TextInput as TTextInput} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
import typeof TView from 'react-native/Libraries/Components/View/View';
import typeof {View as TView} from 'react-native';

const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-preset/jest/mocks/ViewNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
import type {ViewProps} from 'react-native';

import * as React from 'react';
import {createElement} from 'react';
Expand Down
51 changes: 51 additions & 0 deletions packages/react-native/src/unstable-internals-do-not-use.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// ----------------------------------------------------------------------------

import type * as React from 'react';
import type {ColorValue} from '../types_generated/Libraries/StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../types_generated/Libraries/StyleSheet/processColor';

// #region AppContainer

Expand Down Expand Up @@ -64,6 +66,17 @@ export class AssetSourceResolver {
static pickScale(scales: number[], deviceScale?: number): number;
}

// #endregion
// #region ConditionallyIgnoredEventHandlers

/**
* Marks generated event-handler view-config attributes as conditionally
* ignored on platforms that do not synthesize them from native view managers.
*/
export function ConditionallyIgnoredEventHandlers<
T extends Readonly<Record<string, true>>,
>(value: T): T | undefined;

// #endregion
// #region customDirectEventTypes

Expand Down Expand Up @@ -212,3 +225,41 @@ interface PressabilityDebugViewProps {
export const PressabilityDebugView: React.ComponentType<PressabilityDebugViewProps>;

// #endregion
// #region Renderer

/** Renderer APIs used by generated Codegen modules. */
export * as Renderer from '../types_generated/Libraries/ReactNative/RendererImplementation';

// #endregion
// #region Codegen view config helpers

export const colorAttribute:
| true
| Readonly<{
process: typeof import('../types_generated/Libraries/StyleSheet/processColor').default;
}>;

export function processColorArray(
colors: ReadonlyArray<ColorValue> | null | undefined,
): ReadonlyArray<ProcessedColorValue> | null;

type Point = {
x: number | null | undefined;
y: number | null | undefined;
};

export function pointsDiffer(
one: Point | null | undefined,
two: Point | null | undefined,
): boolean;

type EdgeInsets = {
top: number | null | undefined;
left: number | null | undefined;
right: number | null | undefined;
bottom: number | null | undefined;
};

export function insetsDiffer(one: EdgeInsets, two: EdgeInsets): boolean;

// #endregion
30 changes: 30 additions & 0 deletions packages/react-native/src/unstable-internals-do-not-use.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@
// and unstable-internals-do-not-use.js.flow.
// ----------------------------------------------------------------------------

import typeof {colorAttribute} from '../Libraries/Components/View/ReactNativeStyleAttributes';
import typeof getDevServer from '../Libraries/Core/Devtools/getDevServer';
import typeof NativeExceptionsManager from '../Libraries/Core/NativeExceptionsManager';
import typeof AssetSourceResolver from '../Libraries/Image/AssetSourceResolver';
import typeof {ConditionallyIgnoredEventHandlers} from '../Libraries/NativeComponent/ViewConfigIgnore';
import typeof NativeRedBox from '../Libraries/NativeModules/specs/NativeRedBox';
import typeof NativeSourceCode from '../Libraries/NativeModules/specs/NativeSourceCode';
import typeof {PressabilityDebugView} from '../Libraries/Pressability/PressabilityDebug';
import typeof AppContainer from '../Libraries/ReactNative/AppContainer';
import typeof * as Renderer from '../Libraries/ReactNative/RendererProxy';
import typeof {customDirectEventTypes} from '../Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
import typeof processColorArray from '../Libraries/StyleSheet/processColorArray';
import typeof DevLoadingView from '../Libraries/Utilities/DevLoadingView';
import typeof insetsDiffer from '../Libraries/Utilities/differ/insetsDiffer';
import typeof pointsDiffer from '../Libraries/Utilities/differ/pointsDiffer';
import typeof HMRClient from '../Libraries/Utilities/HMRClient';

// flowlint unsafe-getters-setters:off
Expand All @@ -60,6 +66,12 @@ module.exports = {
get AssetSourceResolver(): AssetSourceResolver {
return require('../Libraries/Image/AssetSourceResolver').default;
},
get ConditionallyIgnoredEventHandlers(): ConditionallyIgnoredEventHandlers<{
readonly [name: string]: true,
}> {
return require('../Libraries/NativeComponent/ViewConfigIgnore')
.ConditionallyIgnoredEventHandlers;
},
get customDirectEventTypes(): customDirectEventTypes {
return require('../Libraries/Renderer/shims/ReactNativeViewConfigRegistry')
.customDirectEventTypes;
Expand All @@ -86,4 +98,22 @@ module.exports = {
return require('../Libraries/Pressability/PressabilityDebug')
.PressabilityDebugView;
},
// Generated Codegen modules can be emitted outside this package, so they
// cannot use package-relative imports to access these implementations.
get colorAttribute(): colorAttribute {
return require('../Libraries/Components/View/ReactNativeStyleAttributes')
.colorAttribute;
},
get insetsDiffer(): insetsDiffer {
return require('../Libraries/Utilities/differ/insetsDiffer').default;
},
get pointsDiffer(): pointsDiffer {
return require('../Libraries/Utilities/differ/pointsDiffer').default;
},
get processColorArray(): processColorArray {
return require('../Libraries/StyleSheet/processColorArray').default;
},
get Renderer(): Renderer {
return require('../Libraries/ReactNative/RendererProxy');
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

export {default as AppContainer} from '../Libraries/ReactNative/AppContainer';
export {default as AssetSourceResolver} from '../Libraries/Image/AssetSourceResolver';
export {colorAttribute} from '../Libraries/Components/View/ReactNativeStyleAttributes';
export {ConditionallyIgnoredEventHandlers} from '../Libraries/NativeComponent/ViewConfigIgnore';
export {customDirectEventTypes} from '../Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
export {default as DevLoadingView} from '../Libraries/Utilities/DevLoadingView';
export {default as getDevServer} from '../Libraries/Core/Devtools/getDevServer';
Expand All @@ -24,3 +26,7 @@ export {default as NativeExceptionsManager} from '../Libraries/Core/NativeExcept
export {default as NativeRedBox} from '../Libraries/NativeModules/specs/NativeRedBox';
export {default as NativeSourceCode} from '../Libraries/NativeModules/specs/NativeSourceCode';
export {PressabilityDebugView} from '../Libraries/Pressability/PressabilityDebug';
export {default as insetsDiffer} from '../Libraries/Utilities/differ/insetsDiffer';
export {default as pointsDiffer} from '../Libraries/Utilities/differ/pointsDiffer';
export {default as processColorArray} from '../Libraries/StyleSheet/processColorArray';
export * as Renderer from '../Libraries/ReactNative/RendererProxy';
Loading