Skip to content

Commit

Permalink
Merge branch 'facebook:main' into fix-non-ascii-header-value
Browse files Browse the repository at this point in the history
  • Loading branch information
robertying authored Nov 28, 2022
2 parents 7ed0489 + b7a85b5 commit 03fb462
Show file tree
Hide file tree
Showing 41 changed files with 185 additions and 145 deletions.
3 changes: 0 additions & 3 deletions .circleci/verdaccio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ packages:
'@react-native/*':
access: $all
publish: $all
'react-native-codegen':
access: $all
publish: $all
'@*/*':
access: $all
publish: $authenticated
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ package-lock.json
!/packages/rn-tester/Pods/__offline_mirrors_hermes__
!/packages/rn-tester/Pods/__offline_mirrors_jsc__

# react-native-codegen
# @react-native/codegen
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/packages/react-native-codegen/tmp/
Expand Down
2 changes: 1 addition & 1 deletion BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ rn_apple_xplat_cxx_library(
react_native_root_target("React/CoreModules:CoreModules"),
react_native_xplat_target("cxxreact:bridge"),
react_native_xplat_target("cxxreact:jsbigstring"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsc:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
react_native_xplat_target("reactperflogger:reactperflogger"),
],
Expand Down
3 changes: 3 additions & 0 deletions Libraries/NativeComponent/NativeComponentRegistryUnstable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*
* 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
*/

let componentNameToExists: Map<string, boolean> = new Map();
Expand Down
2 changes: 1 addition & 1 deletion Libraries/TypeSafety/RCTConvertHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using LazyVector = FB::LazyVector<T, id>;
template <typename ContainerT>
NSArray *RCTConvertVecToArray(const ContainerT &vec, id (^convertor)(typename ContainerT::value_type element))
{
NSMutableArray *array = [NSMutableArray new];
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:vec.size()];
for (size_t i = 0, size = vec.size(); i < size; ++i) {
id object = convertor(vec[i]);
array[i] = object ?: (id)kCFNull;
Expand Down
2 changes: 1 addition & 1 deletion React/CxxBridge/JSCExecutorFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "JSCExecutorFactory.h"

#import <jsi/JSCRuntime.h>
#import <jsc/JSCRuntime.h>

#import <memory>

Expand Down
12 changes: 9 additions & 3 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
"rrc_image",
new Pair("../ReactCommon/react/renderer/components/image/", "react/renderer/components/image/")
),
// This prefab target is used by Expo & Reanimated to load a new instance of Hermes
// These prefab targets are used by Expo & Reanimated
new PrefabPreprocessingEntry(
"hermes-executor",
// "hermes-executor" is statically linking agaisnt "hermes-executor-common"
// "hermes-executor" is statically linking against "hermes-executor-common"
// and "hermes-inspector". Here we expose only the headers that we know are needed.
new Pair("../ReactCommon/hermes/inspector/", "hermes/inspector/")
),
new PrefabPreprocessingEntry(
"jscexecutor",
// "jscexecutor" is statically linking against "jscruntime"
// Here we expose only the headers that we know are needed.
new Pair("../ReactCommon/jsc/", "jsc/")
),
new PrefabPreprocessingEntry(
"react_render_uimanager",
new Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
Expand Down Expand Up @@ -635,7 +641,7 @@ react {
reactNativeDir = file("$projectDir/..")
// We search for the codegen in either one of the `node_modules` folder or in the
// root packages folder (that's for when we build from source without calling `yarn install`).
codegenDir = file(findNodeModulePath(projectDir, "react-native-codegen") ?: "../packages/react-native-codegen/")
codegenDir = file(findNodeModulePath(projectDir, "@react-native/codegen") ?: "../packages/react-native-codegen/")
}

apply plugin: "org.jetbrains.kotlin.android"
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_react_common_subdir(reactperflogger)
add_react_common_subdir(logger)
add_react_common_subdir(jsiexecutor)
add_react_common_subdir(cxxreact)
add_react_common_subdir(jsc)
add_react_common_subdir(jsi)
add_react_common_subdir(butter)
add_react_common_subdir(callinvoker)
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jscexecutor/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rn_xplat_cxx_library(
deps = [
FBJNI_TARGET,
react_native_target("jni/react/jni:jni"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsc:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
],
)
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <fbjni/fbjni.h>
#include <jsi/JSCRuntime.h>
#include <jsc/JSCRuntime.h>
#include <jsireact/JSIExecutor.h>
#include <react/jni/JReactMarker.h>
#include <react/jni/JSLogging.h>
Expand Down
6 changes: 6 additions & 0 deletions ReactCommon/jsc/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Checks: '>
clang-diagnostic-*,
'
InheritParentConfig: true
...
34 changes: 34 additions & 0 deletions ReactCommon/jsc/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("//tools/build_defs/oss:rn_defs.bzl", "APPLE", "IOS", "MACOSX", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_dep", "rn_xplat_cxx_library")

APPLE_COMPILER_FLAGS = get_apple_compiler_flags()

rn_xplat_cxx_library(
name = "JSCRuntime",
srcs = [
"JSCRuntime.cpp",
],
header_namespace = "jsc",
exported_headers = [
"JSCRuntime.h",
],
apple_sdks = (IOS, MACOSX),
compiler_flags_pedantic = True,
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS + [
"-Os",
],
fbobjc_frameworks = [
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
],
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
],
platforms = APPLE,
visibility = ["PUBLIC"],
xplat_mangled_args = {
"soname": "libjscjsi.$(ext)",
},
exported_deps = [
react_native_xplat_dep("jsi:jsi"),
],
)
35 changes: 35 additions & 0 deletions ReactCommon/jsc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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.

##################
### jscruntime ###
##################

cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fexceptions
-frtti
-O3
-Wno-unused-lambda-capture
-DLOG_TAG=\"ReactNative\")

add_library(jscruntime
STATIC
JSCRuntime.h
JSCRuntime.cpp)

target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(jscruntime
folly_runtime
jsc
jsi
glog)

# TODO: Remove this flag when ready.
# Android has this enabled by default, but the flag is still needed for iOS.
target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ Pod::Spec.new do |s|
s.source_files = "JSCRuntime.{cpp,h}"
s.exclude_files = "**/test/*"
s.framework = "JavaScriptCore"
s.dependency "React-jsi", version
s.default_subspec = "Default"

s.subspec "Default" do
# no-op
end
s.dependency "React-jsi", version

s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
Expand Down
32 changes: 1 addition & 31 deletions ReactCommon/jsi/BUCK
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools/build_defs/oss:rn_defs.bzl", "APPLE", "IOS", "MACOSX", "react_native_xplat_dep", "rn_xplat_cxx_library")
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_dep", "rn_xplat_cxx_library")

rn_xplat_cxx_library(
name = "jsi",
Expand Down Expand Up @@ -56,33 +56,3 @@ rn_xplat_cxx_library(
react_native_xplat_dep("jsi:jsi"),
],
)

rn_xplat_cxx_library(
name = "JSCRuntime",
srcs = [
"JSCRuntime.cpp",
],
header_namespace = "jsi",
exported_headers = [
"JSCRuntime.h",
],
apple_sdks = (IOS, MACOSX),
compiler_flags_pedantic = True,
fbobjc_compiler_flags = [
"-Os",
],
fbobjc_frameworks = [
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
],
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
],
platforms = APPLE,
visibility = ["PUBLIC"],
xplat_mangled_args = {
"soname": "libjscjsi.$(ext)",
},
exported_deps = [
react_native_xplat_dep("jsi:jsi"),
],
)
16 changes: 0 additions & 16 deletions ReactCommon/jsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,3 @@ target_include_directories(jsi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(jsi
folly_runtime
glog)

##################
### jscruntime ###
##################

add_library(jscruntime STATIC
JSCRuntime.h
JSCRuntime.cpp)

target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(jscruntime folly_runtime jsc glog)

# TODO: Remove this flag when ready.
# Android has this enabled by default, but the flag is still needed for iOS.
target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED)
12 changes: 6 additions & 6 deletions packages/babel-plugin-codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ let flowParser, typeScriptParser, RNCodegen;
const {basename} = require('path');

try {
flowParser = require('react-native-codegen/src/parsers/flow');
typeScriptParser = require('react-native-codegen/src/parsers/typescript');
RNCodegen = require('react-native-codegen/src/generators/RNCodegen');
flowParser = require('@react-native/codegen/src/parsers/flow');
typeScriptParser = require('@react-native/codegen/src/parsers/typescript');
RNCodegen = require('@react-native/codegen/src/generators/RNCodegen');
} catch (e) {
// Fallback to lib when source doesn't exit (e.g. when installed as a dev dependency)
flowParser = require('react-native-codegen/lib/parsers/flow');
typeScriptParser = require('react-native-codegen/lib/parsers/typescript');
RNCodegen = require('react-native-codegen/lib/generators/RNCodegen');
flowParser = require('@react-native/codegen/lib/parsers/flow');
typeScriptParser = require('@react-native/codegen/lib/parsers/typescript');
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen');
}

function parseFile(filename, code) {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"index.js"
],
"dependencies": {
"react-native-codegen": "*"
"@react-native/codegen": "*"
},
"devDependencies": {
"@babel/core": "^7.14.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@babel/eslint-parser": "^7.18.2",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/preset-flow": "^7.17.12",
"@react-native/codegen": "*",
"flow-parser": "^0.185.0",
"make-dir": "^2.1.0",
"pirates": "^4.0.1",
"react-native-codegen": "*",
"source-map-support": "0.5.0"
},
"license": "MIT"
Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-plugin-specs/react-native-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ let RNParserUtils;

function requireModuleParser() {
if (RNModuleParser == null || RNParserUtils == null) {
// If using this externally, we leverage react-native-codegen as published form
// If using this externally, we leverage @react-native/codegen as published form
if (!PACKAGE_USAGE) {
const config = {
only: [/react-native-codegen\/src\//],
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
};

withBabelRegister(config, () => {
RNModuleParser = require('react-native-codegen/src/parsers/flow/modules');
RNParserUtils = require('react-native-codegen/src/parsers/utils');
RNModuleParser = require('@react-native/codegen/src/parsers/flow/modules');
RNParserUtils = require('@react-native/codegen/src/parsers/utils');
});
} else {
const config = {
only: [/react-native-codegen\/lib\//],
only: [/@react-native\/codegen\/lib\//],
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
};

withBabelRegister(config, () => {
RNModuleParser = require('react-native-codegen/lib/parsers/flow/modules');
RNParserUtils = require('react-native-codegen/lib/parsers/utils');
RNModuleParser = require('@react-native/codegen/lib/parsers/flow/modules');
RNParserUtils = require('@react-native/codegen/lib/parsers/flow/utils');
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native-codegen/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# react-native-codegen
# @react-native/codegen

[![Version][version-badge]][package]

## Installation

```
yarn add --dev react-native-codegen
yarn add --dev @react-native/codegen
```

*Note: We're using `yarn` to install deps. Feel free to change commands to use `npm` 3+ and `npx` if you like*

[version-badge]: https://img.shields.io/npm/v/react-native-codegen?style=flat-square
[package]: https://www.npmjs.com/package/react-native-codegen
[version-badge]: https://img.shields.io/npm/v/@react-native/codegen?style=flat-square
[package]: https://www.npmjs.com/package/@react-native/codegen

## Testing

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-native-codegen",
"name": "@react-native/codegen",
"version": "0.72.0",
"description": "⚛️ Code generation tools for React Native",
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function translateTypeAnnotation(
function isModuleInterface(node: $FlowFixMe) {
return (
node.type === 'TSInterfaceDeclaration' &&
node.extends.length === 1 &&
node.extends?.length === 1 &&
node.extends[0].type === 'TSExpressionWithTypeArguments' &&
node.extends[0].expression.name === 'TurboModule'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class ReactExtension @Inject constructor(project: Project) {
/**
* The path to the react-native NPM package folder.
*
* Default: ${rootProject.dir}/../node_modules/react-native-codegen
* Default: ${rootProject.dir}/../node_modules/react-native
*/
val reactNativeDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
Expand Down Expand Up @@ -121,10 +121,10 @@ abstract class ReactExtension @Inject constructor(project: Project) {
/**
* The path to the react-native-codegen NPM package folder.
*
* Default: ${rootProject.dir}/../node_modules/react-native-codegen
* Default: ${rootProject.dir}/../node_modules/@react-native/codegen
*/
val codegenDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native-codegen"))
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))

/**
* The root directory for all JS files for the app.
Expand Down
Loading

0 comments on commit 03fb462

Please sign in to comment.