Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/react-native/ReactCommon/react/bridging/Dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <folly/dynamic.h>
#include <jsi/JSIDynamic.h>
#include <react/bridging/Base.h>

namespace facebook::react {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <React/Debug.h>
#include <React/RendererCore.h>
#include <react/renderer/components/iostextinput/conversions.h>
#include <react/renderer/components/iostextinput/primitives.h>

namespace facebook::react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <react/cxxstableapi/UmbrellaGuard.h>

#include <type_traits>

namespace facebook::react {

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <react/cxxstableapi/UmbrellaGuard.h>

#include <react/renderer/core/LayoutPrimitives.h>
#include <react/renderer/graphics/Size.h>

namespace facebook::react {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <react/cxxstableapi/UmbrellaGuard.h>

#include <optional>
#include <string>
#include <string_view>

namespace facebook::react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import <UIKit/UIKit.h>

#include <React/Graphics.h>
#include <react/renderer/attributedstring/primitives.h>
#include <react/renderer/graphics/RCTPlatformColorUtils.h>
#include <react/renderer/textlayoutmanager/RCTFontProperties.h>
#include <react/renderer/textlayoutmanager/RCTFontUtils.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* 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-local
* @format
*/

'use strict';

const {getHeaderFilesFromPodspecs} = require('../headers');
const path = require('node:path');

const reactNativeRoot = path.resolve(__dirname, '../../..');
const rendererSourceDir = path.join(
reactNativeRoot,
'ReactCommon/react/renderer',
);

const headers = Object.values(
getHeaderFilesFromPodspecs(reactNativeRoot),
).flatMap(headerMaps => headerMaps.flatMap(headerMap => headerMap.headers));
const targets = new Set(headers.map(header => header.target));

function targetsOf(rendererRelativeSource /*: string */) /*: Array<string> */ {
const source = path.join(rendererSourceDir, rendererRelativeSource);
return headers
.filter(header => header.source === source)
.map(header => header.target);
}

describe('prebuilt header layout', () => {
test.each([
'animated/nodes/AnimatedNode.h',
'animated/internal/primitives.h',
'animated/drivers/AnimationDriver.h',
'animated/event_drivers/EventAnimationDriver.h',
'mounting/stubs/stubs.h',
'mounting/internal/CullingContext.h',
])('%s keeps its subfolder', nestedHeader => {
const nestedTarget = `react/renderer/${nestedHeader}`;
const flattenedTarget = path.join(
path.dirname(path.dirname(nestedTarget)),
path.basename(nestedTarget),
);

expect(targetsOf(nestedHeader)).toEqual([nestedTarget]);
expect(targets.has(flattenedTarget)).toBe(false);
});

test.each(['animated/AnimatedModule.h', 'mounting/MountingCoordinator.h'])(
'top-level %s stays in place',
header => {
expect(targetsOf(header)).toEqual([`react/renderer/${header}`]);
},
);

// Private headers (PrivateGuard.h): keep them out of the prebuilt package.
test.each(['intersection', 'mutation', 'resize'])(
'%s observer headers are not shipped',
observer => {
const shippedObserverHeaders = [...targets].filter(
target =>
target.startsWith(`react/renderer/observers/${observer}/`) ||
target.startsWith(`react/nativemodule/${observer}observer/`),
);

expect(shippedObserverHeaders).toEqual([]);
},
);

test('no Android text input header is shipped', () => {
const androidTextInputDir = path.join(
rendererSourceDir,
'components/textinput/platform/android',
);

expect(
headers
.map(header => header.source)
.filter(source => source.startsWith(androidTextInputDir + path.sep)),
).toEqual([]);
});

test('view platform headers stay flattened into their header dir', () => {
expect(
targetsOf(
'components/view/platform/cxx/react/renderer/components/view/HostPlatformViewProps.h',
),
).toEqual(['react/renderer/components/view/HostPlatformViewProps.h']);
});
});
13 changes: 13 additions & 0 deletions packages/react-native/scripts/ios-prebuild/headers-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
headerPatterns: ['react/renderer/animated/**/*.h'],
excludePatterns: ['react/renderer/animated/tests'],
headerDir: 'react/renderer/animated',
preservePaths: ['react/renderer/animated/**/*.h'],
},

{
Expand Down Expand Up @@ -203,6 +204,7 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
headerPatterns: ['react/renderer/mounting/**/*.h'],
excludePatterns: ['react/renderer/mounting/tests'],
headerDir: 'react/renderer/mounting',
preservePaths: ['react/renderer/mounting/**/*.h'],
},

{
Expand Down Expand Up @@ -430,6 +432,9 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
{
name: 'textinput',
headerPatterns: ['react/renderer/components/textinput/**/*.h'],
excludePatterns: [
'react/renderer/components/textinput/platform/android',
],
headerDir: 'react/renderer/components/textinput',
},

Expand Down Expand Up @@ -625,6 +630,14 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
],
},
'React.podspec': {disabled: true},
// Private headers (PrivateGuard.h), included only by .cpp files. Shipping
// them would also require the private observers/{intersection,mutation,resize}.
'ReactCommon/react/nativemodule/intersectionobserver/React-intersectionobservernativemodule.podspec':
{disabled: true},
'ReactCommon/react/nativemodule/mutationobserver/React-mutationobservernativemodule.podspec':
{disabled: true},
'ReactCommon/react/nativemodule/resizeobserver/React-resizeobservernativemodule.podspec':
{disabled: true},
'ReactCommon/react/timing/React-timing.podspec': {
name: 'React-timing',
headerPatterns: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
[
"notShipped react/nativemodule/intersectionobserver/NativeIntersectionObserver.h -> react/renderer/observers/intersection/IntersectionObserverManager.h",
"notShipped react/nativemodule/mutationobserver/NativeMutationObserver.h -> react/renderer/observers/mutation/MutationObserverManager.h",
"notShipped react/nativemodule/resizeobserver/NativeResizeObserver.h -> react/renderer/observers/resize/ResizeObserverManager.h",
"notShipped react/renderer/animated/InterpolationAnimatedNode.h -> react/renderer/animated/internal/primitives.h",
"notShipped react/renderer/animated/NativeAnimatedNodesManager.h -> react/renderer/animated/event_drivers/EventAnimationDriver.h",
"notShipped react/renderer/animated/PropsAnimatedNode.h -> react/renderer/animated/internal/primitives.h",
"notShipped react/renderer/mounting/MountingCoordinator.h -> react/renderer/mounting/stubs/stubs.h",
"notShipped react/renderer/mounting/StubViewTree.h -> react/renderer/mounting/stubs/StubView.h",
"notShipped react/renderer/mounting/stubs.h -> react/renderer/mounting/stubs/StubView.h",
"notShipped react/renderer/mounting/stubs.h -> react/renderer/mounting/stubs/StubViewTree.h",
"quotedNotShipped RCTAnimation/RCTEventAnimation.h -> \"RCTValueAnimatedNode.h\"",
"quotedNotShipped RCTAnimation/RCTNativeAnimatedTurboModule.h -> \"RCTValueAnimatedNode.h\"",
"quotedNotShipped React/RCTEventAnimation.h -> \"RCTValueAnimatedNode.h\"",
"quotedNotShipped React/RCTNativeAnimatedTurboModule.h -> \"RCTValueAnimatedNode.h\"",
"quotedNotShipped react/nativemodule/dom/NativeDOM.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/idlecallbacks/NativeIdleCallbacks.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/intersectionobserver/NativeIntersectionObserver.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/microtasks/NativeMicrotasks.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/mutationobserver/NativeMutationObserver.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/resizeobserver/NativeResizeObserver.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/viewtransition/NativeViewTransition.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/webperformance/NativePerformance.h -> \"FBReactNativeSpecJSI.h\"",
"quotedNotShipped react/nativemodule/webperformance/NativePerformance.h -> \"rncoreJSI.h\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function classifyExternal(
}
// RN's own include namespace but absent from the shipped set: either a
// genuinely unshipped header or a header_dir-flattening mismatch (headers.js
// ships <dir>/<basename>, dropping inner subdirs like mounting/stubs/).
// ships <dir>/<basename>, dropping inner subdirs unless preservePaths keeps them).
if (
ownNamespaces.has(first) ||
fs.existsSync(path.join(rootFolder, 'ReactCommon', token))
Expand Down
Loading