Compare commits

..
Author SHA1 Message Date
Blake Friedman 6291332455 fix: mitigate DangerJS transpilation bug
Danger seems to have a bug where it's not transpiling the import of
@rnx-kit/rn-changelog-generator. This mitigates the issue to get our
project back on track.

Changelog: [internal]
2024-10-24 13:43:43 -07:00
349 changed files with 47630 additions and 66211 deletions
+1 -1
View File
@@ -90,4 +90,4 @@ untyped-import
untyped-type-import
[version]
^0.251.1
^0.250.0
+1 -1
View File
@@ -8,7 +8,7 @@ runs:
using: "composite"
steps:
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: wrapper
# We want the Gradle cache to be written only on main/-stable branches run, and only for jobs with `cache-read-only` == false (i.e. `build_android`).
@@ -46,7 +46,7 @@ describe('#publishTemplate', () => {
expect(github.rest.actions.createWorkflowDispatch).toHaveBeenCalledWith({
owner: 'react-native-community',
repo: 'template',
workflow_id: 'release.yaml',
workflow_id: 'release.yml',
ref: '0.76-stable',
inputs: {
dry_run: true,
@@ -66,7 +66,7 @@ describe('#publishTemplate', () => {
expect(github.rest.actions.createWorkflowDispatch).toHaveBeenCalledWith({
owner: 'react-native-community',
repo: 'template',
workflow_id: 'release.yaml',
workflow_id: 'release.yml',
ref: '0.76-stable',
inputs: {
dry_run: false,
+1 -1
View File
@@ -42,7 +42,7 @@ module.exports.publishTemplate = async (github, version, dryRun = true) => {
await github.rest.actions.createWorkflowDispatch({
owner: 'react-native-community',
repo: 'template',
workflow_id: 'release.yaml',
workflow_id: 'release.yml',
ref,
inputs: {
dry_run: dryRun,
+2 -2
View File
@@ -9,7 +9,7 @@
const {execSync} = require('child_process');
function run(cmd) {
function run(...cmd) {
return execSync(cmd, 'utf8').toString().trim();
}
module.exports.run = run;
@@ -21,7 +21,7 @@ module.exports.sleep = sleep;
async function getNpmPackageInfo(pkg, versionOrTag) {
return fetch(`https://registry.npmjs.org/${pkg}/${versionOrTag}`).then(resp =>
resp.json(),
res.json(),
);
}
module.exports.getNpmPackageInfo = getNpmPackageInfo;
@@ -0,0 +1,13 @@
name: "Validate Gradle Wrapper"
on:
push:
pull_request:
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3
+2 -2
View File
@@ -205,9 +205,9 @@ jobs:
with:
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
script: |
const {verifyPublishedTemplate, isLatest} = require('./.github/workflow-scripts/publishTemplate.js')
const {verifyPublished, isLatest} = require('./.github/workflow-scripts/publishTemplate.js')
const version = "${{ github.ref_name }}"
await verifyPublishedTemplate(version, isLatest());
await verifyPublished(version, isLatest());
- name: Update rn-diff-purge to generate upgrade-support diff
run: |
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
-17
View File
@@ -1,22 +1,5 @@
# Changelog
## v0.76.1
### Fixed
#### Android specific
- **runtime** Made AppRegistry callable from Native code in Bridgeless (fixes headless tasks) ([f3fee67c54](https://github.com/facebook/react-native/commit/f3fee67c547ace5e08bc9e119bcb80e0f3454d30) by [@robik](https://github.com/robik))
- **runtime** Add jsBundleFile to DefaultReactNativeHost.kt ([e56bd89ef](https://github.com/facebook/react-native/commit/e56bd89eff72f1d38d2940b9dbd8f7b97037dc22))
#### iOS specific
- **codegen** Do not generate the ComponentCls function in the RCTThirdPartyFabricComponentsProvider for components deined in the app. ([dc7e9e2d83](https://github.com/facebook/react-native/commit/dc7e9e2d83f5af3d2a970521af4fcc7f86d2168d) by [@cipolleschi](https://github.com/cipolleschi))
- **infra** Generated NODE_BINARY in .xcode.env.local now supports paths with a space ([eeaa3ff458](https://github.com/facebook/react-native/commit/eeaa3ff458a3e5c902075bb45161d6ccde31fe53) by [@blakef](https://github.com/blakef))
- **infra** Pin Xcodeproj to < 1.26.0 ([e8776240b41](https://github.com/facebook/react-native/commit/e8776240b41a3147e95713299b69c813be60b8e8))
- **runtime** Fixed bug where background colors would sometimes animate when changing on Views ([1d6ac09530](https://github.com/facebook/react-native/commit/1d6ac09530145e6d2bf1e4dd9d40f51542d9e7f6) by [@joevilches](https://github.com/joevilches))
- **runtime** Fixes regression of RCTWindowFrameDidChangeNotification not fired ([e271b23fad](https://github.com/facebook/react-native/commit/e271b23fad89e1e7da2e91a8f1e5cbb295406c74) by [@zhongwuzw](https://github.com/zhongwuzw))
## v0.76.0
### Breaking
-1
View File
@@ -5,4 +5,3 @@ ruby ">= 2.6.10"
gem 'cocoapods', '~> 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
gem 'xcodeproj', '< 1.26.0'
+8 -4
View File
@@ -14,7 +14,8 @@
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
"format": "npm run prettier && npm run clang-format",
"featureflags": "cd packages/react-native && yarn featureflags",
"featureflags-check": "cd packages/react-native && yarn featureflags-check",
"featureflags-update": "cd packages/react-native && yarn featureflags-update",
"lint-ci": "./scripts/circleci/analyze_code.sh && yarn shellcheck",
"lint-java": "node ./scripts/lint-java.js",
"lint": "eslint .",
@@ -77,7 +78,7 @@
"eslint-plugin-redundant-undefined": "^0.4.0",
"eslint-plugin-relay": "^1.8.3",
"flow-api-translator": "0.24.0",
"flow-bin": "^0.251.1",
"flow-bin": "^0.250.0",
"glob": "^7.1.1",
"hermes-eslint": "0.24.0",
"hermes-transform": "0.24.0",
@@ -93,13 +94,16 @@
"nullthrows": "^1.1.1",
"prettier": "2.8.8",
"prettier-plugin-hermes-parser": "0.24.0",
"react": "18.3.1",
"react-test-renderer": "18.3.1",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"signedsource": "^1.0.0",
"supports-color": "^7.1.0",
"typescript": "5.0.4",
"ws": "^6.2.3"
},
"resolutions": {
"react-is": "19.0.0-rc-fb9a90fa48-20240614"
}
}
+1 -1
View File
@@ -31,7 +31,7 @@
"nullthrows": "^1.1.1",
"open": "^7.0.3",
"selfsigned": "^2.4.1",
"serve-static": "^1.16.2",
"serve-static": "^1.13.1",
"ws": "^6.2.3"
},
"engines": {
+2 -2
View File
@@ -39,7 +39,7 @@ module.exports = {
overrides: [
{
files: ['*.js'],
parser: '@babel/eslint-parser',
parser: 'hermes-eslint',
plugins: ['ft-flow'],
rules: {
// Flow Plugin
@@ -51,7 +51,7 @@ module.exports = {
},
{
files: ['*.jsx'],
parser: '@babel/eslint-parser',
parser: 'hermes-eslint',
},
{
files: ['*.ts', '*.tsx'],
@@ -21,7 +21,6 @@
"main": "index.js",
"dependencies": {
"@babel/core": "^7.25.2",
"@babel/eslint-parser": "^7.25.1",
"@react-native/eslint-plugin": "0.77.0-main",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
@@ -31,7 +30,8 @@
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0"
"eslint-plugin-react-native": "^4.0.0",
"hermes-eslint": "0.24.0"
},
"peerDependencies": {
"eslint": ">=8",
@@ -1,5 +1,5 @@
[versions]
agp = "8.7.2"
agp = "8.7.1"
gson = "2.8.9"
guava = "31.0.1-jre"
javapoet = "1.13.0"
@@ -59,15 +59,15 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
val cxxModuleCMakeListsPath = dep.cxxModuleCMakeListsPath
if (libraryName != null && cmakeListsPath != null) {
// If user provided a custom cmakeListsPath, let's honor it.
val nativeFolderPath = sanitizeCmakeListsPath(cmakeListsPath)
val nativeFolderPath = cmakeListsPath.replace("CMakeLists.txt", "")
addDirectoryString +=
"add_subdirectory(\"$nativeFolderPath\" ${libraryName}_autolinked_build)"
"add_subdirectory($nativeFolderPath ${libraryName}_autolinked_build)"
}
if (cxxModuleCMakeListsPath != null) {
// If user provided a custom cxxModuleCMakeListsPath, let's honor it.
val nativeFolderPath = sanitizeCmakeListsPath(cxxModuleCMakeListsPath)
val nativeFolderPath = cxxModuleCMakeListsPath.replace("CMakeLists.txt", "")
addDirectoryString +=
"\nadd_subdirectory(\"$nativeFolderPath\" ${libraryName}_cxxmodule_autolinked_build)"
"\nadd_subdirectory($nativeFolderPath ${libraryName}_cxxmodule_autolinked_build)"
}
addDirectoryString
}
@@ -159,9 +159,6 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
const val COMPONENT_DESCRIPTOR_FILENAME = "ComponentDescriptors.h"
const val COMPONENT_INCLUDE_PATH = "react/renderer/components"
internal fun sanitizeCmakeListsPath(cmakeListsPath: String): String =
cmakeListsPath.replace("CMakeLists.txt", "").replace(" ", "\\ ")
// language=cmake
val CMAKE_TEMPLATE =
"""
@@ -53,8 +53,11 @@ internal object NdkConfiguratorUtils {
if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
cmakeArgs.add("-DANDROID_STL=c++_shared")
}
if (cmakeArgs.none { it.startsWith("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES") }) {
cmakeArgs.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
// Due to the new NDK toolchain file, the C++ flags gets overridden between compilation
// units. This is causing some libraries to don't be compiled with -DANDROID and other
// crucial flags. This can be revisited once we bump to NDK 25/26
if (cmakeArgs.none { it.startsWith("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE") }) {
cmakeArgs.add("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON")
}
val architectures = project.getReactNativeArchitectures()
@@ -11,7 +11,6 @@ import com.facebook.react.model.ModelAutolinkingConfigJson
import com.facebook.react.model.ModelAutolinkingDependenciesJson
import com.facebook.react.model.ModelAutolinkingDependenciesPlatformAndroidJson
import com.facebook.react.model.ModelAutolinkingDependenciesPlatformJson
import com.facebook.react.tasks.GenerateAutolinkingNewArchitecturesFileTask.Companion.sanitizeCmakeListsPath
import com.facebook.react.tests.createTestTask
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
@@ -146,9 +145,9 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
add_subdirectory("./a/directory/" aPackage_autolinked_build)
add_subdirectory("./another/directory/with\ spaces/" anotherPackage_autolinked_build)
add_subdirectory("./another/directory/cxx/" anotherPackage_cxxmodule_autolinked_build)
add_subdirectory(./a/directory/ aPackage_autolinked_build)
add_subdirectory(./another/directory/ anotherPackage_autolinked_build)
add_subdirectory(./another/directory/cxx/ anotherPackage_cxxmodule_autolinked_build)
set(AUTOLINKED_LIBRARIES
react_codegen_aPackage
@@ -259,24 +258,6 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
.trimIndent())
}
@Test
fun sanitizeCmakeListsPath_withPathEndingWithFileName_removesFilename() {
val input = "./a/directory/CMakeLists.txt"
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/directory/")
}
@Test
fun sanitizeCmakeListsPath_withSpaces_removesSpaces() {
val input = "./a/dir ectory/with spaces/"
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/with\\ spaces/")
}
@Test
fun sanitizeCmakeListsPath_withPathEndingWithFileNameAndSpaces_sanitizesIt() {
val input = "./a/dir ectory/CMakeLists.txt"
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/")
}
private val testDependencies =
listOf(
ModelAutolinkingDependenciesPlatformAndroidJson(
@@ -295,7 +276,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
buildTypes = emptyList(),
libraryName = "anotherPackage",
componentDescriptors = listOf("AnotherPackageComponentDescriptor"),
cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt",
cmakeListsPath = "./another/directory/CMakeLists.txt",
cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt",
cxxModuleHeaderName = "AnotherCxxModule",
cxxModuleCMakeListsModuleName = "another_cxxModule",
-1
View File
@@ -4,4 +4,3 @@ ruby ">= 2.6.10"
gem 'cocoapods', '~> 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
gem 'xcodeproj', '< 1.26.0'
+2 -2
View File
@@ -12,7 +12,7 @@
"test": "jest"
},
"dependencies": {
"react": "18.3.1",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-native": "1000.0.0"
},
"devDependencies": {
@@ -28,7 +28,7 @@
"eslint": "^8.19.0",
"jest": "^29.6.3",
"listr2": "^8.2.1",
"react-test-renderer": "18.3.1",
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614",
"rxjs": "^7.8.1"
},
"engines": {
+17
View File
@@ -387,6 +387,15 @@ const LOG_LEVELS = {
warn: 2,
error: 3,
};
const INSPECTOR_LEVELS = [];
INSPECTOR_LEVELS[LOG_LEVELS.trace] = 'debug';
INSPECTOR_LEVELS[LOG_LEVELS.info] = 'log';
INSPECTOR_LEVELS[LOG_LEVELS.warn] = 'warning';
INSPECTOR_LEVELS[LOG_LEVELS.error] = 'error';
// Strip the inner function in getNativeLogFunction(), if in dev also
// strip method printing to originalConsole.
const INSPECTOR_FRAMES_TO_SKIP = __DEV__ ? 2 : 1;
function getNativeLogFunction(level) {
return function () {
@@ -420,6 +429,14 @@ function getNativeLogFunction(level) {
// (Note: Logic duplicated in ExceptionsManager.js.)
logLevel = LOG_LEVELS.warn;
}
if (global.__inspectorLog) {
global.__inspectorLog(
INSPECTOR_LEVELS[logLevel],
str,
[].slice.call(arguments),
INSPECTOR_FRAMES_TO_SKIP,
);
}
if (groupStack.length) {
str = groupFormat('', str);
}
+1 -3
View File
@@ -57,9 +57,7 @@ if (!includesTestPlan && !isFromPhabricator) {
// Check if there is a changelog and validate it
if (!isFromPhabricator) {
const status = require('@rnx-kit/rn-changelog-generator').default.validate(
danger.github.pr.body,
);
const status = require('@rnx-kit/rn-changelog-generator').default.validate(danger.github.pr.body);
const changelogInstructions =
'See <a target="_blank" href="https://reactnative.dev/contributing/changelogs-in-pull-requests">Changelog format</a>';
if (status === 'missing') {
+3 -10
View File
@@ -286,11 +286,6 @@ export interface UnsafeAnyTypeAnnotation {
readonly type: 'AnyTypeAnnotation',
}
export interface NativeModuleNumberLiteralTypeAnnotation {
readonly type: 'NumberLiteralTypeAnnotation';
readonly value: number;
}
export interface NativeModuleStringTypeAnnotation {
readonly type: 'StringTypeAnnotation';
}
@@ -325,10 +320,10 @@ export interface NativeModuleBooleanTypeAnnotation {
readonly type: 'BooleanTypeAnnotation';
}
export type NativeModuleEnumMember = {
export type NativeModuleEnumMembers = readonly {
readonly name: string;
readonly value: string | number;
};
}[];
export type NativeModuleEnumMemberType =
| 'NumberTypeAnnotation'
@@ -344,7 +339,7 @@ export interface NativeModuleEnumDeclarationWithMembers {
name: string;
type: 'EnumDeclarationWithMembers';
memberType: NativeModuleEnumMemberType;
members: readonly NativeModuleEnumMember[];
members: NativeModuleEnumMembers;
}
export interface NativeModuleGenericObjectTypeAnnotation {
@@ -385,7 +380,6 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
| NativeModuleFloatTypeAnnotation
| NativeModuleInt32TypeAnnotation
| NativeModuleNumberTypeAnnotation
| NativeModuleNumberLiteralTypeAnnotation
| NativeModuleStringTypeAnnotation
| NativeModuleStringLiteralTypeAnnotation
| NativeModuleStringLiteralUnionTypeAnnotation
@@ -405,7 +399,6 @@ export type NativeModuleBaseTypeAnnotation =
| NativeModuleStringLiteralTypeAnnotation
| NativeModuleStringLiteralUnionTypeAnnotation
| NativeModuleNumberTypeAnnotation
| NativeModuleNumberLiteralTypeAnnotation
| NativeModuleInt32TypeAnnotation
| NativeModuleDoubleTypeAnnotation
| NativeModuleFloatTypeAnnotation
+7 -12
View File
@@ -37,11 +37,6 @@ export type Int32TypeAnnotation = $ReadOnly<{
type: 'Int32TypeAnnotation',
}>;
export type NumberLiteralTypeAnnotation = $ReadOnly<{
type: 'NumberLiteralTypeAnnotation',
value: number,
}>;
export type StringTypeAnnotation = $ReadOnly<{
type: 'StringTypeAnnotation',
}>;
@@ -309,10 +304,12 @@ export type NativeModuleNumberTypeAnnotation = $ReadOnly<{
type: 'NumberTypeAnnotation',
}>;
export type NativeModuleEnumMember = {
name: string,
value: string | number,
};
export type NativeModuleEnumMembers = $ReadOnlyArray<
$ReadOnly<{
name: string,
value: string | number,
}>,
>;
export type NativeModuleEnumMemberType =
| 'NumberTypeAnnotation'
@@ -328,7 +325,7 @@ export type NativeModuleEnumDeclarationWithMembers = {
name: string,
type: 'EnumDeclarationWithMembers',
memberType: NativeModuleEnumMemberType,
members: $ReadOnlyArray<NativeModuleEnumMember>,
members: NativeModuleEnumMembers,
};
export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{
@@ -369,7 +366,6 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
| FloatTypeAnnotation
| Int32TypeAnnotation
| NativeModuleNumberTypeAnnotation
| NumberLiteralTypeAnnotation
| StringTypeAnnotation
| StringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
@@ -389,7 +385,6 @@ export type NativeModuleBaseTypeAnnotation =
| StringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
| NativeModuleNumberTypeAnnotation
| NumberLiteralTypeAnnotation
| Int32TypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
@@ -186,8 +186,6 @@ function serializeArg(
return wrap(val => `${val}.asNumber()`);
case 'Int32TypeAnnotation':
return wrap(val => `${val}.asNumber()`);
case 'NumberLiteralTypeAnnotation':
return wrap(val => `${val}.asNumber()`);
case 'ArrayTypeAnnotation':
return wrap(val => `${val}.asObject(rt).asArray(rt)`);
case 'FunctionTypeAnnotation':
@@ -16,7 +16,7 @@ import type {
import type {
NativeModuleAliasMap,
NativeModuleEnumMap,
NativeModuleEnumMember,
NativeModuleEnumMembers,
NativeModuleEnumMemberType,
NativeModuleEventEmitterShape,
NativeModuleFunctionTypeAnnotation,
@@ -179,8 +179,6 @@ function translatePrimitiveJSTypeToCpp(
return wrapOptional('jsi::String', isRequired);
case 'NumberTypeAnnotation':
return wrapOptional('double', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapOptional('double', isRequired);
case 'DoubleTypeAnnotation':
return wrapOptional('double', isRequired);
case 'FloatTypeAnnotation':
@@ -409,7 +407,7 @@ struct Bridging<${enumName}> {
function generateEnum(
hasteModuleName: string,
origEnumName: string,
members: $ReadOnlyArray<NativeModuleEnumMember>,
members: NativeModuleEnumMembers,
memberType: NativeModuleEnumMemberType,
): string {
const enumName = getEnumName(hasteModuleName, origEnumName);
@@ -136,7 +136,6 @@ function translateEventEmitterTypeToJavaType(
case 'StringLiteralUnionTypeAnnotation':
return 'String';
case 'NumberTypeAnnotation':
case 'NumberLiteralTypeAnnotation':
case 'FloatTypeAnnotation':
case 'DoubleTypeAnnotation':
case 'Int32TypeAnnotation':
@@ -204,8 +203,6 @@ function translateFunctionParamToJavaType(
return wrapOptional('String', isRequired);
case 'NumberTypeAnnotation':
return wrapOptional('double', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapOptional('double', isRequired);
case 'FloatTypeAnnotation':
return wrapOptional('double', isRequired);
case 'DoubleTypeAnnotation':
@@ -300,8 +297,6 @@ function translateFunctionReturnTypeToJavaType(
return wrapOptional('String', isRequired);
case 'NumberTypeAnnotation':
return wrapOptional('double', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapOptional('double', isRequired);
case 'FloatTypeAnnotation':
return wrapOptional('double', isRequired);
case 'DoubleTypeAnnotation':
@@ -378,8 +373,6 @@ function getFalsyReturnStatementFromReturnType(
return '';
case 'NumberTypeAnnotation':
return nullable ? 'return null;' : 'return 0;';
case 'NumberLiteralTypeAnnotation':
return nullable ? 'return null;' : 'return 0;';
case 'FloatTypeAnnotation':
return nullable ? 'return null;' : 'return 0.0;';
case 'DoubleTypeAnnotation':
@@ -197,8 +197,6 @@ function translateReturnTypeToKind(
}
case 'NumberTypeAnnotation':
return 'NumberKind';
case 'NumberLiteralTypeAnnotation':
return 'NumberKind';
case 'DoubleTypeAnnotation':
return 'NumberKind';
case 'FloatTypeAnnotation':
@@ -282,8 +280,6 @@ function translateParamTypeToJniType(
}
case 'NumberTypeAnnotation':
return !isRequired ? 'Ljava/lang/Double;' : 'D';
case 'NumberLiteralTypeAnnotation':
return !isRequired ? 'Ljava/lang/Double;' : 'D';
case 'DoubleTypeAnnotation':
return !isRequired ? 'Ljava/lang/Double;' : 'D';
case 'FloatTypeAnnotation':
@@ -364,8 +360,6 @@ function translateReturnTypeToJniType(
}
case 'NumberTypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
case 'NumberLiteralTypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
case 'DoubleTypeAnnotation':
return nullable ? 'Ljava/lang/Double;' : 'D';
case 'FloatTypeAnnotation':
@@ -23,7 +23,6 @@ import type {
NativeModuleObjectTypeAnnotation,
NativeModuleTypeAliasTypeAnnotation,
Nullable,
NumberLiteralTypeAnnotation,
ReservedTypeAnnotation,
StringLiteralTypeAnnotation,
StringLiteralUnionTypeAnnotation,
@@ -64,7 +63,6 @@ export type StructTypeAnnotation =
| StringLiteralTypeAnnotation
| StringLiteralUnionTypeAnnotation
| NativeModuleNumberTypeAnnotation
| NumberLiteralTypeAnnotation
| Int32TypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
@@ -100,8 +100,6 @@ function toObjCType(
return 'NSString *';
case 'NumberTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'FloatTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'Int32TypeAnnotation':
@@ -185,8 +183,6 @@ function toObjCValue(
return value;
case 'NumberTypeAnnotation':
return wrapPrimitive('double');
case 'NumberLiteralTypeAnnotation':
return wrapPrimitive('double');
case 'FloatTypeAnnotation':
return wrapPrimitive('double');
case 'Int32TypeAnnotation':
@@ -91,8 +91,6 @@ function toObjCType(
return 'NSString *';
case 'NumberTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'FloatTypeAnnotation':
return wrapCxxOptional('double', isRequired);
case 'Int32TypeAnnotation':
@@ -175,8 +173,6 @@ function toObjCValue(
return RCTBridgingTo('String');
case 'NumberTypeAnnotation':
return RCTBridgingTo('Double');
case 'NumberLiteralTypeAnnotation':
return RCTBridgingTo('Double');
case 'FloatTypeAnnotation':
return RCTBridgingTo('Double');
case 'Int32TypeAnnotation':
@@ -25,7 +25,6 @@ function getEventEmitterTypeObjCType(
case 'StringLiteralUnionTypeAnnotation':
return 'NSString *_Nonnull';
case 'NumberTypeAnnotation':
case 'NumberLiteralTypeAnnotation':
return 'NSNumber *_Nonnull';
case 'BooleanTypeAnnotation':
return 'BOOL';
@@ -263,8 +263,6 @@ function getParamObjCType(
return notStruct(wrapOptional('NSString *', !nullable));
case 'NumberTypeAnnotation':
return notStruct(isRequired ? 'double' : 'NSNumber *');
case 'NumberLiteralTypeAnnotation':
return notStruct(isRequired ? 'double' : 'NSNumber *');
case 'FloatTypeAnnotation':
return notStruct(isRequired ? 'float' : 'NSNumber *');
case 'DoubleTypeAnnotation':
@@ -346,8 +344,6 @@ function getReturnObjCType(
return wrapOptional('NSString *', isRequired);
case 'NumberTypeAnnotation':
return wrapOptional('NSNumber *', isRequired);
case 'NumberLiteralTypeAnnotation':
return wrapOptional('NSNumber *', isRequired);
case 'FloatTypeAnnotation':
return wrapOptional('NSNumber *', isRequired);
case 'DoubleTypeAnnotation':
@@ -418,8 +414,6 @@ function getReturnJSType(
return 'StringKind';
case 'NumberTypeAnnotation':
return 'NumberKind';
case 'NumberLiteralTypeAnnotation':
return 'NumberKind';
case 'FloatTypeAnnotation':
return 'NumberKind';
case 'DoubleTypeAnnotation':
@@ -496,9 +496,7 @@ const SIMPLE_NATIVE_MODULES: SchemaType = {
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
name: 'StringEnum',
type: 'EnumDeclaration',
memberType: 'StringTypeAnnotation',
type: 'StringTypeAnnotation',
},
params: [
{
@@ -126,7 +126,6 @@ import * as TurboModuleRegistry from '../TurboModuleRegistry';
export interface Spec extends TurboModule {
+passBool?: (arg: boolean) => void;
+passNumber: (arg: number) => void;
+passNumberLiteral: (arg: 4) => void;
+passString: (arg: string) => void;
+passStringish: (arg: Stringish) => void;
+passStringLiteral: (arg: 'A String Literal') => void;
@@ -812,7 +811,7 @@ export type CustomDeviceEvent = {
export interface Spec extends TurboModule {
+getCallback: () => () => void;
+getMixed: (arg: mixed) => mixed;
+getEnums: (quality: Quality, resolution?: Resolution, stringOptions: StringOptions) => Quality;
+getEnums: (quality: Quality, resolution?: Resolution, stringOptions: StringOptions) => string;
+getBinaryTreeNode: (arg: BinaryTreeNode) => BinaryTreeNode;
+getGraphNode: (arg: GraphNode) => GraphNode;
+getMap: (arg: {[a: string]: ?number}) => {[b: string]: ?number};
@@ -227,9 +227,7 @@ exports[`RN Codegen Flow Parser can generate fixture CXX_ONLY_NATIVE_MODULE 1`]
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'name': 'Quality',
'type': 'EnumDeclaration',
'memberType': 'StringTypeAnnotation'
'type': 'StringTypeAnnotation'
},
'params': [
{
@@ -978,26 +976,6 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_BASIC_PA
]
}
},
{
'name': 'passNumberLiteral',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'NumberLiteralTypeAnnotation',
'value': 4
}
}
]
}
},
{
'name': 'passString',
'optional': false,
@@ -38,7 +38,6 @@ const {
emitCommonTypes,
emitDictionary,
emitFunction,
emitNumberLiteral,
emitPromise,
emitRootTag,
emitUnion,
@@ -244,9 +243,6 @@ function translateTypeAnnotation(
case 'UnionTypeAnnotation': {
return emitUnion(nullable, hasteModuleName, typeAnnotation, parser);
}
case 'NumberLiteralTypeAnnotation': {
return emitNumberLiteral(nullable, typeAnnotation.value);
}
case 'StringLiteralTypeAnnotation': {
return wrapNullable(nullable, {
type: 'StringLiteralTypeAnnotation',
+2 -4
View File
@@ -15,7 +15,7 @@ import type {
NamedShape,
NativeModuleAliasMap,
NativeModuleEnumMap,
NativeModuleEnumMember,
NativeModuleEnumMembers,
NativeModuleEnumMemberType,
NativeModuleParamTypeAnnotation,
Nullable,
@@ -227,9 +227,7 @@ class FlowParser implements Parser {
});
}
parseEnumMembers(
typeAnnotation: $FlowFixMe,
): $ReadOnlyArray<NativeModuleEnumMember> {
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
return typeAnnotation.members.map(member => ({
name: member.id.name,
value: member.init?.value ?? member.id.name,
+2 -4
View File
@@ -15,7 +15,7 @@ import type {
NamedShape,
NativeModuleAliasMap,
NativeModuleEnumMap,
NativeModuleEnumMember,
NativeModuleEnumMembers,
NativeModuleEnumMemberType,
NativeModuleParamTypeAnnotation,
Nullable,
@@ -240,9 +240,7 @@ export interface Parser {
/**
* Calculates enum's members
*/
parseEnumMembers(
typeAnnotation: $FlowFixMe,
): $ReadOnlyArray<NativeModuleEnumMember>;
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers;
/**
* Given a node, it returns true if it is a module interface
+2 -4
View File
@@ -15,7 +15,7 @@ import type {
NamedShape,
NativeModuleAliasMap,
NativeModuleEnumMap,
NativeModuleEnumMember,
NativeModuleEnumMembers,
NativeModuleEnumMemberType,
NativeModuleParamTypeAnnotation,
Nullable,
@@ -168,9 +168,7 @@ export class MockedParser implements Parser {
return;
}
parseEnumMembers(
typeAnnotation: $FlowFixMe,
): $ReadOnlyArray<NativeModuleEnumMember> {
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
return typeAnnotation.type === 'StringTypeAnnotation'
? [
{
@@ -31,7 +31,6 @@ import type {
NativeModuleTypeAnnotation,
NativeModuleUnionTypeAnnotation,
Nullable,
NumberLiteralTypeAnnotation,
ObjectTypeAnnotation,
ReservedTypeAnnotation,
StringLiteralTypeAnnotation,
@@ -171,16 +170,6 @@ function emitMixed(
});
}
function emitNumberLiteral(
nullable: boolean,
value: number,
): Nullable<NumberLiteralTypeAnnotation> {
return wrapNullable(nullable, {
type: 'NumberLiteralTypeAnnotation',
value,
});
}
function emitString(nullable: boolean): Nullable<StringTypeAnnotation> {
return wrapNullable(nullable, {
type: 'StringTypeAnnotation',
@@ -773,7 +762,6 @@ module.exports = {
emitInt32Prop,
emitMixedProp,
emitNumber,
emitNumberLiteral,
emitGenericObject,
emitDictionary,
emitObject,
@@ -113,7 +113,6 @@ import * as TurboModuleRegistry from '../TurboModuleRegistry';
export interface Spec extends TurboModule {
readonly passBool?: (arg: boolean) => void;
readonly passNumber: (arg: number) => void;
readonly passNumberLiteral: (arg: 4) => void;
readonly passString: (arg: string) => void;
readonly passStringish: (arg: Stringish) => void;
readonly passStringLiteral: (arg: 'A String Literal') => void;
@@ -901,7 +900,7 @@ export type CustomDeviceEvent = {
export interface Spec extends TurboModule {
readonly getCallback: () => () => void;
readonly getMixed: (arg: unknown) => unknown;
readonly getEnums: (quality: Quality, resolution?: Resolution, stringOptions: StringOptions) => Quality;
readonly getEnums: (quality: Quality, resolution?: Resolution, stringOptions: StringOptions) => string;
readonly getBinaryTreeNode: (arg: BinaryTreeNode) => BinaryTreeNode;
readonly getGraphNode: (arg: GraphNode) => GraphNode;
readonly getMap: (arg: {[a: string]: number | null;}) => {[b: string]: number | null;};
@@ -218,9 +218,7 @@ exports[`RN Codegen TypeScript Parser can generate fixture CXX_ONLY_NATIVE_MODUL
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'name': 'Quality',
'type': 'EnumDeclaration',
'memberType': 'StringTypeAnnotation'
'type': 'StringTypeAnnotation'
},
'params': [
{
@@ -1123,26 +1121,6 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_BA
]
}
},
{
'name': 'passNumberLiteral',
'optional': false,
'typeAnnotation': {
'type': 'FunctionTypeAnnotation',
'returnTypeAnnotation': {
'type': 'VoidTypeAnnotation'
},
'params': [
{
'name': 'arg',
'optional': false,
'typeAnnotation': {
'type': 'NumberLiteralTypeAnnotation',
'value': 4
}
}
]
}
},
{
'name': 'passString',
'optional': false,
@@ -37,7 +37,6 @@ const {
emitCommonTypes,
emitDictionary,
emitFunction,
emitNumberLiteral,
emitPromise,
emitRootTag,
emitStringLiteral,
@@ -404,9 +403,6 @@ function translateTypeAnnotation(
case 'StringLiteral': {
return emitStringLiteral(nullable, literal.value);
}
case 'NumericLiteral': {
return emitNumberLiteral(nullable, literal.value);
}
default: {
throw new UnsupportedTypeAnnotationParserError(
hasteModuleName,
@@ -15,7 +15,7 @@ import type {
NamedShape,
NativeModuleAliasMap,
NativeModuleEnumMap,
NativeModuleEnumMember,
NativeModuleEnumMembers,
NativeModuleEnumMemberType,
NativeModuleParamTypeAnnotation,
Nullable,
@@ -223,9 +223,7 @@ class TypeScriptParser implements Parser {
});
}
parseEnumMembers(
typeAnnotation: $FlowFixMe,
): $ReadOnlyArray<NativeModuleEnumMember> {
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
return typeAnnotation.members.map(member => ({
name: member.id.name,
value: member.initializer?.value ?? member.id.name,
@@ -16,5 +16,5 @@ import * as React from 'react';
export default (createAnimatedComponent(FlatList): AnimatedComponentType<
React.ElementConfig<typeof FlatList>,
FlatList<mixed>,
React.ElementRef<typeof FlatList>,
>);
@@ -8,9 +8,7 @@
#import <React/RCTBridgeDelegate.h>
#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
#import "RCTArchConfiguratorProtocol.h"
#import "RCTRootViewFactory.h"
#import "RCTUIConfiguratorProtocol.h"
@class RCTBridge;
@protocol RCTBridgeDelegate;
@@ -57,12 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
(const facebook::react::ObjCTurboModule::InitParams &)params
* - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
*/
@interface RCTAppDelegate : UIResponder <
UIApplicationDelegate,
UISceneDelegate,
RCTBridgeDelegate,
RCTUIConfiguratorProtocol,
RCTArchConfiguratorProtocol>
@interface RCTAppDelegate : UIResponder <UIApplicationDelegate, UISceneDelegate, RCTBridgeDelegate>
/// The window object, used to render the UViewControllers
@property (nonatomic, strong, nonnull) UIWindow *window;
@@ -103,6 +96,48 @@ NS_ASSUME_NONNULL_BEGIN
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps;
/**
* This method can be used to customize the rootView that is passed to React Native.
* A typical example is to override this method in the AppDelegate to change the background color.
* To achieve this, add in your `AppDelegate.mm`:
* ```
* - (void)customizeRootView:(RCTRootView *)rootView
* {
* rootView.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
* if ([traitCollection userInterfaceStyle] == UIUserInterfaceStyleDark) {
* return [UIColor blackColor];
* } else {
* return [UIColor whiteColor];
* }
* }];
* }
* ```
*
* @parameter: rootView - The root view to customize.
*/
- (void)customizeRootView:(RCTRootView *)rootView;
/**
* It creates the RootViewController.
* By default, it creates a new instance of a `UIViewController`.
* You can override it to provide your own initial ViewController.
*
* @return: an instance of `UIViewController`.
*/
- (UIViewController *)createRootViewController;
/**
* It assigns the rootView to the rootViewController
* By default, it assigns the rootView to the view property of the rootViewController
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
* For example: UISplitViewController requires `setViewController(_:for:)`
*/
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
/**
* The default `RCTColorSpace` for the app. It defaults to `RCTColorSpaceSRGB`.
*/
@property (nonatomic, readonly) RCTColorSpace defaultColorSpace;
/// This method returns a map of Component Descriptors and Components classes that needs to be registered in the
/// new renderer. The Component Descriptor is a string which represent the name used in JS to refer to the native
@@ -112,6 +147,27 @@ NS_ASSUME_NONNULL_BEGIN
/// @return a dictionary that associate a component for the new renderer with his descriptor.
- (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents;
/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off.
///
/// @note: This is required to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the Turbo Native Module are enabled. Otherwise, it returns `false`.
- (BOOL)turboModuleEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether the App will use the Fabric renderer of the New Architecture or not.
///
/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`.
- (BOOL)fabricEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether React Native's new initialization layer is enabled.
///
/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`.
- (BOOL)bridgelessEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether React Native uses new Architecture.
///
/// @return: `true` if the new architecture is enabled. Otherwise returns `false`.
- (BOOL)newArchEnabled;
/// Return the bundle URL for the main bundle.
- (NSURL *__nullable)bundleURL;
@@ -34,8 +34,6 @@
#endif
#import <react/nativemodule/defaults/DefaultTurboModules.h>
using namespace facebook::react;
@interface RCTAppDelegate () <RCTComponentViewFactoryComponentProvider, RCTHostDelegate>
@end
@@ -78,7 +76,6 @@ using namespace facebook::react;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [self createRootViewController];
[self setRootView:rootView toRootViewController:rootViewController];
_window.windowScene.delegate = self;
_window.rootViewController = rootViewController;
[_window makeKeyAndVisible];
}
@@ -181,6 +178,18 @@ using namespace facebook::react;
{
}
- (void)host:(RCTHost *)host
didReceiveJSErrorStack:(NSArray<NSDictionary<NSString *, id> *> *)stack
message:(NSString *)message
originalMessage:(NSString *_Nullable)originalMessage
name:(NSString *_Nullable)name
componentStack:(NSString *_Nullable)componentStack
exceptionId:(NSUInteger)exceptionId
isFatal:(BOOL)isFatal
extraData:(NSDictionary<NSString *, id> *)extraData
{
}
#pragma mark - Bridge and Bridge Adapter properties
- (RCTBridge *)bridge
@@ -214,14 +223,15 @@ using namespace facebook::react;
#endif
}
- (std::shared_ptr<TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<CallInvoker>)jsInvoker
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return DefaultTurboModules::getTurboModule(name, jsInvoker);
return facebook::react::DefaultTurboModules::getTurboModule(name, jsInvoker);
}
- (std::shared_ptr<TurboModule>)getTurboModule:(const std::string &)name
initParams:(const ObjCTurboModule::InitParams &)params
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
@@ -295,7 +305,7 @@ using namespace facebook::react;
#pragma mark - Feature Flags
class RCTAppDelegateBridgelessFeatureFlags : public ReactNativeFeatureFlagsDefaults {
class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
public:
bool enableBridgelessArchitecture() override
{
@@ -309,16 +319,12 @@ class RCTAppDelegateBridgelessFeatureFlags : public ReactNativeFeatureFlagsDefau
{
return true;
}
bool useNativeViewConfigsInBridgelessMode() override
{
return true;
}
};
- (void)_setUpFeatureFlags
{
if ([self bridgelessEnabled]) {
ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
facebook::react::ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
}
}
@@ -53,9 +53,7 @@ RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
[surface start];
return rootView;
return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
}
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
}
@@ -1,32 +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.
*/
#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
@protocol RCTArchConfiguratorProtocol
/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off.
///
/// @note: This is required to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the Turbo Native Module are enabled. Otherwise, it returns `false`.
- (BOOL)turboModuleEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether the App will use the Fabric renderer of the New Architecture or not.
///
/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`.
- (BOOL)fabricEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether React Native's new initialization layer is enabled.
///
/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`.
- (BOOL)bridgelessEnabled __attribute__((deprecated("Use newArchEnabled instead")));
/// This method controls whether React Native uses new Architecture.
///
/// @return: `true` if the new architecture is enabled. Otherwise returns `false`.
- (BOOL)newArchEnabled;
@end
@@ -161,9 +161,12 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
initialProperties:(NSDictionary *)initialProperties
launchOptions:(NSDictionary *)launchOptions
{
NSDictionary *initProps = updateInitialProps(initialProperties, _configuration.fabricEnabled);
NSDictionary *initProps = updateInitialProps(initialProperties, self->_configuration.fabricEnabled);
if (self->_configuration.bridgelessEnabled) {
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
RCTSetUseNativeViewConfigsInBridgelessMode(self->_configuration.fabricEnabled);
if (_configuration.bridgelessEnabled) {
// Enable TurboModule interop by default in Bridgeless mode
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);
@@ -172,8 +175,9 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
[[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
if (self->_configuration.customizeRootView != nil) {
@@ -186,8 +190,8 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
[self createBridgeAdapterIfNeeded];
UIView *rootView;
if (_configuration.createRootViewWithBridge != nil) {
rootView = _configuration.createRootViewWithBridge(self.bridge, moduleName, initProps);
if (self->_configuration.createRootViewWithBridge != nil) {
rootView = self->_configuration.createRootViewWithBridge(self.bridge, moduleName, initProps);
} else {
rootView = [self createRootViewWithBridge:self.bridge moduleName:moduleName initProps:initProps];
}
@@ -1,56 +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.
*/
#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
@class RCTRootView;
@protocol RCTUIConfiguratorProtocol
/**
* The default `RCTColorSpace` for the app. It defaults to `RCTColorSpaceSRGB`.
*/
- (RCTColorSpace)defaultColorSpace;
/**
* This method can be used to customize the rootView that is passed to React Native.
* A typical example is to override this method in the AppDelegate to change the background color.
* To achieve this, add in your `AppDelegate.mm`:
* ```
* - (void)customizeRootView:(RCTRootView *)rootView
* {
* rootView.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
* if ([traitCollection userInterfaceStyle] == UIUserInterfaceStyleDark) {
* return [UIColor blackColor];
* } else {
* return [UIColor whiteColor];
* }
* }];
* }
* ```
*
* @parameter: rootView - The root view to customize.
*/
- (void)customizeRootView:(RCTRootView *)rootView;
/**
* It creates the RootViewController.
* By default, it creates a new instance of a `UIViewController`.
* You can override it to provide your own initial ViewController.
*
* @return: an instance of `UIViewController`.
*/
- (UIViewController *)createRootViewController;
/**
* It assigns the rootView to the rootViewController
* By default, it assigns the rootView to the view property of the rootViewController
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
* For example: UISplitViewController requires `setViewController(_:for:)`
*/
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
@end
@@ -64,7 +64,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES"
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Private/Yoga\""}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
s.dependency "React-Core"
s.dependency "RCT-Folly", folly_version
@@ -55,7 +55,6 @@ const EventNames: Map<
['highTextContrastChanged', 'highTextContrastDidChange'],
['screenReaderChanged', 'touchExplorationDidChange'],
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
['invertColorsChanged', 'invertColorDidChange'],
])
: new Map([
['announcementFinished', 'announcementFinished'],
@@ -139,13 +138,7 @@ const AccessibilityInfo = {
*/
isInvertColorsEnabled(): Promise<boolean> {
if (Platform.OS === 'android') {
return new Promise((resolve, reject) => {
if (NativeAccessibilityInfoAndroid?.isInvertColorsEnabled != null) {
NativeAccessibilityInfoAndroid.isInvertColorsEnabled(resolve);
} else {
reject(null);
}
});
return Promise.resolve(false);
} else {
return new Promise((resolve, reject) => {
if (NativeAccessibilityManagerIOS != null) {
+27 -44
View File
@@ -141,31 +141,24 @@ let inExceptionHandler = false;
* Logs exceptions to the (native) console and displays them
*/
function handleException(e: mixed, isFatal: boolean) {
// TODO(T196834299): We should really use a c++ turbomodule for this
const reportToConsole = true;
if (
!global.RN$handleException ||
!global.RN$handleException(e, isFatal, reportToConsole)
) {
let error: Error;
if (e instanceof Error) {
error = e;
} else {
// Workaround for reporting errors caused by `throw 'some string'`
// Unfortunately there is no way to figure out the stacktrace in this
// case, so if you ended up here trying to trace an error, look for
// `throw '<error message>'` somewhere in your codebase.
error = new SyntheticError(e);
}
try {
inExceptionHandler = true;
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
* parameters */
// $FlowFixMe[incompatible-call]
reportException(error, isFatal, reportToConsole);
} finally {
inExceptionHandler = false;
}
let error: Error;
if (e instanceof Error) {
error = e;
} else {
// Workaround for reporting errors caused by `throw 'some string'`
// Unfortunately there is no way to figure out the stacktrace in this
// case, so if you ended up here trying to trace an error, look for
// `throw '<error message>'` somewhere in your codebase.
error = new SyntheticError(e);
}
try {
inExceptionHandler = true;
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
* parameters */
// $FlowFixMe[incompatible-call]
reportException(error, isFatal, /*reportToConsole*/ true);
} finally {
inExceptionHandler = false;
}
}
@@ -177,10 +170,7 @@ function reactConsoleErrorHandler(...args) {
if (!console.reportErrorsAsExceptions) {
return;
}
if (
inExceptionHandler ||
(global.RN$inExceptionHandler && global.RN$inExceptionHandler())
) {
if (inExceptionHandler) {
// The fundamental trick here is that are multiple entry point to logging errors:
// (see D19743075 for more background)
//
@@ -234,21 +224,14 @@ function reactConsoleErrorHandler(...args) {
error.name = 'console.error';
}
const isFatal = false;
const reportToConsole = false;
if (
!global.RN$handleException ||
!global.RN$handleException(error, isFatal, reportToConsole)
) {
reportException(
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
* parameters */
// $FlowFixMe[incompatible-call]
error,
isFatal,
reportToConsole,
);
}
reportException(
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
* parameters */
// $FlowFixMe[incompatible-call]
error,
false, // isFatal
false, // reportToConsole
);
}
/**
@@ -14,6 +14,7 @@ import typeof NativeExceptionsManager from '../NativeExceptionsManager';
export default ({
reportFatalException: jest.fn(),
reportSoftException: jest.fn(),
updateExceptionMessage: jest.fn(),
dismissRedbox: jest.fn(),
reportException: jest.fn(),
}: NativeExceptionsManager);
@@ -67,6 +67,8 @@ function runExceptionsManagerTests() {
return {
default: {
reportException: jest.fn(),
// Used to show symbolicated messages, not part of this test.
updateExceptionMessage: () => {},
},
};
});
+7 -1
View File
@@ -21,7 +21,13 @@ ExceptionsManager.installConsoleErrorReporter();
if (!global.__fbDisableExceptionsManager) {
const handleError = (e: mixed, isFatal: boolean) => {
try {
ExceptionsManager.handleException(e, isFatal);
// TODO(T196834299): We should really use a c++ turbomodule for this
if (
!global.RN$handleException ||
!global.RN$handleException(e, isFatal)
) {
ExceptionsManager.handleException(e, isFatal);
}
} catch (ee) {
console.log('Failed to print error: ', ee.message);
throw e;
+29 -18
View File
@@ -60,28 +60,18 @@ export interface ImagePropsIOS {
interface ImagePropsAndroid {
/**
* The mechanism that should be used to resize the image when the image's dimensions
* differ from the image view's dimensions. Defaults to `auto`.
* differ from the image view's dimensions. Defaults to auto.
*
* - `auto`: Use heuristics to pick between `resize` and `scale`.
* 'auto': Use heuristics to pick between resize and scale.
*
* - `resize`: A software operation which changes the encoded image in memory before it
* gets decoded. This should be used instead of `scale` when the image is much larger
* than the view.
* 'resize': A software operation which changes the encoded image in memory before it gets decoded.
* This should be used instead of scale when the image is much larger than the view.
*
* - `scale`: The image gets drawn downscaled or upscaled. Compared to `resize`, `scale` is
* faster (usually hardware accelerated) and produces higher quality images. This
* should be used if the image is smaller than the view. It should also be used if the
* image is slightly bigger than the view.
*
* - `none`: No sampling is performed and the image is displayed in its full resolution. This
* should only be used in rare circumstances because it is considered unsafe as Android will
* throw a runtime exception when trying to render images that consume too much memory.
*
* More details about `resize` and `scale` can be found at http://frescolib.org/docs/resizing-rotating.html.
*
* @platform android
* 'scale': The image gets drawn downscaled or upscaled. Compared to resize, scale is faster (usually hardware accelerated)
* and produces higher quality images. This should be used if the image is smaller than the view.
* It should also be used if the image is slightly bigger than the view.
*/
resizeMethod?: 'auto' | 'resize' | 'scale' | 'none' | undefined;
resizeMethod?: 'auto' | 'resize' | 'scale' | undefined;
/**
* Duration of fade in animation in ms. Defaults to 300
@@ -203,6 +193,27 @@ export interface ImagePropsBase
*/
resizeMode?: ImageResizeMode | undefined;
/**
* The mechanism that should be used to resize the image when the image's dimensions
* differ from the image view's dimensions. Defaults to `auto`.
*
* - `auto`: Use heuristics to pick between `resize` and `scale`.
*
* - `resize`: A software operation which changes the encoded image in memory before it
* gets decoded. This should be used instead of `scale` when the image is much larger
* than the view.
*
* - `scale`: The image gets drawn downscaled or upscaled. Compared to `resize`, `scale` is
* faster (usually hardware accelerated) and produces higher quality images. This
* should be used if the image is smaller than the view. It should also be used if the
* image is slightly bigger than the view.
*
* More details about `resize` and `scale` can be found at http://frescolib.org/docs/resizing-rotating.html.
*
* @platform android
*/
resizeMethod?: 'auto' | 'resize' | 'scale' | undefined;
/**
* The image source (either a remote URL or a local file resource).
*
+1 -1
View File
@@ -51,7 +51,7 @@ export interface ImageURISource {
* to a URL load request, no attempt is made to load the data from the originating source,
* and the load is considered to have failed.
*
* @platform ios (for `force-cache`)
* @platform ios
*/
cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined;
/**
+1 -1
View File
@@ -66,7 +66,7 @@ export interface ImageURISource {
* to a URL load request, no attempt is made to load the data from the originating source,
* and the load is considered to have failed.
*
* @platform ios (for `force-cache`)
* @platform ios
*/
+cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached');
@@ -477,10 +477,7 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, CGSize size, CGFloat scal
// Add missing png extension
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
NSURL *pngRequestURL = [request.URL URLByAppendingPathExtension:@"png"];
if ([[NSFileManager defaultManager] fileExistsAtPath:pngRequestURL.path]) {
mutableRequest.URL = pngRequestURL;
}
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
}
if (_redirectDelegate != nil) {
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
+2 -2
View File
@@ -480,10 +480,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
this._checkProps(this.props);
}
_listRef: ?VirtualizedList;
_listRef: ?React.ElementRef<typeof VirtualizedList>;
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];
_captureRef = (ref: ?VirtualizedList) => {
_captureRef = (ref: ?React.ElementRef<typeof VirtualizedList>) => {
this._listRef = ref;
};
+17 -26
View File
@@ -37,8 +37,6 @@ const COLORS = {
'ansi-bright-white': 'rgb(247, 247, 247)',
};
const LRM = '\u200E'; // Left-to-Right Mark
export default function Ansi({
text,
style,
@@ -82,28 +80,25 @@ export default function Ansi({
};
return (
<View style={styles.container}>
<View>
{parsedLines.map((items, i) => (
<View style={styles.line} key={i}>
<Text>
{LRM}
{items.map((bundle, key) => {
const textStyle =
bundle.fg && COLORS[bundle.fg]
? {
backgroundColor: bundle.bg && COLORS[bundle.bg],
color: bundle.fg && COLORS[bundle.fg],
}
: {
backgroundColor: bundle.bg && COLORS[bundle.bg],
};
return (
<Text style={[style, textStyle]} key={key}>
{getText(bundle.content, key)}
</Text>
);
})}
</Text>
{items.map((bundle, key) => {
const textStyle =
bundle.fg && COLORS[bundle.fg]
? {
backgroundColor: bundle.bg && COLORS[bundle.bg],
color: bundle.fg && COLORS[bundle.fg],
}
: {
backgroundColor: bundle.bg && COLORS[bundle.bg],
};
return (
<Text style={[style, textStyle]} key={key}>
{getText(bundle.content, key)}
</Text>
);
})}
</View>
))}
</View>
@@ -111,10 +106,6 @@ export default function Ansi({
}
const styles = StyleSheet.create({
container: {
minWidth: '100%',
direction: 'ltr',
},
line: {
flexDirection: 'row',
},
@@ -59,9 +59,7 @@ function LogBoxInspectorCodeFrame(props: Props): React.Node {
<LogBoxInspectorSection heading="Source" action={<AppInfo />}>
<View style={styles.box}>
<View style={styles.frame}>
<ScrollView
horizontal
contentContainerStyle={styles.contentContainer}>
<ScrollView horizontal>
<AnsiHighlight style={styles.content} text={codeFrame.content} />
</ScrollView>
</View>
@@ -140,9 +138,6 @@ const styles = StyleSheet.create({
paddingTop: 10,
paddingBottom: 10,
},
contentContainer: {
minWidth: '100%',
},
content: {
color: LogBoxStyle.getTextColor(1),
fontSize: 12,
@@ -26,11 +26,6 @@ exports[`LogBoxInspectorCodeFrame should render a code frame 1`] = `
}
>
<ScrollView
contentContainerStyle={
Object {
"minWidth": "100%",
}
}
horizontal={true}
>
<Ansi
@@ -113,11 +108,6 @@ exports[`LogBoxInspectorCodeFrame should render a code frame without a location
}
>
<ScrollView
contentContainerStyle={
Object {
"minWidth": "100%",
}
}
horizontal={true}
>
<Ansi
@@ -80,7 +80,7 @@ describe('LogBox', () => {
expect(mockWarn).not.toBeCalled();
expect(console.error).toBeCalledTimes(1);
expect(console.error.mock.calls[0]).toEqual([
'Warning: Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.%s',
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.%s',
'\n\nCheck the render method of `DoesNotUseKey`.',
'',
expect.stringMatching('at DoesNotUseKey'),
@@ -94,7 +94,7 @@ describe('LogBox', () => {
componentStackType: 'stack',
message: {
content:
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://reactjs.org/link/warning-keys for more information.',
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://react.dev/link/warning-keys for more information.',
substitutions: [
{length: 45, offset: 62},
{length: 0, offset: 107},
@@ -106,7 +106,7 @@ describe('LogBox', () => {
// We also interpolate the string before passing to the underlying console method.
expect(mockError.mock.calls[0]).toEqual([
expect.stringMatching(
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://reactjs.org/link/warning-keys for more information.\n at ',
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://react.dev/link/warning-keys for more information.\n at ',
),
]);
});
@@ -134,7 +134,7 @@ describe('LogBox', () => {
expect(mockWarn).not.toBeCalled();
expect(console.error).toBeCalledTimes(1);
expect(console.error.mock.calls[0]).toEqual([
'Warning: Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.%s',
'Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.%s',
'invalid',
expect.stringMatching('at FragmentWithProp'),
]);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -9,7 +9,8 @@
#import <React/RCTDynamicTypeRamp.h>
#import <React/RCTTextDecorationLineType.h>
#import <React/RCTTextTransform.h>
#import "RCTTextTransform.h"
NS_ASSUME_NONNULL_BEGIN
@@ -278,15 +278,19 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
static NSString *capitalizeText(NSString *text)
{
NSMutableString *result = [[NSMutableString alloc] initWithString:text];
[result
enumerateSubstringsInRange:NSMakeRange(0, text.length)
options:NSStringEnumerationByWords
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[result replaceCharactersInRange:NSMakeRange(substringRange.location, 1)
withString:[[substring substringToIndex:1] uppercaseString]];
}];
return result;
NSArray *words = [text componentsSeparatedByString:@" "];
NSMutableArray *newWords = [NSMutableArray new];
NSNumberFormatter *num = [NSNumberFormatter new];
for (NSString *item in words) {
NSString *word;
if ([item length] > 0 && [num numberFromString:[item substringWithRange:NSMakeRange(0, 1)]] == nil) {
word = [item capitalizedString];
} else {
word = [item lowercaseString];
}
[newWords addObject:word];
}
return [newWords componentsJoinedByString:@" "];
}
- (NSString *)applyTextAttributesToText:(NSString *)text
@@ -36,7 +36,6 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
{
if (![self isDescendantOfView:scrollView]) {
// View is outside scroll view
scrollView.firstResponderViewOutsideScrollView = self.backedTextInputView;
return;
}
@@ -683,7 +683,7 @@ exports[`public API should not change unintentionally Libraries/Animated/bezier.
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedFlatList.js 1`] = `
"declare export default AnimatedComponentType<
React.ElementConfig<typeof FlatList>,
FlatList<mixed>,
React.ElementRef<typeof FlatList>,
>;
"
`;
@@ -5725,7 +5725,7 @@ declare class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
setNativeProps(props: { [string]: mixed, ... }): void;
constructor(props: Props<ItemT>): void;
componentDidUpdate(prevProps: Props<ItemT>): void;
_listRef: ?VirtualizedList;
_listRef: ?React.ElementRef<typeof VirtualizedList>;
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair>;
_captureRef: $FlowFixMe;
_checkProps(props: Props<ItemT>): void;
@@ -18,9 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface RCTBridgeProxy : NSProxy
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
@@ -41,8 +41,6 @@ using namespace facebook;
void *_runtime;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
@@ -63,10 +61,8 @@ using namespace facebook;
_runtime = runtime;
_launchOptions = [launchOptions copy];
}
return self;
}
#pragma clang diagnostic pop
- (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue
{
@@ -418,10 +414,6 @@ using namespace facebook;
RCTViewRegistry *_viewRegistry;
NSMutableDictionary<NSNumber *, UIView *> *_legacyViewRegistry;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
{
self = [super self];
@@ -432,8 +424,6 @@ using namespace facebook;
return self;
}
#pragma clang diagnostic pop
/**
* RCTViewRegistry
*/
@@ -11,11 +11,6 @@
std::shared_ptr<facebook::react::CallInvoker> _callInvoker;
}
- (instancetype)init
{
return [self initWithCallInvoker:nullptr];
}
- (instancetype)initWithCallInvoker:(std::shared_ptr<facebook::react::CallInvoker>)callInvoker
{
if (self = [super init]) {
@@ -50,3 +50,15 @@ RCT_EXTERN NSString *const RCTDidInitializeModuleNotification;
*/
RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
/*
* Memory Pressure Unloading Level
*/
RCT_EXTERN int RCTGetMemoryPressureUnloadLevel(void);
RCT_EXTERN void RCTSetMemoryPressureUnloadLevel(int value);
/*
* Use native view configs in bridgeless mode
*/
RCT_EXTERN BOOL RCTGetUseNativeViewConfigsInBridgelessMode(void);
RCT_EXTERN void RCTSetUseNativeViewConfigsInBridgelessMode(BOOL value);
@@ -38,3 +38,34 @@ void RCTSetDispatchW3CPointerEvents(BOOL value)
{
RCTDispatchW3CPointerEvents = value;
}
/*
* Memory Pressure Unloading Level for experimentation only.
* Default is 15, which is TRIM_MEMORY_RUNNING_CRITICAL.
*/
static int RCTMemoryPressureUnloadLevel = 15;
int RCTGetMemoryPressureUnloadLevel(void)
{
return RCTMemoryPressureUnloadLevel;
}
void RCTSetMemoryPressureUnloadLevel(int value)
{
RCTMemoryPressureUnloadLevel = value;
}
/*
* Use native view configs in bridgeless mode
*/
static BOOL RCTUseNativeViewConfigsInBridgelessMode = NO;
BOOL RCTGetUseNativeViewConfigsInBridgelessMode(void)
{
return RCTUseNativeViewConfigsInBridgelessMode;
}
void RCTSetUseNativeViewConfigsInBridgelessMode(BOOL value)
{
RCTUseNativeViewConfigsInBridgelessMode = value;
}
@@ -34,7 +34,7 @@ typedef id<RCTBridgeModule> (^RCTBridgeModuleProvider)(void);
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules NS_DESIGNATED_INITIALIZER;
callableJSModules:(RCTCallableJSModules *)callableJSModules;
- (instancetype)initWithModuleInstance:(id<RCTBridgeModule>)instance
bridge:(RCTBridge *)bridge
@@ -53,21 +53,8 @@ int32_t getUniqueId()
@synthesize instance = _instance;
@synthesize methodQueue = _methodQueue;
- (void)_setUpWithBridge:(RCTBridge *)bridge
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules
- (void)setUp
{
// start with the ivars
{
_bridge = bridge;
_moduleRegistry = moduleRegistry;
_viewRegistry_DEPRECATED = viewRegistry_DEPRECATED;
_bundleManager = bundleManager;
_callableJSModules = callableJSModules;
}
_implementsBatchDidComplete = [_moduleClass instancesRespondToSelector:@selector(batchDidComplete)];
// If a module overrides `constantsToExport` and doesn't implement `requiresMainQueueSetup`, then we must assume
@@ -99,17 +86,35 @@ int32_t getUniqueId()
viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules
{
return [self _initWithModuleClass:moduleClass
moduleProvider:^id<RCTBridgeModule> {
return [moduleClass new];
}
bridge:bridge
moduleRegistry:moduleRegistry
viewRegistry_DEPRECATED:viewRegistry_DEPRECATED
bundleManager:bundleManager
callableJSModules:callableJSModules];
}
- (instancetype)_initWithModuleClass:(Class)moduleClass
moduleProvider:(RCTBridgeModuleProvider)moduleProvider
bridge:(RCTBridge *)bridge
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED
bundleManager:(RCTBundleManager *)bundleManager
callableJSModules:(RCTCallableJSModules *)callableJSModules
{
if (self = [super init]) {
_bridge = bridge;
_moduleClass = moduleClass;
_moduleProvider = [^id<RCTBridgeModule> {
return [moduleClass new];
} copy];
[self _setUpWithBridge:bridge
moduleRegistry:moduleRegistry
viewRegistry_DEPRECATED:viewRegistry_DEPRECATED
bundleManager:bundleManager
callableJSModules:callableJSModules];
_moduleProvider = [moduleProvider copy];
_moduleRegistry = moduleRegistry;
_viewRegistry_DEPRECATED = viewRegistry_DEPRECATED;
_bundleManager = bundleManager;
_callableJSModules = callableJSModules;
[self setUp];
}
return self;
}
@@ -122,13 +127,14 @@ int32_t getUniqueId()
callableJSModules:(RCTCallableJSModules *)callableJSModules
{
if (self = [super init]) {
_bridge = bridge;
_instance = instance;
_moduleClass = [instance class];
[self _setUpWithBridge:bridge
moduleRegistry:moduleRegistry
viewRegistry_DEPRECATED:viewRegistry_DEPRECATED
bundleManager:bundleManager
callableJSModules:callableJSModules];
_moduleRegistry = moduleRegistry;
_viewRegistry_DEPRECATED = viewRegistry_DEPRECATED;
_bundleManager = bundleManager;
_callableJSModules = callableJSModules;
[self setUp];
}
return self;
}
@@ -239,10 +239,7 @@ NSString *RCTMD5Hash(NSString *string)
{
const char *str = string.UTF8String;
unsigned char result[CC_MD5_DIGEST_LENGTH];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CC_MD5(str, (CC_LONG)strlen(str), result);
#pragma clang diagnostic pop
return [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0],
@@ -39,13 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDuration;
@property (nonatomic, assign) CGSize minimumSize;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_UNAVAILABLE;
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface NS_DESIGNATED_INITIALIZER;
- (void)cancelTouches;
@@ -53,8 +53,11 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
{
return [super initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
if (self = [super initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact]) {
[surface start];
}
return self;
}
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
@@ -128,10 +128,7 @@ static BOOL RCTIsIPhoneNotched()
RCTAssertMainQueue();
// 20pt is the top safeArea value in non-notched devices
UIWindow *keyWindow = RCTKeyWindow();
if (keyWindow) {
isIPhoneNotched = keyWindow.safeAreaInsets.top > 20;
}
isIPhoneNotched = RCTSharedApplication().keyWindow.safeAreaInsets.top > 20;
});
#endif
@@ -11,6 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
@protocol RCTExceptionsManagerDelegate <NSObject>
- (void)handleSoftJSExceptionWithMessage:(nullable NSString *)message
stack:(nullable NSArray *)stack
exceptionId:(NSNumber *)exceptionId
@@ -19,6 +20,12 @@ NS_ASSUME_NONNULL_BEGIN
stack:(nullable NSArray *)stack
exceptionId:(NSNumber *)exceptionId
extraDataAsJSON:(nullable NSString *)extraDataAsJSON;
@optional
- (void)updateJSExceptionWithMessage:(nullable NSString *)message
stack:(nullable NSArray *)stack
exceptionId:(NSNumber *)exceptionId;
@end
@interface RCTExceptionsManager : NSObject <RCTBridgeModule>
@@ -34,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)reportJsException:(nullable NSString *)message
stack:(nullable NSArray<NSDictionary *> *)stack
exceptionId:(double)exceptionId
isFatal:(bool)isFatal __attribute__((deprecated));
isFatal:(bool)isFatal;
@property (nonatomic, weak) id<RCTExceptionsManagerDelegate> delegate;
@@ -99,6 +99,27 @@ RCT_EXPORT_METHOD(reportFatalException
[self reportFatal:message stack:stack exceptionId:exceptionId extraDataAsJSON:nil];
}
RCT_EXPORT_METHOD(updateExceptionMessage
: (NSString *)message stack
: (NSArray<NSDictionary *> *)stack exceptionId
: (double)exceptionId)
{
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}
if (_delegate && [_delegate respondsToSelector:@selector(updateJSExceptionWithMessage:stack:exceptionId:)]) {
[_delegate updateJSExceptionWithMessage:message stack:stack exceptionId:[NSNumber numberWithDouble:exceptionId]];
}
}
// Deprecated. Use reportFatalException directly instead.
RCT_EXPORT_METHOD(reportUnhandledException : (NSString *)message stack : (NSArray<NSDictionary *> *)stack)
{
[self reportFatalException:message stack:stack exceptionId:-1];
}
RCT_EXPORT_METHOD(dismissRedbox) {}
RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData &)data)
@@ -371,8 +371,7 @@ struct RCTInstanceCallback : public InstanceCallback {
// in case if some other tread resets it.
auto reactInstance = _reactInstance;
if (reactInstance) {
// Memory Pressure Unloading Level 15 represents TRIM_MEMORY_RUNNING_CRITICAL.
int unloadLevel = 15;
int unloadLevel = RCTGetMemoryPressureUnloadLevel();
reactInstance->handleMemoryPressure(unloadLevel);
}
}
@@ -14,8 +14,8 @@ namespace facebook::react {
AppleEventBeat::AppleEventBeat(
std::shared_ptr<OwnerBox> ownerBox,
std::unique_ptr<const RunLoopObserver> uiRunLoopObserver,
RuntimeScheduler& runtimeScheduler)
: EventBeat(std::move(ownerBox), runtimeScheduler),
RuntimeExecutor runtimeExecutor)
: EventBeat(std::move(ownerBox), std::move(runtimeExecutor)),
uiRunLoopObserver_(std::move(uiRunLoopObserver)) {
uiRunLoopObserver_->setDelegate(this);
uiRunLoopObserver_->enable();
@@ -13,8 +13,6 @@
namespace facebook::react {
class RuntimeScheduler;
/*
* Event beat associated with JavaScript runtime.
* The beat is called on `RuntimeExecutor`'s thread induced by the UI thread
@@ -25,7 +23,7 @@ class AppleEventBeat : public EventBeat, public RunLoopObserver::Delegate {
AppleEventBeat(
std::shared_ptr<OwnerBox> ownerBox,
std::unique_ptr<const RunLoopObserver> uiRunLoopObserver,
RuntimeScheduler& RuntimeScheduler);
RuntimeExecutor runtimeExecutor);
#pragma mark - RunLoopObserver::Delegate
@@ -16,6 +16,7 @@
#import <react/renderer/components/image/ImageProps.h>
#import <react/renderer/imagemanager/ImageRequest.h>
#import <react/renderer/imagemanager/RCTImagePrimitivesConversions.h>
#import <react/utils/CoreFeatures.h>
using namespace facebook::react;
@@ -100,6 +101,13 @@ using namespace facebook::react;
const auto &imageRequest = _state->getData().getImageRequest();
auto &observerCoordinator = imageRequest.getObserverCoordinator();
observerCoordinator.removeObserver(_imageResponseObserverProxy);
// Cancelling image request because we are no longer observing it.
// This is not 100% correct place to do this because we may want to
// re-create RCTImageComponentView with the same image and if it
// was cancelled before downloaded, download is not resumed.
// This will only become issue if we decouple life cycle of a
// ShadowNode from ComponentView, which is not something we do now.
imageRequest.cancel();
}
_state = state;
@@ -38,9 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
@property (nonatomic, assign) CGRect firstResponderFocus;
/** newly-activated text input outside of the scroll view */
@property (nonatomic, weak) UIView *firstResponderViewOutsideScrollView;
/*
* Returns the subview of the scroll view that the component uses to mount all subcomponents into. That's useful to
* separate component views from auxiliary views to be able to reliably implement pull-to-refresh- and RTL-related
@@ -182,7 +182,6 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInt
UIViewAnimationCurve curve =
(UIViewAnimationCurve)[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue];
CGRect keyboardEndFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect keyboardBeginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGPoint absoluteViewOrigin = [self convertPoint:self.bounds.origin toView:nil];
CGFloat scrollViewLowerY = isInverted ? absoluteViewOrigin.y : absoluteViewOrigin.y + self.bounds.size.height;
@@ -204,24 +203,21 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInt
from:self
forEvent:nil]) {
if (CGRectEqualToRect(_firstResponderFocus, CGRectNull)) {
UIView *inputAccessoryView = _firstResponderViewOutsideScrollView.inputAccessoryView;
if (inputAccessoryView) {
// Text input view is within the inputAccessoryView.
contentDiff = keyboardEndFrame.origin.y - keyboardBeginFrame.origin.y;
}
} else {
CGRect viewIntersection = CGRectIntersection(self.firstResponderFocus, keyboardEndFrame);
// Text input view is outside of the scroll view.
return;
}
if (CGRectIsNull(viewIntersection)) {
return;
}
CGRect viewIntersection = CGRectIntersection(self.firstResponderFocus, keyboardEndFrame);
// Inner text field focused
CGFloat focusEnd = CGRectGetMaxY(self.firstResponderFocus);
if (focusEnd > keyboardEndFrame.origin.y) {
// Text field active region is below visible area with keyboard - update diff to bring into view
contentDiff = keyboardEndFrame.origin.y - focusEnd;
}
if (CGRectIsNull(viewIntersection)) {
return;
}
// Inner text field focused
CGFloat focusEnd = CGRectGetMaxY(self.firstResponderFocus);
if (focusEnd > keyboardEndFrame.origin.y) {
// Text field active region is below visible area with keyboard - update diff to bring into view
contentDiff = keyboardEndFrame.origin.y - focusEnd;
}
}
@@ -78,7 +78,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
const auto &defaultProps = TextInputShadowNode::defaultSharedProps();
_props = defaultProps;
_backedTextInputView = defaultProps->multiline ? [RCTUITextView new] : [RCTUITextField new];
_backedTextInputView = defaultProps->traits.multiline ? [RCTUITextView new] : [RCTUITextField new];
_backedTextInputView.textInputDelegate = self;
_ignoreNextTextInputCall = NO;
_comingFromJS = NO;
@@ -126,7 +126,6 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
{
if (![self isDescendantOfView:scrollView.scrollView] || !_backedTextInputView.isFirstResponder) {
// View is outside scroll view or it's not a first responder.
scrollView.firstResponderViewOutsideScrollView = _backedTextInputView;
return;
}
@@ -167,8 +166,8 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
const auto &newTextInputProps = static_cast<const TextInputProps &>(*props);
// Traits:
if (newTextInputProps.multiline != oldTextInputProps.multiline) {
[self _setMultiline:newTextInputProps.multiline];
if (newTextInputProps.traits.multiline != oldTextInputProps.traits.multiline) {
[self _setMultiline:newTextInputProps.traits.multiline];
}
if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) {
@@ -449,7 +448,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
return;
}
const auto &props = static_cast<const TextInputProps &>(*_props);
if (props.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
[self textInputDidChange];
_ignoreNextTextInputCall = YES;
}
@@ -786,7 +785,14 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
- (SubmitBehavior)getSubmitBehavior
{
const auto &props = static_cast<const TextInputProps &>(*_props);
return props.getNonDefaultSubmitBehavior();
const SubmitBehavior submitBehaviorDefaultable = props.traits.submitBehavior;
// We should always have a non-default `submitBehavior`, but in case we don't, set it based on multiline.
if (submitBehaviorDefaultable == SubmitBehavior::Default) {
return props.traits.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit;
}
return submitBehaviorDefaultable;
}
@end
@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
* Schedule a mounting transaction to be performed on the main thread.
* Can be called from any thread.
*/
- (void)scheduleTransaction:(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;
- (void)scheduleTransaction:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
/**
* Dispatch a command to be performed on the main thread.
@@ -20,6 +20,7 @@
#import <react/renderer/core/LayoutableShadowNode.h>
#import <react/renderer/core/RawProps.h>
#import <react/renderer/mounting/TelemetryController.h>
#import <react/utils/CoreFeatures.h>
#import <React/RCTComponentViewProtocol.h>
#import <React/RCTComponentViewRegistry.h>
@@ -186,7 +187,7 @@ static void RCTPerformMountInstructions(
componentViewDescriptor:rootViewDescriptor];
}
- (void)scheduleTransaction:(std::shared_ptr<const MountingCoordinator>)mountingCoordinator
- (void)scheduleTransaction:(MountingCoordinator::Shared)mountingCoordinator
{
if (RCTIsMainQueue()) {
// Already on the proper thread, so:
@@ -26,10 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@protocol RCTSchedulerDelegate
- (void)schedulerDidFinishTransaction:(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;
- (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
- (void)schedulerShouldRenderTransactions:
(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;
- (void)schedulerShouldRenderTransactions:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
- (void)schedulerDidDispatchCommand:(const facebook::react::ShadowView &)shadowView
commandName:(const std::string &)commandName
@@ -26,13 +26,13 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
public:
SchedulerDelegateProxy(void *scheduler) : scheduler_(scheduler) {}
void schedulerDidFinishTransaction(const std::shared_ptr<const MountingCoordinator> &mountingCoordinator) override
void schedulerDidFinishTransaction(const MountingCoordinator::Shared &mountingCoordinator) override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidFinishTransaction:mountingCoordinator];
}
void schedulerShouldRenderTransactions(const std::shared_ptr<const MountingCoordinator> &mountingCoordinator) override
void schedulerShouldRenderTransactions(const MountingCoordinator::Shared &mountingCoordinator) override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerShouldRenderTransactions:mountingCoordinator];
@@ -114,6 +114,9 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi
- (instancetype)initWithToolbox:(SchedulerToolbox)toolbox
{
if (self = [super init]) {
auto reactNativeConfig =
toolbox.contextContainer->at<std::shared_ptr<const ReactNativeConfig>>("ReactNativeConfig");
_delegateProxy = std::make_unique<SchedulerDelegateProxy>((__bridge void *)self);
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS()) {

Some files were not shown because too many files have changed in this diff Show More