diff --git a/.buckconfig b/.buckconfig index 07ec813646f170..272ffbbe1221a5 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,6 +1,10 @@ [android] - target = android-30 + target = android-31 + +[kotlin] + compile_against_abis = True + kotlin_version = 1.6.10 [download] max_number_of_retries = 3 diff --git a/.circleci/Dockerfiles/Dockerfile.android b/.circleci/Dockerfiles/Dockerfile.android index 822d7df3d2983a..8d0e28803a5fc8 100644 --- a/.circleci/Dockerfiles/Dockerfile.android +++ b/.circleci/Dockerfiles/Dockerfile.android @@ -14,7 +14,7 @@ # and build a Android application that can be used to run the # tests specified in the scripts/ directory. # -FROM reactnativecommunity/react-native-android:5.1 +FROM reactnativecommunity/react-native-android:5.4 LABEL Description="React Native Android Test Image" LABEL maintainer="Héctor Ramos " @@ -22,6 +22,7 @@ LABEL maintainer="Héctor Ramos " # set default environment variables ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\"" ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" +ENV KOTLIN_HOME="third-party/kotlin" ADD .buckconfig /app/.buckconfig ADD .buckjavaargs /app/.buckjavaargs @@ -33,9 +34,12 @@ ADD React /app/React ADD keystores /app/keystores ADD packages/react-native-codegen /app/packages/react-native-codegen ADD tools /app/tools +add scripts /app/scripts WORKDIR /app +RUN scripts/download-kotlin-compiler-with-buck.sh + RUN buck fetch ReactAndroid/src/test/java/com/facebook/react/modules RUN buck fetch ReactAndroid/src/main/java/com/facebook/react RUN buck fetch ReactAndroid/src/main/java/com/facebook/react/shell @@ -49,6 +53,4 @@ ADD . /app RUN yarn -RUN ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog - -RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 +RUN ./gradlew :ReactAndroid:assembleDebug diff --git a/.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js b/.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js index 06a9c2a45e75f2..f34e8d30eb4647 100644 --- a/.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js +++ b/.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh b/.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh index b6a2427324e7d2..64f0ee465642ab 100644 --- a/.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh +++ b/.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh b/.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh index c7886e5ed18baa..93a38f46318fef 100644 --- a/.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh +++ b/.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/.circleci/Dockerfiles/scripts/run-ci-e2e-tests.sh b/.circleci/Dockerfiles/scripts/run-ci-e2e-tests.sh index 3176638424e7e0..07a8779f60c46f 100755 --- a/.circleci/Dockerfiles/scripts/run-ci-e2e-tests.sh +++ b/.circleci/Dockerfiles/scripts/run-ci-e2e-tests.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh b/.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh index 1c6396f5601b96..d095b972a42787 100755 --- a/.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh +++ b/.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/.circleci/config.yml b/.circleci/config.yml index 03108bff69efd5..fee64be10324af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,17 +8,71 @@ orbs: win: circleci/windows@2.4.0 # ------------------------- -# DEFAULTS +# REFERENCES # ------------------------- -defaults: &defaults - working_directory: ~/react-native - environment: - - GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1 - # The public github tokens are publicly visible by design - - PUBLIC_PULLBOT_GITHUB_TOKEN_A: &github_pullbot_token_a "a6edf8e8d40ce4e8b11a" - - PUBLIC_PULLBOT_GITHUB_TOKEN_B: &github_pullbot_token_b "150e1341f4dd9c944d2a" - - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: &github_analysisbot_token_a "312d354b5c36f082cfe9" - - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: &github_analysisbot_token_b "07973d757026bdd9f196" +references: + defaults: &defaults + working_directory: ~/react-native + environment: + - GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1 + # The public github tokens are publicly visible by design + - PUBLIC_PULLBOT_GITHUB_TOKEN_A: &github_pullbot_token_a "a6edf8e8d40ce4e8b11a" + - PUBLIC_PULLBOT_GITHUB_TOKEN_B: &github_pullbot_token_b "150e1341f4dd9c944d2a" + - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: &github_analysisbot_token_a "312d354b5c36f082cfe9" + - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: &github_analysisbot_token_b "07973d757026bdd9f196" + # Homebrew currently breaks while updating: + # https://discuss.circleci.com/t/brew-install-fails-while-updating/32992 + - HOMEBREW_NO_AUTO_UPDATE: 1 + + hermes_workspace_root: &hermes_workspace_root + /tmp/hermes + attach_hermes_workspace: &attach_hermes_workspace + attach_workspace: + at: *hermes_workspace_root + + # ------------------------- + # Dependency Anchors + # ------------------------- + dependency_versions: + # The Xcode version used on CircleCI OSS tests must be kept in sync with + # the Xcode version used on Sandcastle OSS tests. See _XCODE_VERSION in + # tools/utd/migrated_nbtd_jobs/react_native_oss.td + xcode_version: &xcode_version "13.3.1" + nodelts_image: &nodelts_image "cimg/node:16.14" + nodeprevlts_image: &nodeprevlts_image "cimg/node:14.19" + + # ------------------------- + # Cache Key Anchors + # ------------------------- + # Anchors for the cache keys + + cache_keys: + buck_cache_key: &buck_cache_key v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} + checkout_cache_key: &checkout_cache_key v1-checkout + gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }} + gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }} + hermes_cache_key: &hermes_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }} + hermes_sdk_cache_key: &hermes_sdk_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "sdks/.hermes-cache-key-file" }} + hermes_windows_cache_key: &hermes_windows_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }} + pods_cache_key: &pods_cache_key v6-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} + windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} + yarn_cache_key: &yarn_cache_key v5-yarn-cache-{{ .Environment.CIRCLE_JOB }} + + # ------------------------- + # Filters + # ------------------------- + # CircleCI filters are OR-ed, with all branches triggering by default and tags excluded by default + # CircleCI env-vars are only set with the branch OR tag that triggered the job, not both. + + # In this case, CIRCLE_BRANCH is unset, but CIRCLE_TAG is set. + only_release_tags: &only_release_tags + # Both of the following conditions must be included! + # Ignore any commit on any branch by default. + branches: + ignore: /.*/ + # Only act on version tags. + tags: + only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/ # ------------------------- # EXECUTORS @@ -28,16 +82,18 @@ executors: <<: *defaults docker: # Note: Version set separately for Windows builds, see below. - - image: circleci/node:14 + - image: *nodelts_image + resource_class: "xlarge" nodeprevlts: <<: *defaults docker: - - image: circleci/node:12 + - image: *nodeprevlts_image + resource_class: "xlarge" reactnativeandroid: <<: *defaults docker: - - image: reactnativecommunity/react-native-android:5.1 - resource_class: "large" + - image: reactnativecommunity/react-native-android:5.4 + resource_class: "xlarge" environment: - TERM: "dumb" - ADB_INSTALL_TIMEOUT: 10 @@ -51,12 +107,30 @@ executors: reactnativeios: <<: *defaults macos: - xcode: &_XCODE_VERSION "13.0.0" + xcode: *xcode_version + resource_class: macos.x86.medium.gen2 # ------------------------- # COMMANDS # ------------------------- commands: + # Checkout with cache, on machines that are using Docker the cache is ignored + checkout_code_with_cache: + parameters: + checkout_base_cache_key: + default: *checkout_cache_key + type: string + steps: + - restore_cache: + keys: + - << parameters.checkout_base_cache_key >>-{{ .Branch }}-{{ .Revision }} + - << parameters.checkout_base_cache_key >>-{{ .Branch }}- + - << parameters.checkout_base_cache_key >> + - checkout + - save_cache: + key: << parameters.checkout_base_cache_key >>-{{ .Branch }}-{{ .Revision }} + paths: + - ".git" setup_artifacts: steps: @@ -67,18 +141,29 @@ commands: setup_ruby: steps: - restore_cache: - key: 1-gems-{{ checksum "Gemfile.lock" }} - - run: bundle check || bundle install --path vendor/bundle --clean + key: *gems_cache_key + - run: + name: Bundle Install + command: | + source /usr/local/share/chruby/auto.sh + bundle check || bundle install --path vendor/bundle --clean - save_cache: - key: 1-gems-{{ checksum "Gemfile.lock" }} + key: *gems_cache_key paths: - vendor/bundle run_yarn: + parameters: + yarn_base_cache_key: + default: *yarn_cache_key + type: string + steps: - restore_cache: keys: - - v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} + - << parameters.yarn_base_cache_key >>-{{ arch }}-{{ checksum "yarn.lock" }} + - << parameters.yarn_base_cache_key >>-{{ arch }} + - << parameters.yarn_base_cache_key >> - run: name: "Yarn: Install Dependencies" command: | @@ -90,19 +175,13 @@ commands: - save_cache: paths: - ~/.cache/yarn - key: v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} - - build_codegen: - steps: - - run: - name: "Codegen: Build react-native-codegen package" - command: cd packages/react-native-codegen && yarn build + key: << parameters.yarn_base_cache_key >>-{{ arch }}-{{ checksum "yarn.lock" }} install_buck_tooling: steps: - restore_cache: keys: - - v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} + - *buck_cache_key - run: name: Install BUCK command: | @@ -115,7 +194,7 @@ commands: paths: - ~/buck - ~/okbuck - key: v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }} + key: *buck_cache_key install_github_bot_deps: steps: @@ -131,22 +210,7 @@ commands: steps: - run: name: "Brew: Install << parameters.package >>" - command: HOMEBREW_NO_AUTO_UPDATE=1 brew install << parameters.package >> >/dev/null - - with_brew_cache_span: - parameters: - steps: - type: steps - steps: - - restore_cache: - keys: - - v4-brew - - steps: << parameters.steps >> - - save_cache: - paths: - - /usr/local/Homebrew - - ~/Library/Caches/Homebrew - key: v4-brew + command: brew install << parameters.package >> >/dev/null with_rntester_pods_cache_span: parameters: @@ -159,29 +223,29 @@ commands: command: cp packages/rn-tester/Podfile.lock packages/rn-tester/Podfile.lock.bak - restore_cache: keys: - # The committed lockfile is generated using USE_FRAMEWORKS=0 and USE_HERMES=0 so it could load an outdated cache if a change + # The committed lockfile is generated using USE_FRAMEWORKS=0 and USE_HERMES=1 so it could load an outdated cache if a change # only affects the frameworks or hermes config. To help prevent this also cache based on the content of Podfile. - - v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} + - *pods_cache_key - steps: << parameters.steps >> - save_cache: paths: - packages/rn-tester/Pods - key: v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} + key: *pods_cache_key download_gradle_dependencies: steps: - restore_cache: keys: - - v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }} + - *gradle_cache_key - run: name: Download Dependencies Using Gradle - command: ./scripts/circleci/gradle_download_deps.sh + command: ./gradlew downloadAll - save_cache: paths: - ~/.gradle - ReactAndroid/build/downloads - ReactAndroid/build/third-party-ndk - key: v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }} + key: *gradle_cache_key download_buck_dependencies: steps: @@ -217,6 +281,28 @@ commands: name: Report size of RNTester.app (analysis-bot) command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh << parameters.platform >> || true + with_hermes_sdk_cache_span: + parameters: + steps: + type: steps + steps: + - run: + name: Setup Hermes cache + command: | + HERMES_CACHE_KEY_FILE="sdks/.hermes-cache-key-file" + if [ ! -f "$HERMES_CACHE_KEY_FILE" ]; then + git ls-remote https://github.com/facebook/hermes main | cut -f 1 > $HERMES_CACHE_KEY_FILE + fi + - restore_cache: + keys: + - *hermes_sdk_cache_key + - steps: << parameters.steps >> + - save_cache: + key: *hermes_sdk_cache_key + paths: + - sdks/hermesc + - sdks/hermes + # ------------------------- # JOBS # ------------------------- @@ -242,7 +328,7 @@ jobs: command: | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - apt update && apt install -y shellcheck jq - apt-get install openssl ca-certificates + apt-get -y install openssl ca-certificates update-ca-certificates curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - apt update && apt install -y shellcheck jq @@ -252,13 +338,6 @@ jobs: command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" yarn lint-ci when: always - - run: - name: Analyze Pull Request (pull-bot) - command: | - cd bots - DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks - when: always - # ------------------------- # JOBS: Analyze Code # ------------------------- @@ -322,7 +401,7 @@ jobs: - run_yarn - run: name: Install rsync - command: sudo apt-get install rsync + command: sudo apt update && sudo apt install rsync # ------------------------- # Run JavaScript tests @@ -343,7 +422,7 @@ jobs: path: ./reports/junit # ------------------------- - # JOBS: Test iOS + # JOBS: iOS Unit Tests # ------------------------- test_ios: executor: reactnativeios @@ -351,17 +430,10 @@ jobs: use_frameworks: type: boolean default: false - use_hermes: - type: boolean - default: false run_unit_tests: description: Specifies whether unit tests should run. type: boolean default: false - run_detox_tests: - description: Specifies whether Detox e2e tests should run. - type: boolean - default: false run_disabled_tests: description: Specifies whether disabled tests should run. Set this to true to debug failing tests. type: boolean @@ -369,12 +441,15 @@ jobs: environment: - REPORTS_DIR: "./reports/junit" steps: - - checkout + - checkout_code_with_cache - setup_artifacts - setup_ruby + - run: + name: Run Ruby Tests + command: | + cd scripts + sh run_ruby_tests.sh - run_yarn - - build_codegen - - run: | cd packages/rn-tester bundle check || bundle install @@ -385,24 +460,14 @@ jobs: - run: name: Configure Environment Variables command: | - echo 'export PATH=/usr/local/opt/node@14/bin:$PATH' >> $BASH_ENV + echo 'export PATH=/usr/local/opt/node@16/bin:$PATH' >> $BASH_ENV source $BASH_ENV - - with_brew_cache_span: - steps: - - brew_install: - package: watchman - - run: - name: "Brew: Tap wix/brew" - command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null - - brew_install: - package: applesimutils - - run: - name: Configure Node - # Sourcing find-node.sh will ensure nvm is set up. - # It also helps future invocation of find-node.sh prevent permission issue with nvm.sh. - command: source scripts/find-node.sh && nvm install 14 && nvm alias default 14 + name: "Brew: Tap wix/brew" + command: brew tap wix/brew >/dev/null + - brew_install: + package: applesimutils watchman cmake - run: name: Configure Watchman @@ -415,22 +480,25 @@ jobs: name: Set USE_FRAMEWORKS=1 command: echo "export USE_FRAMEWORKS=1" >> $BASH_ENV - - when: - condition: << parameters.use_hermes >> - steps: - - run: - name: Set USE_HERMES=1 - command: echo "export USE_HERMES=1" >> $BASH_ENV + - run: + name: Set USE_HERMES=1 + command: echo "export USE_HERMES=1" >> $BASH_ENV + + - run: + name: Set BUILD_HERMES_SOURCE=1 + command: echo "export BUILD_HERMES_SOURCE=1" >> $BASH_ENV - run: name: Setup the CocoaPods environment command: bundle exec pod setup - - with_rntester_pods_cache_span: + - with_hermes_sdk_cache_span: steps: - - run: - name: Generate RNTesterPods Workspace - command: cd packages/rn-tester && bundle exec pod install --verbose + - with_rntester_pods_cache_span: + steps: + - run: + name: Generate RNTesterPods Workspace + command: cd packages/rn-tester && bundle exec pod install --verbose # ------------------------- # Runs iOS unit tests @@ -440,13 +508,6 @@ jobs: - run: name: "Run Tests: iOS Unit and Integration Tests" command: yarn test-ios - # Runs iOS Detox e2e tests - - when: - condition: << parameters.run_detox_tests >> - steps: - - run: - name: "Run Tests: Detox iOS End-to-End Tests" - command: yarn run build-ios-e2e && yarn run test-ios-e2e # Optionally, run disabled tests - when: @@ -482,6 +543,8 @@ jobs: run_disabled_tests: type: boolean default: false + environment: + KOTLIN_HOME=third-party/kotlin steps: - checkout - setup_artifacts @@ -514,15 +577,24 @@ jobs: # Build and compile - run: - name: Build Android App + name: Build & Test React Native using Buck command: | buck build ReactAndroid/src/main/java/com/facebook/react buck build ReactAndroid/src/main/java/com/facebook/react/shell + + - run: + name: Build & Test React Native using Gradle + command: ./gradlew buildAll + - run: name: Compile Native Libs for Unit and Integration Tests command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS no_output_timeout: 30m + - run: + name: Build RN Tester for Release using Gradle + command: ./gradlew packages:rn-tester:android:app:assembleRelease + # Build JavaScript Bundle for instrumentation tests - run: name: Build JavaScript Bundle @@ -533,17 +605,13 @@ jobs: name: Wait for Android Virtual Device command: source scripts/android-setup.sh && waitForAVD - - run: - name: Assemble RNTester App - command: ./gradlew packages:rn-tester:android:app:assembleRelease - # ------------------------- # Run Android tests - run: - name: "Run Tests: Android Unit Tests" + name: Run Tests - Android Unit Tests with Buck command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ./reports/buck/all-results-raw.xml - run: - name: "Build Tests: Android Instrumentation Tests" + name: Build Tests - Android Instrumentation Tests with Buck # Here, just build the instrumentation tests. There is a known issue with installing the APK to android-21+ emulator. command: | if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then @@ -585,19 +653,18 @@ jobs: steps: - checkout - run_yarn + - attach_workspace: + at: . - run: - name: Setup the Android Template + name: Create Android template project command: | + REPO_ROOT=$(pwd) + PACKAGE=$(cat build/react-native-package-version) + PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE" cd template - sed -i 's/1000\.0\.0/file\:\.\./g' package.json + npm add $PATH_TO_PACKAGE npm install - # react-native-community/cli is needed as the Android template is referencing a .gradle file inside it. - npm i @react-native-community/cli - - - run: - name: Bundle the latest version of ReactAndroid - command: ./gradlew :ReactAndroid:publishReleasePublicationToNpmRepository - run: name: Build the template application @@ -610,13 +677,21 @@ jobs: executor: reactnativeios environment: - PROJECT_NAME: "iOSTemplateProject" + - HERMES_WS_DIR: *hermes_workspace_root steps: - - checkout + - checkout_code_with_cache - run_yarn - attach_workspace: at: . - + - *attach_hermes_workspace + - run: + name: Set USE_HERMES=1 + command: echo "export USE_HERMES=1" >> $BASH_ENV + - run: + name: Set HERMES_ENGINE_TARBALL_PATH + command: | + echo "export HERMES_ENGINE_TARBALL_PATH=$(ls -AU $HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-*.tar.gz | head -1)" >> $BASH_ENV - run: name: Create iOS template project command: | @@ -626,8 +701,7 @@ jobs: node ./scripts/set-rn-template-version.js "file:$PATH_TO_PACKAGE" mkdir -p ~/tmp cd ~/tmp - node "$REPO_ROOT/cli.js" init "$PROJECT_NAME" --template "$REPO_ROOT" - + node "$REPO_ROOT/cli.js" init "$PROJECT_NAME" --template "$REPO_ROOT" --verbose - run: name: Build template project command: | @@ -636,6 +710,50 @@ jobs: -scheme $PROJECT_NAME \ -sdk iphonesimulator + # ------------------------- + # JOBS: Test iOS RNTester + # ------------------------- + test_ios_rntester: + executor: reactnativeios + steps: + - checkout_code_with_cache + - run_yarn + + # The macOS machine can run out of storage if Hermes is enabled and built from source. + # Since this job does not use the iOS Simulator, deleting it provides a quick way to + # free up space. + - run: + name: Delete iOS Simulators + background: true + command: sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/ + + - run: + name: Set USE_HERMES=1 + command: echo "export USE_HERMES=1" >> $BASH_ENV + + - run: + name: Set BUILD_HERMES_SOURCE=1 + command: echo "export BUILD_HERMES_SOURCE=1" >> $BASH_ENV + + - brew_install: + package: cmake + + - with_hermes_sdk_cache_span: + steps: + - run: + name: Install CocoaPods dependencies + command: | + rm -rf packages/rn-tester/Pods + cd packages/rn-tester && bundle exec pod install + + - run: + name: Build RNTester + command: | + xcodebuild build \ + -workspace packages/rn-tester/RNTesterPods.xcworkspace \ + -scheme RNTester \ + -sdk iphonesimulator + # ------------------------- # JOBS: Windows # ------------------------- @@ -649,19 +767,18 @@ jobs: environment: - ANDROID_HOME: "C:\\Android\\android-sdk" - ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944" - - ANDROID_BUILD_VERSION: 30 - - ANDROID_TOOLS_VERSION: 30.0.2 + - ANDROID_BUILD_VERSION: 31 + - ANDROID_TOOLS_VERSION: 31.0.0 - GRADLE_OPTS: -Dorg.gradle.daemon=false - - NDK_VERSION: 21.4.7075529 steps: - - checkout + - checkout_code_with_cache - run: name: Install Node # Note: Version set separately for non-Windows builds, see above. command: | - nvm install 14.17.0 - nvm use 14.17.0 + nvm install 16 + nvm use 16 # Setup Dependencies - run: @@ -674,12 +791,12 @@ jobs: - restore_cache: keys: - - v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} + - *windows_yarn_cache_key - run: name: "Yarn: Install Dependencies" command: yarn install --frozen-lockfile --non-interactive - save_cache: - key: v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} + key: *windows_yarn_cache_key paths: - C:\Users\circleci\AppData\Local\Yarn @@ -698,7 +815,6 @@ jobs: sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%" sdkmanager "add-ons;addon-google_apis-google-23" sdkmanager "extras;android;m2repository" - sdkmanager "ndk;%NDK_VERSION%" # ------------------------- # Run Tests @@ -746,15 +862,270 @@ jobs: - store_artifacts: path: ~/react-native/coverage/ + # ------------------------- + # JOBS: Build hermesc + # ------------------------- + prepare_hermes_workspace: + docker: + - image: debian:bullseye + environment: + - HERMES_WS_DIR: *hermes_workspace_root + - HERMES_VERSION_FILE: "sdks/.hermesversion" + steps: + - run: + name: Install dependencies + command: | + apt update + apt install -y wget git curl + curl -sL https://deb.nodesource.com/setup_16.x | bash - + apt install -y nodejs + npm install --global yarn + - checkout + - run_yarn + - run: + name: Set up Hermes workspace and caching + command: | + mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes" + + if [ -f "$HERMES_VERSION_FILE" ]; then + cat $HERMES_VERSION_FILE > /tmp/hermes/hermesversion + else + HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]') + echo $HERMES_TAG_SHA > /tmp/hermes/hermesversion + fi + - restore_cache: + key: *hermes_cache_key + - run: + name: Download Hermes tarball + command: | + node scripts/hermes/prepare-hermes-for-build + cp sdks/download/* $HERMES_WS_DIR/download/. + cp -r sdks/hermes/* $HERMES_WS_DIR/hermes/. + - save_cache: + key: *hermes_cache_key + paths: + - /tmp/hermes/download/ + - /tmp/hermes/hermes/ + - persist_to_workspace: + root: *hermes_workspace_root + paths: + - download + - hermes + - hermesversion + + build_hermesc_linux: + docker: + - image: debian:bullseye + resource_class: "xlarge" + working_directory: /root + steps: + - run: + name: Install dependencies + command: | + apt update + apt install -y git openssh-client cmake build-essential \ + libreadline-dev libicu-dev zip python3 + - *attach_hermes_workspace + - restore_cache: + key: *hermes_cache_key + - run: + name: Set up workspace + command: | + mkdir -p /tmp/hermes/linux64-bin + - run: + name: Build HermesC for Linux + command: | + if [ -f /tmp/hermes/linux64-bin/hermesc ]; then + echo 'Skipping; Clean "/tmp/hermes/linux64-bin" to rebuild.' + else + cd /tmp/hermes + cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \ + -DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" + cmake --build build --target check-hermes -j 4 + cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/. + fi + - save_cache: + key: *hermes_cache_key + paths: + - /tmp/hermes/linux64-bin/ + - /tmp/hermes/hermes/destroot/ + - store_artifacts: + path: /tmp/hermes/linux64-bin/ + - persist_to_workspace: + root: /tmp/hermes/ + paths: + - linux64-bin + + build_hermes_macos: + executor: reactnativeios + environment: + - HERMES_WS_DIR: *hermes_workspace_root + steps: + - checkout_code_with_cache + - *attach_hermes_workspace + - restore_cache: + key: *hermes_cache_key + - run: + name: Set up workspace + command: | + mkdir -p /tmp/hermes/osx-bin + mkdir -p ~/react-native/sdks/hermes + cp -r $HERMES_WS_DIR/hermes/* ~/react-native/sdks/hermes/. + - run: + name: Install dependencies + command: | + brew install cmake + - run: + name: Build the Hermes iOS frameworks + command: | + cd ~/react-native/sdks/hermes + ./utils/build-ios-framework.sh + - run: + name: Build the Hermes Mac frameworks + command: | + cd ~/react-native/sdks/hermes + ./utils/build-mac-framework.sh + cp build_macosx/bin/hermesc /tmp/hermes/osx-bin/. + - run: + name: Package the Hermes Apple frameworks + command: | + cd ~/react-native/sdks/hermes + . ./utils/build-apple-framework.sh + + mkdir -p /tmp/cocoapods-package-root/destroot + mkdir -p /tmp/hermes/output + cp -R ./destroot /tmp/cocoapods-package-root + cp LICENSE /tmp/cocoapods-package-root + + tar -C /tmp/cocoapods-package-root/ -czvf /tmp/hermes/output/hermes-runtime-darwin-v$(get_release_version).tar.gz . + + mkdir -p /tmp/hermes/hermes-runtime-darwin + cp /tmp/hermes/output/hermes-runtime-darwin-v$(get_release_version).tar.gz /tmp/hermes/hermes-runtime-darwin/. + - save_cache: + key: *hermes_cache_key + paths: + - ~/react-native/hermes/build_host_hermesc + - ~/react-native/hermes/build_iphoneos + - ~/react-native/hermes/build_catalyst + - ~/react-native/hermes/build_iphonesimulator + - ~/react-native/hermes/build_macosx + - ~/react-native/hermes/destroot + - store_artifacts: + path: /tmp/hermes/hermes-runtime-darwin/ + - store_artifacts: + path: /tmp/hermes/osx-bin/ + - persist_to_workspace: + root: /tmp/hermes/ + paths: + - hermes-runtime-darwin + - osx-bin + + build_hermesc_windows: + executor: + name: win/default + shell: powershell.exe + environment: + - HERMES_WS_DIR: 'C:\tmp\hermes' + - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" + - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' + - CMAKE_DIR: 'C:\Program Files\CMake\bin' + steps: + - *attach_hermes_workspace + - restore_cache: + key: *hermes_windows_cache_key + - run: + name: Set up workspace + command: | + New-Item -ItemType Directory $Env:HERMES_WS_DIR + New-Item -ItemType Directory $Env:HERMES_WS_DIR\icu + New-Item -ItemType Directory $Env:HERMES_WS_DIR\deps + New-Item -ItemType Directory $Env:HERMES_WS_DIR\win64-bin + New-Item -ItemType SymbolicLink -Target tmp\hermes\hermes -Path $Env:HERMES_WS_DIR -Name hermes + - run: + name: Build HermesC for Windows + command: | + if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) { + choco install --no-progress cmake --version 3.14.7 + if (-not $?) { throw "Failed to install CMake" } + choco install --no-progress python3 + if (-not $?) { throw "Failed to install Python" } + + cd $Env:HERMES_WS_DIR\icu + # If Invoke-WebRequest shows a progress bar, it will fail with + # Win32 internal error "Access is denied" 0x5 occurred [...] + $progressPreference = 'silentlyContinue' + Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip" + Expand-Archive -Path "icu.zip" -DestinationPath "." + + cd $Env:HERMES_WS_DIR + Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps" + # Include MSVC++ 2015 redistributables + Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps" + Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps" + Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps" + + $Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR" + $Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu" + + cmake -S hermes -B build_release -G 'Visual Studio 16 2019' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF + if (-not $?) { throw "Failed to configure Hermes" } + cd build_release + cmake --build . --target hermesc --config Release + if (-not $?) { throw "Failed to build Hermes" } + + cd $Env:HERMES_WS_DIR + Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "win64-bin" + # Include Windows runtime dependencies + Copy-Item -Path "deps\*" -Destination "win64-bin" + } + else { + Write-Host "Skipping; Clean c:\tmp\hermes\win64-bin to rebuild." + } + - save_cache: + key: *hermes_windows_cache_key + paths: + - C:\tmp\hermes\win64-bin\ + - C:\tmp\hermes\hermes\icu\ + - C:\tmp\hermes\hermes\deps\ + - C:\tmp\hermes\hermes\build_release\ + - store_artifacts: + path: C:\tmp\hermes\win64-bin\ + - persist_to_workspace: + root: C:\tmp\hermes\ + paths: + - win64-bin + # ------------------------- # JOBS: Releases # ------------------------- + prepare_package_for_release: + parameters: + version: + type: string + latest: + type: boolean + default: false + executor: reactnativeios + steps: + - checkout_code_with_cache + - run_yarn + - add_ssh_keys: + fingerprints: + - "1c:98:e0:3a:52:79:95:29:12:cd:b4:87:5b:41:e2:bb" + - run: + name: "Set new react-native version and commit changes" + command: | + node ./scripts/prepare-package-for-release.js -v << parameters.version >> -l << parameters.latest >> + build_npm_package: parameters: publish_npm_args: type: string default: --dry-run executor: reactnativeandroid + environment: + - HERMES_WS_DIR: *hermes_workspace_root steps: - run: name: Add github.com to SSH known hosts @@ -762,11 +1133,24 @@ jobs: mkdir -p ~/.ssh echo '|1|If6MU203eXTaaWL678YEfWkVMrw=|kqLeIAyTy8pzpj8x8Ae4Fr8Mtlc= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts - checkout + - *attach_hermes_workspace + - run: + name: Copy HermesC binaries + command: | + mkdir -p ./sdks/hermesc ./sdks/hermesc/osx-bin ./sdks/hermesc/win64-bin ./sdks/hermesc/linux64-bin + cp -r $HERMES_WS_DIR/osx-bin/* ./sdks/hermesc/osx-bin/. + cp -r $HERMES_WS_DIR/win64-bin/* ./sdks/hermesc/win64-bin/. + cp -r $HERMES_WS_DIR/linux64-bin/* ./sdks/hermesc/linux64-bin/. + - run_yarn - install_buck_tooling - download_buck_dependencies - download_gradle_dependencies - # Only tagged releases and nightlies should be able to publish to npm + + # START: Stables and nightlies + # This conditional step sets up the necessary credentials for publishing react-native to npm, + # and for interacting with GitHub as the react-native-bot account. Important: these steps + # should not be allowed to run on commits from pull requests. - when: condition: or: @@ -778,7 +1162,17 @@ jobs: git config --global user.email "react-native-bot@users.noreply.github.com" git config --global user.name "npm Deployment Script" echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc + # END: Stables and nightlies + - run: node ./scripts/publish-npm.js << parameters.publish_npm_args >> + - run: + name: Zip Hermes Native Symbols + command: zip -r /tmp/hermes-native-symbols.zip ~/react-native/ReactAndroid/hermes-engine/build/intermediates/cmake/ + - store_artifacts: + path: /tmp/hermes-native-symbols.zip + + # START: Commitlies + # Provide a react-native package for this commit as a Circle CI release artifact. - when: condition: equal: [ --dry-run, << parameters.publish_npm_args >> ] @@ -797,7 +1191,10 @@ jobs: root: . paths: - build/* + # END: Commitlies + # START: Commits from pull requests + # When building commits from pull requests, leave a comment on the PR with a link to build artifacts - when: condition: matches: { pattern: '^pull\/.*$', value: << pipeline.git.branch >> } @@ -806,7 +1203,9 @@ jobs: - run: name: Post link to PR build artifacts (pull-bot) command: GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh || true + # END: Commits from pull requests + # START: Stable releases - when: condition: equal: [ --release, << parameters.publish_npm_args >> ] @@ -818,6 +1217,15 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ -u "$PAT_USERNAME:$PAT_TOKEN" \ -d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${CIRCLE_TAG:1}\" }}" + - run: + name: Install dependencies + command: apt update && apt install -y jq jo + - run: + name: Create draft GitHub Release and upload Hermes binaries + command: | + ARTIFACTS=("$HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-$CIRCLE_TAG.tar.gz") + ./scripts/circleci/create_github_release.sh $CIRCLE_TAG $CIRCLE_PROJECT_USERNAME $CIRCLE_PROJECT_REPONAME $GITHUB_TOKEN "${ARTIFACTS[@]}" + # END: Stable releases # ------------------------- # JOBS: Nightly @@ -831,124 +1239,131 @@ jobs: command: | echo "Nightly build run" + +# ------------------------- +# PIPELINE PARAMETERS +# ------------------------- +parameters: + run_package_release_workflow_only: + default: false + type: boolean + + release_latest: + default: false + type: boolean + + release_version: + default: "9999" + type: string + # ------------------------- # WORK FLOWS +# +# When creating a new workflow, make sure to include condition `unless: << pipeline.parameters.run_package_release_workflow_only >>` +# It's setup this way so we can trigger a release via a POST +# See limitations: https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2 # ------------------------- workflows: version: 2 tests: + unless: << pipeline.parameters.run_package_release_workflow_only >> jobs: + - prepare_hermes_workspace + - build_hermesc_linux: + requires: + - prepare_hermes_workspace + - build_hermes_macos: + requires: + - prepare_hermes_workspace + - build_hermesc_windows: + requires: + - prepare_hermes_workspace - build_npm_package: # Build a release package on every untagged commit, but do not publish to npm. publish_npm_args: --dry-run - filters: - branches: - only: - - main - - /^pull\/.*$/ - - /^(\d+)\.(\d+)-stable$/ + requires: + - build_hermesc_linux + - build_hermes_macos + - build_hermesc_windows - test_js: run_disabled_tests: false - filters: - branches: - ignore: gh-pages - test_android: run_disabled_tests: false - filters: - branches: - ignore: gh-pages - test_android_template: - filters: - branches: - ignore: gh-pages + requires: + - build_npm_package - test_ios_template: requires: - build_npm_package - filters: - branches: - ignore: gh-pages - - test_ios: - name: test_ios_unit_jsc - run_unit_tests: true - filters: - branches: - ignore: gh-pages - # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper - # - test_ios: - # name: test_ios_unit_frameworks_jsc - # use_frameworks: true - # run_unit_tests: true + - test_ios_rntester - test_ios: - name: test_ios_unit_hermes - use_hermes: true run_unit_tests: true - filters: - branches: - ignore: gh-pages # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper # - test_ios: - # name: test_ios_unit_frameworks_hermes - # use_hermes: true + # name: test_ios_frameworks # use_frameworks: true # run_unit_tests: true - # DISABLED: Detox tests need to be fixed - # - test_ios: - # name: test_ios_detox - # run_detox_tests: true - # DISABLED: USE_FRAMEWORKS=1 not supported by Flipper - # - test_ios: - # name: test_ios_detox_frameworks - # use_frameworks: true - # run_detox_tests: true + # requires: + # - build_ios_frameworks - test_js: name: test_js_prev_lts executor: nodeprevlts - filters: - branches: - ignore: gh-pages - test_windows: - filters: - branches: - ignore: gh-pages run_disabled_tests: false - releases: + # This workflow should only be triggered by release script + package_release: + when: << pipeline.parameters.run_package_release_workflow_only >> jobs: + # This job will trigger publish_release workflow + - prepare_package_for_release: + name: prepare_package_for_release + version: << pipeline.parameters.release_version >> + latest : << pipeline.parameters.release_latest >> + + publish_release: + unless: << pipeline.parameters.run_package_release_workflow_only >> + jobs: + - prepare_hermes_workspace: + filters: *only_release_tags + - build_hermesc_linux: + filters: *only_release_tags + requires: + - prepare_hermes_workspace + - build_hermes_macos: + filters: *only_release_tags + requires: + - prepare_hermes_workspace + - build_hermesc_windows: + filters: *only_release_tags + requires: + - prepare_hermes_workspace + # This job will trigger when a version tag is pushed (by package_release) - build_npm_package: name: build_and_publish_npm_package context: react-native-bot publish_npm_args: --release - filters: - # Both of the following conditions must be included! - # Ignore any commit on any branch by default. - branches: - ignore: /.*/ - # Only act on version tags. - tags: - only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/ + filters: *only_release_tags + requires: + - build_hermesc_linux + - build_hermes_macos + - build_hermesc_windows analysis: + unless: << pipeline.parameters.run_package_release_workflow_only >> jobs: - # Run lints on every commit other than those to the gh-pages branch - - analyze_code: - filters: - branches: - ignore: gh-pages + # Run lints on every commit + - analyze_code - # Run code checks on PRs from forks - - analyze_pr: - filters: - branches: - only: /^pull\/.*$/ + # Run code checks on PRs + - analyze_pr # Gather coverage - - js_coverage: - filters: - branches: - ignore: gh-pages + - js_coverage nightly: + unless: << pipeline.parameters.run_package_release_workflow_only >> triggers: - schedule: cron: "0 20 * * *" @@ -959,5 +1374,19 @@ workflows: jobs: - nightly_job + - prepare_hermes_workspace + - build_hermesc_linux: + requires: + - prepare_hermes_workspace + - build_hermes_macos: + requires: + - prepare_hermes_workspace + - build_hermesc_windows: + requires: + - prepare_hermes_workspace - build_npm_package: publish_npm_args: --nightly + requires: + - build_hermesc_linux + - build_hermes_macos + - build_hermesc_windows diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f990717831deb2..00000000000000 --- a/.eslintrc +++ /dev/null @@ -1,60 +0,0 @@ -{ - "root": true, - - "extends": [ - "./packages/eslint-config-react-native-community/index.js" - ], - - "plugins": [ - "@react-native/eslint-plugin-codegen" - ], - - "overrides": [ - { - "files": [ - "Libraries/**/*.js", - ], - "rules": { - "@react-native-community/no-haste-imports": 2, - "@react-native-community/error-subclass-name": 2, - "@react-native-community/platform-colors": 2, - "@react-native/codegen/react-native-modules": 2 - } - }, - { - "files": [ - "flow-typed/**/*.js", - ], - "rules": { - quotes: 0 - } - }, - { - "files": [ - "**/__fixtures__/**/*.js", - "**/__mocks__/**/*.js", - "**/__tests__/**/*.js", - "jest/**/*.js", - "packages/rn-tester/**/*.js", - ], - "globals": { - // Expose some Jest globals for test helpers - "afterAll": true, - "afterEach": true, - "beforeAll": true, - "beforeEach": true, - "expect": true, - "jest": true, - }, - }, - { - "files": [ - "**/__tests__/**/*-test.js", - ], - "env": { - "jasmine": true, - "jest": true - } - } - ] -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000000000..8c7d0470630a9e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,75 @@ +/** + * 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. + * + * @format + */ + +'use strict'; + +module.exports = { + root: true, + + extends: ['./packages/eslint-config-react-native-community/index.js'], + + plugins: ['@react-native/eslint-plugin-specs'], + + overrides: [ + // overriding the JS config from eslint-config-react-native-community config to ensure + // that we use hermes-eslint for all js files + { + files: ['*.js'], + parser: 'hermes-eslint', + rules: { + // These rules are not required with hermes-eslint + 'ft-flow/define-flow-type': 0, + 'ft-flow/use-flow-type': 0, + // flow handles this check for us, so it's not required + 'no-undef': 0, + }, + }, + + { + files: ['Libraries/**/*.js'], + rules: { + '@react-native-community/no-haste-imports': 2, + '@react-native-community/error-subclass-name': 2, + '@react-native-community/platform-colors': 2, + '@react-native/specs/react-native-modules': 2, + }, + }, + { + files: ['flow-typed/**/*.js'], + rules: { + quotes: 0, + }, + }, + { + files: [ + '**/__fixtures__/**/*.js', + '**/__mocks__/**/*.js', + '**/__tests__/**/*.js', + 'jest/**/*.js', + 'packages/rn-tester/**/*.js', + ], + globals: { + // Expose some Jest globals for test helpers + afterAll: true, + afterEach: true, + beforeAll: true, + beforeEach: true, + expect: true, + jest: true, + }, + }, + { + files: ['**/__tests__/**/*-test.js'], + env: { + jasmine: true, + jest: true, + }, + }, + ], +}; diff --git a/.flowconfig b/.flowconfig index 20b8afa70e2a62..c2d114b4f6769c 100644 --- a/.flowconfig +++ b/.flowconfig @@ -14,6 +14,8 @@ ; Flow doesn't support platforms .*/Libraries/Utilities/LoadingView.js +.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ + [untyped] .*/node_modules/@react-native-community/cli/.*/.* @@ -30,6 +32,7 @@ flow/ emoji=true exact_by_default=true +exact_empty_objects=true format.bracket_spacing=false @@ -49,6 +52,8 @@ suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState suppress_type=$FlowFixMeEmpty +experimental.env_mode=ssa + [lints] sketchy-null-number=warn sketchy-null-mixed=warn @@ -58,7 +63,6 @@ nonstrict-import=warn deprecated-type=error unsafe-getters-setters=warn unnecessary-invariant=warn -signature-verification-failure=warn [strict] deprecated-type @@ -70,4 +74,4 @@ untyped-import untyped-type-import [version] -^0.165.0 +^0.182.0 diff --git a/.flowconfig.android b/.flowconfig.android index a0c22e68f21e10..dc9d12aba7e9a8 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -14,6 +14,8 @@ ; Flow doesn't support platforms .*/Libraries/Utilities/LoadingView.js +.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ + [untyped] .*/node_modules/@react-native-community/cli/.*/.* @@ -30,6 +32,7 @@ flow/ emoji=true exact_by_default=true +exact_empty_objects=true format.bracket_spacing=false @@ -49,6 +52,8 @@ suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState suppress_type=$FlowFixMeEmpty +experimental.env_mode=ssa + [lints] sketchy-null-number=warn sketchy-null-mixed=warn @@ -58,7 +63,6 @@ nonstrict-import=warn deprecated-type=error unsafe-getters-setters=warn unnecessary-invariant=warn -signature-verification-failure=warn [strict] deprecated-type @@ -70,4 +74,4 @@ untyped-import untyped-type-import [version] -^0.165.0 +^0.182.0 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d2c508fc226df9..9c245257bf1eb2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -24,8 +24,8 @@ body: - type: textarea id: react-native-info attributes: - label: Output of `react-native info` - description: Run `react-native info` in your terminal, copy and paste the results here. + label: Output of `npx react-native info` + description: Run `npx react-native info` in your terminal, copy and paste the results here. validations: required: true - type: textarea @@ -43,5 +43,6 @@ body: Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve + Please note that a reproducer is mandatory. Issues without reproducer are more likely to stall and will be closed. validations: - required: false + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c50c3e2a4f2f95..9b140cf8107ee4 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -6,6 +6,9 @@ contact_links: - name: 🤔 Questions and Help url: https://reactnative.dev/help about: Looking for help with your app? Please refer to the React Native community's support resources. + - name: 💫 New Architecture - Questions & Technical Deep dive insights + url: https://github.com/reactwg/react-native-new-architecture + about: Questions and doubts related to technical questions for the New Architecture should be directed to the Working Group. Instructions on how to join are available in the README. - name: 🚀 Discussions and Proposals url: https://github.com/react-native-community/discussions-and-proposals about: Discuss the future of React Native in the React Native community's discussions and proposals repository. diff --git a/.github/ISSUE_TEMPLATE/new_architecture_bug_report.yml b/.github/ISSUE_TEMPLATE/new_architecture_bug_report.yml new file mode 100644 index 00000000000000..8f060dd42de927 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new_architecture_bug_report.yml @@ -0,0 +1,53 @@ +name: 💫 New Architecture - Bug Report +description: Report a reproducible bug or a build issue when using the New Architecture (Fabric & TurboModules) in React Native. +labels: ["Needs: Triage :mag:", "Type: New Architecture"] +body: + - type: markdown + attributes: + value: | + Please provide all the information requested. Issues that do not follow this format are going to be closed. + This issue report is reserved to bug & build issues for users on the New Architecture. If you're not using + the New Architecture, please don't open issues on this category. + - type: textarea + id: description + attributes: + label: Description + description: | + Please provide a clear and concise description of what the bug or issue is. Include screenshots if needed. + Please make sure you check the New Architecture documentation first, as your issue might + already be answered there - https://reactnative.dev/docs/next/new-architecture-intro + validations: + required: true + - type: input + id: version + attributes: + label: Version + description: What react-native version does this appear on? Please test against the latest stable version. Bug reports against older versions are more likely to stall. + placeholder: ex. 0.68.0 + validations: + required: true + - type: textarea + id: react-native-info + attributes: + label: Output of `npx react-native info` + description: Run `npx react-native info` in your terminal, copy and paste the results here. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Steps to reproduce + description: Provide a detailed list of steps that reproduce the issue. + validations: + required: true + - type: textarea + id: extra + attributes: + label: Snack, code example, screenshot, or link to a repository + description: | + Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. + You may provide a screenshot of the application if you think it is relevant to your bug report. + Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve + Please note that a reproducer is mandatory. Issues without reproducer are more likely to stall and will be closed. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/release_blocker_form.yml b/.github/ISSUE_TEMPLATE/release_blocker_form.yml deleted file mode 100644 index b8c35d75e6d3ad..00000000000000 --- a/.github/ISSUE_TEMPLATE/release_blocker_form.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Release Candidate Blocker -description: If you are testing a release candidate (0.XX.0-rc.Y) and run into an issue. -labels: ["Needs: Triage :mag:", "pre-release"] -body: - - type: markdown - attributes: - value: | - Please use this form to file an issue against the current release candidate. See current releases [here](https://github.com/facebook/react-native/releases). - - type: input - id: version - attributes: - label: Version - description: What release candidate version does this appear on? Please refer to [release candidate versions](https://github.com/facebook/react-native/releases). - placeholder: ex. 0.66.0-rc.2 - validations: - required: true - - type: input - id: target - attributes: - label: Build Target(s) - description: What target(s) are encountering this issue? - placeholder: iOS simulator in release flavor - validations: - required: true - - type: textarea - id: react-native-info - attributes: - label: Output of `react-native info` - description: Run `react-native info` in your terminal, copy and paste the results here. - validations: - required: true - - type: textarea - id: reproduction - attributes: - label: Issue and Reproduction Steps - description: Please describe the issue and list out commands run to reproduce. - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/upgrade-regression-form.yml b/.github/ISSUE_TEMPLATE/upgrade-regression-form.yml index 7e4fd8066c747e..51495e4916a373 100644 --- a/.github/ISSUE_TEMPLATE/upgrade-regression-form.yml +++ b/.github/ISSUE_TEMPLATE/upgrade-regression-form.yml @@ -1,5 +1,5 @@ -name: Upgrade Regression -description: If you are upgrading to a stable release and encounter a regression. +name: ⬆️ Upgrade - Build Regression +description: If you are upgrading to a new React Native version (stable or pre-release) and encounter a build regression. labels: ["Needs: Triage :mag:", "Type: Upgrade Issue"] body: - type: markdown diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 073b9af6d242da..4b81ca2408c33d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,7 +7,7 @@ ## Changelog [CATEGORY] [TYPE] - Message diff --git a/.github/RELEASE_TEMPLATE.md b/.github/RELEASE_TEMPLATE.md new file mode 100644 index 00000000000000..302daf94622667 --- /dev/null +++ b/.github/RELEASE_TEMPLATE.md @@ -0,0 +1,23 @@ + + + + +- + +--- + +To test it, run: + +npx react-native init RN__SHORT_VERSION__ --version __VERSION__ + +--- + +You can participate in the conversation on the status of this release in the [working group](https://github.com/reactwg/react-native-releases/discussions). + +--- + +To help you upgrade to this version, you can use the [upgrade helper](https://react-native-community.github.io/upgrade-helper/) ⚛️ + +--- + +See changes from this release in the [changelog PR](https://github.com/facebook/react-native/labels/%F0%9F%93%9D%20Changelog) diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index e0896503e04bac..00000000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 90 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - Good first issue - - "Type: Discussion" - - Partner - - Core Team - - "Help Wanted :octocat:" - - "Impact: Regression" - - "Resolution: PR Submitted" - - "Resolution: Backlog" -# Label to use when marking an issue as stale -staleLabel: Stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. - You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. - Thank you for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: > - Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. -only: issues diff --git a/.github/workflows/apply-version-label-issue.yml b/.github/workflows/apply-version-label-issue.yml index 472f081d65db23..121e280cfcafe6 100644 --- a/.github/workflows/apply-version-label-issue.yml +++ b/.github/workflows/apply-version-label-issue.yml @@ -4,11 +4,18 @@ on: issues: types: [opened, edited] +permissions: + contents: read + jobs: add-version-label-issue: + permissions: + issues: write # for react-native-community/actions-apply-version-label to label issues runs-on: ubuntu-latest + continue-on-error: true steps: - - uses: lucasbento/core-workflow-apply-version-label@v0.0.6 + - uses: react-native-community/actions-apply-version-label@v0.0.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} + required-label: "Type: Upgrade Issue" diff --git a/.github/workflows/create-new-tag-version-label.yml b/.github/workflows/create-new-tag-version-label.yml deleted file mode 100644 index edfcde5b1fdec0..00000000000000 --- a/.github/workflows/create-new-tag-version-label.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Create new tag as version label - -on: - release: - types: - - created - - edited - -jobs: - add-new-tag-version-label: - runs-on: ubuntu-latest - - steps: - - uses: lucasbento/core-workflow-create-version-label@v0.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/danger_pr.yml b/.github/workflows/danger_pr.yml new file mode 100644 index 00000000000000..d3e8072065a891 --- /dev/null +++ b/.github/workflows/danger_pr.yml @@ -0,0 +1,22 @@ +name: Run Danger on PR + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +permissions: + contents: read + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: yarn install + working-directory: bots + - name: Danger + run: DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks --failOnErrors --id danger_pr + working-directory: bots + env: + PUBLIC_PULLBOT_GITHUB_TOKEN_A: a6edf8e8d40ce4e8b11a + PUBLIC_PULLBOT_GITHUB_TOKEN_B: 150e1341f4dd9c944d2a diff --git a/.github/workflows/needs-attention.yml b/.github/workflows/needs-attention.yml index e5c1a979653171..f1ec7e8813475c 100644 --- a/.github/workflows/needs-attention.yml +++ b/.github/workflows/needs-attention.yml @@ -4,12 +4,18 @@ on: issue_comment: types: created +permissions: + contents: read + jobs: applyNeedsAttentionLabel: + permissions: + contents: read # for actions/checkout to fetch code + issues: write # for hramos/needs-attention to label issues name: Apply Needs Attention Label runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Apply Needs Attention Label uses: hramos/needs-attention@v1 with: diff --git a/.github/workflows/on-issue-labeled.yml b/.github/workflows/on-issue-labeled.yml index e68682b2ecb71b..f99404e94fae8a 100644 --- a/.github/workflows/on-issue-labeled.yml +++ b/.github/workflows/on-issue-labeled.yml @@ -4,12 +4,18 @@ on: issues: types: labeled +permissions: + contents: read + jobs: respondToIssueBasedOnLabel: + permissions: + contents: read # for hramos/respond-to-issue-based-on-label to fetch config file + issues: write # for hramos/respond-to-issue-based-on-label to update issues name: Respond to Issue Based on Label runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Respond to Issue Based on Label uses: hramos/respond-to-issue-based-on-label@v2 with: diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml index 2ef7890236e881..326a54eb71e9aa 100644 --- a/.github/workflows/stale-bot.yml +++ b/.github/workflows/stale-bot.yml @@ -9,11 +9,11 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-stale: 365 - stale-issue-message: 'This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.' - stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + days-before-stale: 180 + stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-pr-message: 'This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.' close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' diff --git a/.github/workflows/test-docker-android.yml b/.github/workflows/test-docker-android.yml index 8aec07427d4584..6951e180eb81ce 100644 --- a/.github/workflows/test-docker-android.yml +++ b/.github/workflows/test-docker-android.yml @@ -5,15 +5,22 @@ on: branches: - main pull_request: - types: [ synchronize ] branches: - main +permissions: + contents: read + jobs: test-docker-android: name: Test Docker runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Free up space by removing unnecessary folders + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Build Docker image with Android test app run: npm run docker-build-android diff --git a/.gitignore b/.gitignore index 6d419dcf559721..c954afb75a0f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,10 +20,12 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace +**/.xcode.env.local # Gradle /build/ /packages/react-native-gradle-plugin/build/ +/packages/rn-tester/build /packages/rn-tester/android/app/.cxx/ /packages/rn-tester/android/app/build/ /packages/rn-tester/android/app/gradle/ @@ -34,6 +36,8 @@ project.xcworkspace /ReactAndroid/gradle/ /ReactAndroid/gradlew /ReactAndroid/gradlew.bat +/ReactAndroid/hermes-engine/build/ +/ReactAndroid/hermes-engine/.cxx/ /template/android/app/build/ /template/android/build/ @@ -82,8 +86,6 @@ package-lock.json # ReactCommon subdir shouldn't have Xcode project /ReactCommon/**/*.xcodeproj -/packages/rn-tester/build -/packages/rn-tester/android/app/build/* # Libs that shouldn't have Xcode project /Libraries/FBLazyVector/**/*.xcodeproj @@ -96,7 +98,8 @@ package-lock.json /vendor /template/vendor -# CocoaPods +# iOS / CocoaPods +/template/ios/build/ /template/ios/Pods/ /template/ios/Podfile.lock /packages/rn-tester/Gemfile.lock @@ -111,6 +114,11 @@ package-lock.json /ReactCommon/react/renderer/components/rncore/ /packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec* +# Additional SDKs +/sdks/download +/sdks/hermes +/sdks/hermesc + # Visual studio .vscode .vs diff --git a/.node-version b/.node-version new file mode 100644 index 00000000000000..b6a7d89c68e0ca --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16 diff --git a/.ruby-version b/.ruby-version index a4dd9dba4fbfc5..a603bb50a29e35 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.4 +2.7.5 diff --git a/BUCK b/BUCK index 5650357aa27962..69a9a077041b0b 100644 --- a/BUCK +++ b/BUCK @@ -10,13 +10,13 @@ load( ) load( "//tools/build_defs/oss:rn_defs.bzl", - "APPLETVOS", "HERMES_BYTECODE_VERSION", "IOS", "RCT_IMAGE_DATA_DECODER_SOCKET", "RCT_IMAGE_URL_LOADER_SOCKET", "RCT_URL_REQUEST_HANDLER_SOCKET", "YOGA_CXX_TARGET", + "get_react_native_ios_target_sdk_version", "react_fabric_component_plugin_provider", "react_module_plugin_providers", "react_native_root_target", @@ -35,6 +35,7 @@ RCTCXXBRIDGE_PUBLIC_HEADERS = { "JSCExecutorFactory.h", "NSDataBigString.h", "RCTCxxBridgeDelegate.h", + "RCTJSIExecutorRuntimeInstaller.h", "RCTMessageThread.h", ] } @@ -56,6 +57,7 @@ fb_native.genrule( ) + [ react_native_root_target("packages/rn-tester:nativecomponent-srcs"), ], + labels = ["uses_hg"], cmd = "$(exe {}) $OUT $SRCS".format(react_native_root_target("packages/react-native-codegen:write_to_json")), out = "schema-rncore.json", ) @@ -95,6 +97,7 @@ rn_xplat_cxx_library2( # it's linked in your app, transparently use it". labels = [ "depslint_never_remove", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode() + [ @@ -151,14 +154,17 @@ rn_xplat_cxx_library2( frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", ], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode() + ["-DWITH_FBSYSTRACE=1"], visibility = ["PUBLIC"], deps = [ ":RCTCxxUtils", ":ReactInternal", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", react_native_xplat_target("cxxreact:module"), react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("reactperflogger:reactperflogger"), @@ -182,13 +188,16 @@ rn_xplat_cxx_library2( exclude = RCTCXXMODULE_PUBLIC_HEADERS.values(), prefix = "React", ), - apple_sdks = (IOS, APPLETVOS), + apple_sdks = (IOS,), contacts = ["oncall+react_native@xmail.facebook.com"], fbobjc_enable_exceptions = True, frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", ], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), visibility = ["PUBLIC"], deps = [ @@ -196,6 +205,35 @@ rn_xplat_cxx_library2( ], ) +rn_xplat_cxx_library2( + name = "RCTCxxLogUtils", + srcs = glob([ + "React/CxxLogUtils/*.mm", + ]), + header_namespace = "", + exported_headers = subdir_glob( + [ + ( + "React/CxxLogUtils", + "*.h", + ), + ], + prefix = "React", + ), + contacts = ["oncall+react_native@xmail.facebook.com"], + fbobjc_enable_exceptions = True, + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], + preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), + visibility = ["PUBLIC"], + deps = [ + "//xplat/js/react-native-github:ReactInternal", + react_native_xplat_target("logger:logger"), + ], +) + RCTLIB_PATH = "Libraries/" RCTBASE_PATH = "React/Base/" @@ -217,6 +255,7 @@ REACT_PUBLIC_HEADERS = { "React/RCTBridgeDelegate.h": RCTBASE_PATH + "RCTBridgeDelegate.h", "React/RCTBridgeMethod.h": RCTBASE_PATH + "RCTBridgeMethod.h", "React/RCTBridgeModule.h": RCTBASE_PATH + "RCTBridgeModule.h", + "React/RCTBridgeModuleDecorator.h": RCTBASE_PATH + "RCTBridgeModuleDecorator.h", "React/RCTBundleURLProvider.h": RCTBASE_PATH + "RCTBundleURLProvider.h", "React/RCTComponent.h": RCTVIEWS_PATH + "RCTComponent.h", "React/RCTComponentData.h": RCTVIEWS_PATH + "RCTComponentData.h", @@ -253,6 +292,7 @@ REACT_PUBLIC_HEADERS = { "React/RCTLayoutAnimationGroup.h": RCTMODULES_PATH + "RCTLayoutAnimationGroup.h", "React/RCTLog.h": RCTBASE_PATH + "RCTLog.h", "React/RCTManagedPointer.h": RCTBASE_PATH + "RCTManagedPointer.h", + "React/RCTMockDef.h": RCTBASE_PATH + "RCTMockDef.h", "React/RCTModalHostViewController.h": RCTVIEWS_PATH + "RCTModalHostViewController.h", "React/RCTModalHostViewManager.h": RCTVIEWS_PATH + "RCTModalHostViewManager.h", "React/RCTModalManager.h": RCTVIEWS_PATH + "RCTModalManager.h", @@ -260,9 +300,11 @@ REACT_PUBLIC_HEADERS = { "React/RCTModuleMethod.h": RCTBASE_PATH + "RCTModuleMethod.h", "React/RCTMultipartStreamReader.h": RCTBASE_PATH + "RCTMultipartStreamReader.h", "React/RCTNullability.h": RCTBASE_PATH + "RCTNullability.h", + "React/RCTPLTag.h": RCTBASE_PATH + "RCTPLTag.h", "React/RCTPackagerClient.h": RCTDEVSUPPORT_PATH + "RCTPackagerClient.h", "React/RCTPackagerConnection.h": RCTDEVSUPPORT_PATH + "RCTPackagerConnection.h", "React/RCTPerformanceLogger.h": RCTBASE_PATH + "RCTPerformanceLogger.h", + "React/RCTPerformanceLoggerLabels.h": RCTBASE_PATH + "RCTPerformanceLoggerLabels.h", "React/RCTPointerEvents.h": RCTVIEWS_PATH + "RCTPointerEvents.h", "React/RCTProfile.h": "React/Profiler/RCTProfile.h", "React/RCTPushNotificationManager.h": RCTLIB_PATH + "PushNotificationIOS/RCTPushNotificationManager.h", @@ -309,7 +351,6 @@ REACT_PUBLIC_HEADERS = { "React/RCTViewManager.h": RCTVIEWS_PATH + "RCTViewManager.h", "React/RCTViewUtils.h": RCTVIEWS_PATH + "RCTViewUtils.h", "React/RCTWeakProxy.h": RCTBASE_PATH + "RCTWeakProxy.h", - "React/RCTWeakViewHolder.h": RCTVIEWS_PATH + "RCTWeakViewHolder.h", "React/RCTWrapperViewController.h": RCTVIEWS_PATH + "RCTWrapperViewController.h", "React/UIView+React.h": RCTVIEWS_PATH + "UIView+React.h", } @@ -387,6 +428,7 @@ rn_xplat_cxx_library2( labels = [ "depslint_never_add", "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], platform_preprocessor_flags = [( @@ -404,6 +446,7 @@ rn_xplat_cxx_library2( "//fbobjc/Libraries/FBQPLMetadataProviders/...", "//fbobjc/Libraries/FBReactKit/...", "//fbobjc/Libraries/FBiOSSecurityUtils/...", + "//fbobjc/Libraries/RCTPrerendering/...", "//fbobjc/VendorLib/react-native-maps:react-native-maps", "//xplat/js:", "//xplat/js/react-native-github/React/...", @@ -441,7 +484,6 @@ rn_xplat_cxx_library2( "React/RCTComponentViewRegistry.h": "React/Fabric/Mounting/RCTComponentViewRegistry.h", "React/RCTFabricSurface.h": "React/Fabric/Surface/RCTFabricSurface.h", "React/RCTFabricSurfaceHostingProxyRootView.h": "React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h", - "React/RCTFabricSurfaceHostingView.h": "React/Fabric/Surface/RCTFabricSurfaceHostingView.h", "React/RCTGenericDelegateSplitter.h": "React/Fabric/Utils/RCTGenericDelegateSplitter.h", "React/RCTLegacyViewManagerInteropComponentView.h": "React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h", "React/RCTLocalizationProvider.h": "React/Fabric/RCTLocalizationProvider.h", @@ -468,7 +510,7 @@ rn_xplat_cxx_library2( ], contacts = ["oncall+react_native@xmail.facebook.com"], fbobjc_enable_exceptions = True, - fbobjc_target_sdk_version = "11.0", + fbobjc_target_sdk_version = get_react_native_ios_target_sdk_version(), frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/QuartzCore.framework", @@ -477,6 +519,7 @@ rn_xplat_cxx_library2( header_path_prefix = "React", labels = [ "disable_plugins_only_validation", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = [ @@ -507,6 +550,7 @@ rn_xplat_cxx_library2( ":RCTFabricComponentViewsBase", "//fbobjc/Libraries/FBReactKit/RCTFabricComponent/RCTFabricComponentPlugin:RCTFabricComponentPlugin", "//xplat/js/react-native-github:RCTCxxBridge", + "//xplat/js/react-native-github:RCTCxxLogUtils", "//xplat/js/react-native-github:RCTCxxUtils", "//xplat/js/react-native-github:RCTImage", "//xplat/js/react-native-github:RCTPushNotification", @@ -558,7 +602,10 @@ rn_apple_library( "$PLATFORM_DIR/Developer/Library/Frameworks/Foundation.framework", ], inherited_buck_flags = get_static_library_ios_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), reexport_all_header_dependencies = True, deps = [ @@ -628,6 +675,7 @@ rn_apple_library( contacts = ["oncall+react_native@xmail.facebook.com"], labels = [ "disable_plugins_only_validation", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = [react_fabric_component_plugin_provider("Image", "RCTImageCls")], @@ -658,7 +706,10 @@ rn_xplat_cxx_library2( }, compiler_flags = ["-Wall"], contacts = ["oncall+react_native@xmail.facebook.com"], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], visibility = ["PUBLIC"], deps = [ "//xplat/js/react-native-github:RCTImage", @@ -685,30 +736,32 @@ rn_library( "**/__*__/**", "**/gulpfile.js", "Libraries/Components/Switch/SwitchSchema.js", + "**/*._reactvr.js", ], ), - labels = ["supermodule:xplat/default/public.react_native.core"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.core", + ], visibility = ["PUBLIC"], deps = [ "//xplat/js:node_modules__abort_19controller", "//xplat/js:node_modules__anser", "//xplat/js:node_modules__base64_19js", - "//xplat/js:node_modules__deprecated_19react_19native_19prop_19types", "//xplat/js:node_modules__event_19target_19shim", "//xplat/js:node_modules__invariant", + "//xplat/js:node_modules__memoize_19one", "//xplat/js:node_modules__nullthrows", "//xplat/js:node_modules__pretty_19format", "//xplat/js:node_modules__promise", - "//xplat/js:node_modules__prop_19types", "//xplat/js:node_modules__react_19devtools_19core", "//xplat/js:node_modules__react_19refresh", "//xplat/js:node_modules__react_19shallow_19renderer", "//xplat/js:node_modules__regenerator_19runtime", "//xplat/js:node_modules__stacktrace_19parser", - "//xplat/js:node_modules__use_19subscription", + "//xplat/js:node_modules__use_19sync_19external_19store", "//xplat/js:node_modules__whatwg_19fetch", "//xplat/js/RKJSModules/Libraries/Polyfills:Polyfills", - "//xplat/js/RKJSModules/Libraries/React:React", "//xplat/js/RKJSModules/vendor/react:react", "//xplat/js/RKJSModules/vendor/react-test-renderer:react-test-renderer", "//xplat/js/RKJSModules/vendor/scheduler:scheduler", @@ -725,7 +778,10 @@ rn_codegen( android_package_name = "com.facebook.fbreact.specs", codegen_modules = True, ios_assume_nonnull = False, - library_labels = ["supermodule:xplat/default/public.react_native.infra"], + library_labels = [ + "supermodule:xplat/default/public.react_native.infra", + "pfh:ReactNative_CommonInfrastructurePlaceholder", + ], native_module_spec_name = "FBReactNativeSpec", src_prefix = "Libraries/", ) @@ -735,7 +791,10 @@ rn_codegen( name = "FBReactNativeComponentSpec", codegen_components = True, ios_assume_nonnull = False, - library_labels = ["supermodule:xplat/default/public.react_native.infra"], + library_labels = [ + "supermodule:xplat/default/public.react_native.infra", + "pfh:ReactNative_CommonInfrastructurePlaceholder", + ], src_prefix = "Libraries/", ) @@ -769,6 +828,7 @@ rn_apple_library( "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", "extension_api_allow_unsafe_unavailable_usages", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -818,6 +878,7 @@ rn_apple_library( labels = [ "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -876,6 +937,7 @@ rn_apple_library( "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", "extension_api_allow_unsafe_unavailable_usages", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -923,6 +985,7 @@ rn_apple_library( "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", "extension_api_allow_unsafe_unavailable_usages", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -974,6 +1037,7 @@ rn_apple_library( "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", "extension_api_allow_unsafe_unavailable_usages", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -1054,6 +1118,7 @@ rn_apple_library( "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. "disable_plugins_only_validation", "extension_api_allow_unsafe_unavailable_usages", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = @@ -1187,6 +1252,7 @@ rn_xplat_cxx_library2( ], labels = [ "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), @@ -1219,6 +1285,7 @@ rn_apple_library( labels = [ "depslint_never_remove", "disable_plugins_only_validation", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], plugins = react_module_plugin_providers( @@ -1259,6 +1326,7 @@ rn_xplat_cxx_library2( ], labels = [ "depslint_never_remove", # Some old NativeModule still relies on +load unfortunately. + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), @@ -1291,6 +1359,7 @@ rn_xplat_cxx_library2( ], labels = [ "depslint_never_remove", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), @@ -1325,12 +1394,14 @@ rn_xplat_cxx_library2( ], labels = [ "depslint_never_remove", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), visibility = ["PUBLIC"], deps = [ "//fbobjc/Libraries/MobileUI/ComponentKit:ComponentKit", + "//xplat/js/react-native-github:RCTFabric", "//xplat/js/react-native-github:RCTLinking", "//xplat/js/react-native-github:RCTPushNotification", "//xplat/js/react-native-github:ReactInternal", @@ -1359,6 +1430,7 @@ rn_xplat_cxx_library2( ], labels = [ "depslint_never_remove", + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), @@ -1366,6 +1438,7 @@ rn_xplat_cxx_library2( deps = [ ":RCTSurfaceHostingComponent", "//fbobjc/Libraries/MobileUI/ComponentKit:ComponentKit", + "//xplat/js/react-native-github:RCTFabric", "//xplat/js/react-native-github:RCTLinking", "//xplat/js/react-native-github:RCTPushNotification", "//xplat/js/react-native-github:ReactInternal", @@ -1379,6 +1452,7 @@ rn_xplat_cxx_library2( "React/RCTConvert+CoreLocation.h": RCTVIEWS_PATH + "RCTConvert+CoreLocation.h", }, labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], visibility = [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 60844b3848bfbb..255539250f8b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,612 @@ # Changelog +## v0.69.1 + +### Changed + +#### iOS specific + +- Make all Yoga headers public and add #ifdef __cplusplus ([43f831b23c](https://github.com/facebook/react-native/commit/43f831b23caf22e59af5c6d3fdd62fed3d20d4ec) by [@janicduplessis](https://github.com/janicduplessis)) + +### Fixed + +- Use monotonic clock for performance.now() ([114d31feee](https://github.com/facebook/react-native/commit/114d31feeeb47f5a57419e5088c3cbe9340f757a)) + +#### iOS specific + +- Fix build for React-RCTText ([4ea38e16bf](https://github.com/facebook/react-native/commit/4ea38e16bf533955557057656cba5346d2372acd) by [@ph4r05](https://github.com/ph4r05)) +- Fix RCT-Folly build error when use_frameworks! and hermes are both enabled ([79baca678a](https://github.com/facebook/react-native/commit/79baca678a743560fa16fdd551f1d0d018d34304) by [@Kudo](https://github.com/Kudo)) +- Fix use_frameworks! for 0.69 ([f97c6a5b49](https://github.com/facebook/react-native/commit/f97c6a5b498eec95e99a02c7842cb2ae160cd6cd) by [@Kudo](https://github.com/Kudo)) + +## v0.69.0 + +### Breaking + +- Support for `console.disableYellowBox` [has been dropped](https://github.com/facebook/react-native/commit/b633cc130533f0731b2577123282c4530e4f0abe) +- Already deprecated prop types have been removed ([cdfddb4dad](https://github.com/facebook/react-native/commit/cdfddb4dad7c69904850d7e5f089a32a1d3445d1), [3e229f27bc](https://github.com/facebook/react-native/commit/3e229f27bc9c7556876ff776abf70147289d544b), [10199b1581](https://github.com/facebook/react-native/commit/10199b158138b8645550b5579df87e654213fe42)) +- `removeListener`, deprecated since RN0.65, [was removed](https://github.com/facebook/react-native/commit/8dfbed786b40082a7a222e00dc0a621c0695697d) from Appearance +- If you were using `SegmentedComponentIOS`, you will now need to move to the [segmented-control](https://github.com/react-native-segmented-control/segmented-control) library ([235f168574](https://github.com/facebook/react-native/commit/235f1685748442553e53f8ec6d904bc0314a8ae6)) + +### Added + +- Add Hermes scripts to package ([004b8609d9](https://github.com/facebook/react-native/commit/004b8609d97b14a6d5cb8c9e63afdbe343c500da) by [@hramos](https://github.com/hramos)) +- Expose scheduler through FabricUIManager ([1730949e94](https://github.com/facebook/react-native/commit/1730949e94aa23927a90d2a64d91977b7e2904d6) by [@cortinico](https://github.com/cortinico)) +- Add event listeners to Scheduler ([e51e19ecc1](https://github.com/facebook/react-native/commit/e51e19ecc1d1b8ac5c860eac55338ef13471844f) by [@cortinico](https://github.com/cortinico)) +- C++ TurboModule methods can return functions ([c7380ba113](https://github.com/facebook/react-native/commit/c7380ba1131b26b487ecae87239a4cf82afefd15) by [@appden](https://github.com/appden)) +- Add support for devtools' profiler ([fefa7b6ac8](https://github.com/facebook/react-native/commit/fefa7b6ac8a1e0e33fa7a1070936c5c83c873c0a) by [@jpporto](https://github.com/jpporto)) +- Add getAll function to FormData class for getting all parts containing that key. This is also available in web API. ([d05a5d1551](https://github.com/facebook/react-native/commit/d05a5d15512ab794ef80b31ef91090d5d88b3fcd) by [@matinzd](https://github.com/matinzd)) +- Automatic type conversions for C++ TurboModules ([31f0796237](https://github.com/facebook/react-native/commit/31f079623732fb017b1fa38d56abe855d7738ece) by [@appden](https://github.com/appden)) +- New bridging API for JSI <-> C++ ([30cb78e709](https://github.com/facebook/react-native/commit/30cb78e709bccb4f7bf7aab3f6b0f1ba4261f577) by [@appden](https://github.com/appden)) +- Add asBool() method to JSI ([603620b739](https://github.com/facebook/react-native/commit/603620b7394da5855e2255790bfea9ad7d80ddf9) by [@appden](https://github.com/appden)) +- CustomEvent and Event polyfills for React Native ([6abbef1200](https://github.com/facebook/react-native/commit/6abbef1200af9adab1848de17955d77fbe0ad5da) by [@JoshuaGross](https://github.com/JoshuaGross)) +- Implement Runtime.getHeapUsage for hermes chrome inspector ([cff9590864](https://github.com/facebook/react-native/commit/cff9590864c4be153a4eb49757b7cac8b3f23f66) by [@janicduplessis](https://github.com/janicduplessis)) +- Introduce ReactNativeFeatureFlags file to control FeatureFlags in React Native ([33aba77456](https://github.com/facebook/react-native/commit/33aba774564acdec216e02e28f17ad08ad7bc26b) by [@mdvacca](https://github.com/mdvacca)) +- Added fail-safe check to catch MissingWebViewPackage Exception ([8c573d9336](https://github.com/facebook/react-native/commit/8c573d933652ae4da1008502c53fce93057101c0) by [@Kunal-Airtel2022](https://github.com/Kunal-Airtel2022)) +- Add ability to access properties with symbol keys through JSI ([9010bfe457](https://github.com/facebook/react-native/commit/9010bfe457b77862024214ce6210504ff1786ef5) by [@neildhar](https://github.com/neildhar)) +- Allow color styles to be animated using native driver ([201f355479](https://github.com/facebook/react-native/commit/201f355479cafbcece3d9eb40a52bae003da3e5c) by [@genkikondo](https://github.com/genkikondo)) +- Make react-native depend on react-native-gradle-plugin ([3346efb7d4](https://github.com/facebook/react-native/commit/3346efb7d422bd8eb7f48650b454071f9981fa0b) by [@cortinico](https://github.com/cortinico)) +- Add RawEventTelemetryEventEmitter interface to ReactNativePrivateInterface ([1f15a64028](https://github.com/facebook/react-native/commit/1f15a6402869b001cae049facc17126924b97197) by [@JoshuaGross](https://github.com/JoshuaGross)) +- Implement Runtime.getHeapUsage for hermes chrome inspector ([3568a72987](https://github.com/facebook/react-native/commit/3568a7298738a651d76c70763362c297ab601ee8) by [@janicduplessis](https://github.com/janicduplessis)) +- Add support for C++17 in OSS ([c2e4ae39b8](https://github.com/facebook/react-native/commit/c2e4ae39b8a5c6534a3fa4dae4130166eda15169) by [@sammy-SC](https://github.com/sammy-SC)) + +#### Android specific + +- Generate `Nullable` for optional objects and arrays in module codegen. ([ffaa5d69bc](https://github.com/facebook/react-native/commit/ffaa5d69bc268918891121e2d60e7ca08ee82530)) +- Expose an API to enable Concurrent Root on Android ([d7b64b8d4b](https://github.com/facebook/react-native/commit/d7b64b8d4b2f403ce00b27c5df89ffb3a64dc6de) by [@cortinico](https://github.com/cortinico)) +- Add scrollEventThrottle prop support in Android ([cf55fd587e](https://github.com/facebook/react-native/commit/cf55fd587e6cc82a73079be6076d244ab72fa359) by [@ryancat](https://github.com/ryancat)) +- Accessibility announcement for list and grid in FlatList ([dd6325bafe](https://github.com/facebook/react-native/commit/dd6325bafe1a539d348f3710e717a6344576b859) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Introduce ModuleDataCleaner.cleanDataFromModules(ReactContext) ([184dfb8f8b](https://github.com/facebook/react-native/commit/184dfb8f8bd4dfbb8d1575e9554e3f3361793015) by [@RSNara](https://github.com/RSNara)) +- Introduce ReactContext.getNativeModules() ([b978308519](https://github.com/facebook/react-native/commit/b978308519f71c6c7fda4b38a842aa219a349275) by [@RSNara](https://github.com/RSNara)) +- MapBuffer implementation for JVM -> C++ communication ([cf6f3b680b](https://github.com/facebook/react-native/commit/cf6f3b680b43fae31e97b14af681293503025a0c)) +- Make links independently focusable by Talkback ([7b5b114d57](https://github.com/facebook/react-native/commit/7b5b114d578142d18bf4a7a5279b179a9ac8d958) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Support animating text color with native driver ([87cdb607e4](https://github.com/facebook/react-native/commit/87cdb607e4792156d433c44b89932e7dae3371da) by [@genkikondo](https://github.com/genkikondo)) +- Added an experimental prop serialization path based on MapBuffer ([cbcdaae2b5](https://github.com/facebook/react-native/commit/cbcdaae2b5dda2a44c95d83dcb5b5aa0f43bc6f9)) +- Allow to setup a Gradle Enterprise instance via an external script ([f11dcfaea1](https://github.com/facebook/react-native/commit/f11dcfaea14249b059aea2474ce36a0665140d4f) by [@cortinico](https://github.com/cortinico)) +- Support platform color with AnimatedColor ([cb42049e0a](https://github.com/facebook/react-native/commit/cb42049e0ae262afe907ace1099414836ab0018d) by [@genkikondo](https://github.com/genkikondo)) +- Support running animations with AnimatedColor with native driver ([3f49e6763e](https://github.com/facebook/react-native/commit/3f49e6763e66447f6ae17dc2f032e27330b7b74a) by [@genkikondo](https://github.com/genkikondo)) +- Add public API to ReactRootView to control if JS touch events are dispatched ([0a517ae438](https://github.com/facebook/react-native/commit/0a517ae43892fb764d829f8bae56c1ac58356b1b) by [@ryancat](https://github.com/ryancat)) + +#### iOS specific + +- Prepare a method in the AppDelegate to control the concurrentRoot. ([8ac8439e0d](https://github.com/facebook/react-native/commit/8ac8439e0dcc0cc4a9c0cc99f614a5e19bae56eb) by [@cipolleschi](https://github.com/cipolleschi)) +- `hotkeysEnabled` property is added to `RCTDevMenu` which allows enabling/disabling hotkeys that triggers developer menu popup ([1a1a304ed2](https://github.com/facebook/react-native/commit/1a1a304ed2023d60547aef65b1a7bf56467edf08)) +- Allow modifying iOS image cache limits ([61b013e7ad](https://github.com/facebook/react-native/commit/61b013e7ad8a1cc28ee39434d2fd96b74b96cf5f) by [@danilobuerger](https://github.com/danilobuerger)) +- Add dismissActionSheet method to ActionSheetIOS ([64ebe5bbdd](https://github.com/facebook/react-native/commit/64ebe5bbdd32fc3b3a243a8a81a6f724d8f81267) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Integrated the `accessibilityLanguage` prop to all the available components. The prop is available for any platform but it will work only on iOS. ([7b05b091fd](https://github.com/facebook/react-native/commit/7b05b091fd97f95b778369277ac2147730abc7b8) by [@dgopsq](https://github.com/dgopsq)) +- Support running animations with AnimatedColor with native driver ([49f3f47b1e](https://github.com/facebook/react-native/commit/49f3f47b1e9b840e4374d46b105604f4d2c22dd5) by [@genkikondo](https://github.com/genkikondo)) + +### Changed + +- Update direct Metro dependencies to 0.70.1 ([b74e964e70](https://github.com/facebook/react-native/commit/b74e964e705c40834acad7020562e870cdad9db1), ([c92b64b16a](https://github.com/facebook/react-native/commit/c92b64b16a5710c1dfaea9af4c271931e4669636) by [@arushikesarwani94](https://github.com/arushikesarwani94)), ([f89a0b765c](https://github.com/facebook/react-native/commit/f89a0b765c09c9aba573f03777cc76673989628f) by [@robhogan](https://github.com/robhogan)) +- Upgrade RN CLI to v8.0.0 ([0605880c9e](https://github.com/facebook/react-native/commit/0605880c9ed0aec812f3198eb5075db64fba969a), [1e0226f933](https://github.com/facebook/react-native/commit/1e0226f933814bf9ada87eaa14348bfff863ead1), [24bb7f7380](https://github.com/facebook/react-native/commit/24bb7f7380662925f078d78a03fbc954af2da3d6), [7dceb9b63c](https://github.com/facebook/react-native/commit/7dceb9b63c0bfd5b13bf6d26f9530729506e9097) by [@thymikee](https://github.com/thymikee)) +- Replace use-subscripton with use-sync-external-store ([93b50be8c2](https://github.com/facebook/react-native/commit/93b50be8c2341a0daf41f6fdc656896c4907c4dc) by [@rickhanlonii](https://github.com/rickhanlonii)) +- Expose UIManager from Scheduler ([54db5f2012](https://github.com/facebook/react-native/commit/54db5f201292ebf267800d92b7dd5bfa22431963) by [@cortinico](https://github.com/cortinico)) +- Optimized VirtualizedList context when used with nested lists ([ceb0a54608](https://github.com/facebook/react-native/commit/ceb0a546083509192c059cdd93d6aa379e38ef4e) by [@javache](https://github.com/javache)) +- Remove usage of std::string in EarlyJsErrorHandler. ([30051b2c41](https://github.com/facebook/react-native/commit/30051b2c4185bff015c72069488b5f6ba3391ad7) by [@sshic](https://github.com/sshic)) +- `eslint-config`: add support for ESLint 8 ([864a8c11b2](https://github.com/facebook/react-native/commit/864a8c11b2a7540f607ebc0e084edd7393169359) by [@wcandillon](https://github.com/wcandillon)) +- `eslint-config`: add support for TypeScript 4.5+ ([199ac680c7](https://github.com/facebook/react-native/commit/199ac680c7867a982e25620219bffa18f85f5404) by [@rnike](https://github.com/rnike)) +- Upgraded react-devtools-core dependency to 4.24.0 ([a7a781ff4a](https://github.com/facebook/react-native/commit/a7a781ff4a13e744f4eb3007ef0657740b277a72)) +- Avoid flattening nodes with event props ([980c52de41](https://github.com/facebook/react-native/commit/980c52de41258f6cf2d2360144ea7ca16a19c9f8)) +- Type the argument of Animated.interpolate as read-only ([6584304c10](https://github.com/facebook/react-native/commit/6584304c100ce4d51a5c4d606170a6ad0dc00875) by [@motiz88](https://github.com/motiz88)) +- Update gradle-download-task to 5.0.1 to support concurrent downloads ([a86cae7aac](https://github.com/facebook/react-native/commit/a86cae7aacc9837536e7d679870a57dcd0f45475) by [@michel-kraemer](https://github.com/michel-kraemer)) +- Logging a soft error when ReactRootView has an id other than -1 instead of crashing the app in hybrid apps ([1ca2c24930](https://github.com/facebook/react-native/commit/1ca2c2493027c1b027146cd41e17dd8a4fc33a41) by [@Kunal-Airtel2022](https://github.com/Kunal-Airtel2022)) + +#### Android specific + +- Gradle: extend the algoritm to find hermesc paths ([aeac6ab677](https://github.com/facebook/react-native/commit/aeac6ab6773cd2c0ca7abe9e5aa3f22fa81683e5) by [@cortinico](https://github.com/cortinico)) +- Bump boost for Android to 1.76 to align with iOS ([5cd6367f0b](https://github.com/facebook/react-native/commit/5cd6367f0b86543274a15bb6d0e53a8545fed845) by [@kelset](https://github.com/kelset)) +- Adopt `MapBuffer` interface for `ReadableMapBuffer` ([81e4249315](https://github.com/facebook/react-native/commit/81e42493158edd5e7b88f98c19c87e9d61ba4aba)) +- Mark intent as nullable ([5ffa0b0aa6](https://github.com/facebook/react-native/commit/5ffa0b0aa6c523234c634167be1f94b0d9edb0f7) by [@sshic](https://github.com/sshic)) +- Use CMake to build ReactAndroid module ([e3830ddffd](https://github.com/facebook/react-native/commit/e3830ddffd9260fe071e0c9f9df40b379d54cf26)) +- Update template/android and RN Tester to use `hermes-engine` from the `react-native` NPM package. ([4d91f40fbd](https://github.com/facebook/react-native/commit/4d91f40fbdf0012689b04084113299676342c0dc) by [@cortinico](https://github.com/cortinico)) +- Build Hermes from Source ([a3d9892ed9](https://github.com/facebook/react-native/commit/a3d9892ed9c993d16fa36fa6b713e2ead43fcc77) by [@cortinico](https://github.com/cortinico)) +- Rename field with default values for ReactConfig to DEFAULT_CONFIG ([964e816752](https://github.com/facebook/react-native/commit/964e81675286c80a8e322127aa7c052f62621098)) +- Moved `com/react/facebook/uimanager/interfaces` files into `com/react/facebook/uimanager` to enable Kotlin build ([b1a779392d](https://github.com/facebook/react-native/commit/b1a779392d483c649d428debfe4a6405247b8c0e)) +- Bump AGP to 7.1.0 and fix bundle inclusion in release mode ([200488e87c](https://github.com/facebook/react-native/commit/200488e87cf4bc355e03c78cd814b97b23452117) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Release react-native-gradle-plugin 0.0.5 ([42272211e4](https://github.com/facebook/react-native/commit/42272211e4a1b7cff7770b59cf1bcf649cbdd6fc) by [@cortinico](https://github.com/cortinico)) +- ViewPagerAndroid recommendation link. ([7e8cce3d2d](https://github.com/facebook/react-native/commit/7e8cce3d2ddffbe36bcb3c9ec2f006f7e1b42a79) by [@maaxg](https://github.com/maaxg)) +- Bump android Appcompat to 1.4.1 ([6b61995647](https://github.com/facebook/react-native/commit/6b61995647c789a567845521fed7b0cc1e0cddb7) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Remove `react-native-gradle-plugin` as a dependency from template's package.json ([cd79317672](https://github.com/facebook/react-native/commit/cd79317672e5c99636346f2abb641a688a4ceb82) by [@cortinico](https://github.com/cortinico)) +- Use 2g as a default heap size for gradle builds ([09e418ef8e](https://github.com/facebook/react-native/commit/09e418ef8e98fd026cf828696ff2475993b76ac2)) +- Use new StatusBar API on Android 11 (API 30)+ ([50c8e973f0](https://github.com/facebook/react-native/commit/50c8e973f067d4ef1fc3c2eddd360a0709828968) by [@ieatfood](https://github.com/ieatfood)) +- Change static string to public ([ab45138394](https://github.com/facebook/react-native/commit/ab45138394f41aeb13370882837968636de04c24) by [@sshic](https://github.com/sshic)) + +#### iOS specific + +- Use pre-built HermesC if available in current React Native release ([644fe430fd](https://github.com/facebook/react-native/commit/644fe430fdecc0bf1fa098d1c2d52178da6c987c) by [@hramos](https://github.com/hramos)) +- When building Hermes from source, the filesystem will now be prepared using the new hermes-utils.js scripts, outside of CocoaPods ([aaa01f7710](https://github.com/facebook/react-native/commit/aaa01f77106f891696d9ec508e2ee71111a6af2a) by [@hramos](https://github.com/hramos)) +- Expose scheduler through RCTSurfacePresenter ([614aa86916](https://github.com/facebook/react-native/commit/614aa86916394d8ee2ecb236f38de6bb7e161ca2) by [@cortinico](https://github.com/cortinico)) +- Adopt UIGraphicsImageRenderer API ([d70d7fd0b3](https://github.com/facebook/react-native/commit/d70d7fd0b3984ee54622afc4692a6c945618c345) by [@matrush](https://github.com/matrush)) +- Build Hermes from source when Hermes is used ([bb01b75637](https://github.com/facebook/react-native/commit/bb01b75637edc1159a3bdb3af86936e1c92f39c1) by [@hramos](https://github.com/hramos)) +- Update CodeGen scripts to accept custom node executable ([323db75c36](https://github.com/facebook/react-native/commit/323db75c36d26d771f6b231c8eabc5afc0da74d3) by [@cipolleschi](https://github.com/cipolleschi)) +- Fixed the fallback behavior when the `.xcode.env` file is missing, actually using the old `find-node-for-xcode.sh` script ([705c6f57d6](https://github.com/facebook/react-native/commit/705c6f57d66b4499f43489292183a58413402a74) by [@cipolleschi](https://github.com/cipolleschi)) +- Adding a link in a message for the users. ([2c52131f5e](https://github.com/facebook/react-native/commit/2c52131f5e0eb4668681242fcdd8150afe3c5827) by [@cipolleschi](https://github.com/cipolleschi)) +- Bump ruby to 2.7.5 ([2c87b7466e](https://github.com/facebook/react-native/commit/2c87b7466e098c5cd230e02b279fc7bc7a357615) by [@danilobuerger](https://github.com/danilobuerger)) +- This PR removes the `find-node.sh` scripts and replaces it with an `.xcode.env` file that is sourced by the script phases that needs it. The `.xcode.env` file is versioned: to customize a local environment, an unversioned `.xcode.local.env` can be used. ([0480f56c5b](https://github.com/facebook/react-native/commit/0480f56c5b5478b6ebe5ad88e347cad2810bfb17) by [@cipolleschi](https://github.com/cipolleschi)) +- Update `PushNotificationIOS.checkPermissions` to include iOS 10+ notification settings. ([17ecd2fb5b](https://github.com/facebook/react-native/commit/17ecd2fb5b3cfb8aa0282ed406b16dc3b9777018)) +- Enable SonarKit in React-Core when the configuration is `'Debug'` ([b5343a6b0d](https://github.com/facebook/react-native/commit/b5343a6b0dd07c1b4ef9dac549df67a4d68ebd1e) by [@cipolleschi](https://github.com/cipolleschi)) +- When Hermes is enabled, the Hermes Engine will be built from source instead of using the pre-built `hermes-engine` CocoaPod. ([12ad1fffe8](https://github.com/facebook/react-native/commit/12ad1fffe87c0c5ab2e001f318ff4f8d3eda7479) by [@hramos](https://github.com/hramos)) +- Replaced folly::Optional with std::optional from C++17 in Objc module generator. ([45e2941367](https://github.com/facebook/react-native/commit/45e2941367fbf13584193bbda598173802289167) by [@philIip](https://github.com/philIip)) +- Removed methodName parameter that was used only for a warning message and moved the warning parameter to be calculated inline. ([cfb11ca2f6](https://github.com/facebook/react-native/commit/cfb11ca2f67c59c090b8a58b2b7bdaacef0e19df)) +- Fix the crash caused by nil partialLoadHandler ([46bc521513](https://github.com/facebook/react-native/commit/46bc521513c9c78e5ffc49cf3e571757e1a91cef)) +- Synchronously render cached images ([189c2c8958](https://github.com/facebook/react-native/commit/189c2c8958442541c6b4f42860b2943ece612da2)) +- Updated Flipper-Glog to 0.5.0.4 ([cd60ffdb62](https://github.com/facebook/react-native/commit/cd60ffdb62b2183cd24baef3075d56f758cea24a)) +- Add function to report early js errors ([1804951595](https://github.com/facebook/react-native/commit/180495159517dc0bfa103621e5ff62fc04cb3c8b) by [@sshic](https://github.com/sshic)) + +### Deprecated + +- Deprecate the use of `react-native/jest/preprocessor.js` by external projects ([c1e9aa9a27](https://github.com/facebook/react-native/commit/c1e9aa9a272aed3cba60c4aeff783eeb8bffce68) by [@motiz88](https://github.com/motiz88)) +- Deprecate the Promise.prototype.done method and log a warning when it's called in development. ([35800962c1](https://github.com/facebook/react-native/commit/35800962c16a33eb8e9ff1adfd428cf00bb670d3) by [@motiz88](https://github.com/motiz88)) + +#### iOS specific + +- Deprecating support for iOS/tvOS SDK 11.0, 12.4+ is now required ([5f2835b14d](https://github.com/facebook/react-native/commit/5f2835b14d35681c268dd64d6ec284ea5f053be3), ([c71e6efbcd](https://github.com/facebook/react-native/commit/c71e6efbcd2b95faee327d9763d321488120bc5e), ([982ca30de0](https://github.com/facebook/react-native/commit/982ca30de079d7e80bd0b50365d58b9048fb628f) by [@philIip](https://github.com/philIip)) + +#### iOS specific + +- Removed lint restricting `DynamicColorIOS` to only two properties ([13b0b06522](https://github.com/facebook/react-native/commit/13b0b0652259ada468cc044b0b604edb666b2eb9)) + +### Fixed + +- Remove unactionable warning about `codegenNativeComponent` when on 'Paper' ([494b73cb33](https://github.com/facebook/react-native/commit/494b73cb33197fa865e9ead8fdca11bce6822917) by [@tido64](https://github.com/tido64)) +- Fix typo in Value's constructor with a Symbol ([a7a0f86a73](https://github.com/facebook/react-native/commit/a7a0f86a73ab51be31fb2c3205612d7ff1fb5384) by [@jpporto](https://github.com/jpporto)) +- Avoid full copy of large folly::dynamic objects by switching to std::move semantics ([3f98c8e4c2](https://github.com/facebook/react-native/commit/3f98c8e4c2c8f40b81c1a90aa65c1bdc9327faed) by [@NikoAri](https://github.com/NikoAri)) +- Fix performance issue on Animated.interpolate with big input range ([f503b21203](https://github.com/facebook/react-native/commit/f503b212039f79f00ea56b65ecf3cd150b82f087) by [@Almouro](https://github.com/Almouro)) +- Update function spacing linting rules ([8650220cf9](https://github.com/facebook/react-native/commit/8650220cf99739c4b904a37ce4f19ce7dfd3bdbb) by [@joeframbach](https://github.com/joeframbach)) +- Add supportsFromJs and supportsToJs template variables ([087624ccaf](https://github.com/facebook/react-native/commit/087624ccaf2e484c0b6425e57edf9afd62a06e9a) by [@appden](https://github.com/appden)) +- The Array appended to FormData is transmitted as a string ([d2e8e7d58e](https://github.com/facebook/react-native/commit/d2e8e7d58e680e0bb3b4da1f820dd4dd840639f5) by [@bang9](https://github.com/bang9)) +- AppState.removeEventListener correctly removes listener for blur and focus events ([9aab25ec53](https://github.com/facebook/react-native/commit/9aab25ec536473ffe6d22c5efeae8fea6bd769be) by [@AntoineDoubovetzky](https://github.com/AntoineDoubovetzky)) +- `focus()` on TextInput to respect its `editable` state ([8a5460ce80](https://github.com/facebook/react-native/commit/8a5460ce80e69c11a007121d4278d55642f6b10e) by [@vonovak](https://github.com/vonovak)) +- Restore Windows build with RawPropsParser.cpp ([2d64d1d693](https://github.com/facebook/react-native/commit/2d64d1d69360161c047c86a026403d8074ba28bb) by [@TatianaKapos](https://github.com/TatianaKapos)) +- Fix babel-plugin-codegen crash when export init is null ([ae756647c9](https://github.com/facebook/react-native/commit/ae756647c9b8a88ba615fd30185f621825a33427) by [@janicduplessis](https://github.com/janicduplessis)) +- Fixed compilation warning due to `using namespace` being used as part of header ([009d80bf5a](https://github.com/facebook/react-native/commit/009d80bf5a55dd74be448960b1344ac7599c6bae) by [@arhelmus](https://github.com/arhelmus)) +- Allow including TurboModule.h in mixed rtti/no-rtti environment, even if TurboModule.h/cpp is compiled without RTTI. ([1f87729697](https://github.com/facebook/react-native/commit/1f87729697370a4ab31e2bb9ab1780438d9e146f) by [@nlutsenko](https://github.com/nlutsenko)) +- Remove prettier from dependencies in eslint-config ([2db1bca952](https://github.com/facebook/react-native/commit/2db1bca95224ce39484c3f27508aec9a21ce126a) by [@Kerumen](https://github.com/Kerumen)) +- Switch Component doesn't disable click functionality when disabled ([b2e625a517](https://github.com/facebook/react-native/commit/b2e625a51723becea4cef0433448fbec679669ee) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Support numeric color values in StyleSheet's Flow types ([83b1975b90](https://github.com/facebook/react-native/commit/83b1975b90569a36020da33156615a13fcc7ba92) by [@motiz88](https://github.com/motiz88)) +- Fix build break on Windows with ReactCommon ([42b391775f](https://github.com/facebook/react-native/commit/42b391775f663df335f6f2553104fc2fa35b1bee) by [@chiaramooney](https://github.com/chiaramooney)) +- Fixed opacity value in TouchableOpacity ([3eddc9abb7](https://github.com/facebook/react-native/commit/3eddc9abb70eb54209c68aab7dbd69e363cc7b29) by [@hetanthakkar1](https://github.com/hetanthakkar1)) +- Remove illegal private property access in VirtualizedSectionList.scrollToLocation ([b2f871a6fa](https://github.com/facebook/react-native/commit/b2f871a6fa9c92dd0712055384b9eca6d828e37d) by [@motiz88](https://github.com/motiz88)) +- JS animated node value updates properly when listener is attached ([1f778014a7](https://github.com/facebook/react-native/commit/1f778014a7e95c5c473898c38d5b1e0725cd373c) by [@genkikondo](https://github.com/genkikondo)) +- Working around Long paths limitation on Windows ([7b76abc0d3](https://github.com/facebook/react-native/commit/7b76abc0d3a0a5bec37f314c80954e412fc5f5ec) by [@mganandraj](https://github.com/mganandraj)) +- Fix VirtualizedList with initialScrollIndex not rendering all elements when data is updated ([c5c17985da](https://github.com/facebook/react-native/commit/c5c17985dae402725abb8a3a94ccedc515428711) by [@AntoineDoubovetzky](https://github.com/AntoineDoubovetzky)) + +#### Android specific + +- Add back hermes inspector support ([6b6adcc111](https://github.com/facebook/react-native/commit/6b6adcc111123bec2c4c110070b2506385e74664) by [@Kudo](https://github.com/Kudo)) +- Fixed issue where any node with an AccessibilityDelegate set (which was any node with any accessibility propoerty), was using ExploreByTouchHelper's built in AccessibilityNodeProvider, and not properly populating their AccessibilityNodeInfo's, leading to focus issues and issues with automated test services like UIAutomator. ([70fcab76a4](https://github.com/facebook/react-native/commit/70fcab76a4dcf65e628ac897620fe050758574e3) by [@blavalla](https://github.com/blavalla)) +- Fix Extras usage in Android implementation of Linking.sendIntent() ([86f8d0bb52](https://github.com/facebook/react-native/commit/86f8d0bb528a75777c357ae214643ed58c326ca9)) +- Fix typo in gradle plugin deprecation message ([41cfd2f976](https://github.com/facebook/react-native/commit/41cfd2f9768e4742eedd299ab467d316d016705e) by [@mikehardy](https://github.com/mikehardy)) +- Fixed `TimingModule` related functions for headless JS tasks, eg. `setTimeout` ([dac56ce077](https://github.com/facebook/react-native/commit/dac56ce0776e0e4d23ed4f8b324f2e2432aefa6a) by [@marcesengel](https://github.com/marcesengel)) +- Improve support for Android users on M1 machine ([c5babd993a](https://github.com/facebook/react-native/commit/c5babd993a2bed2994ecc4710fa9e424b3e6cfc2) by [@cortinico](https://github.com/cortinico)) +- Do not use `rootProject` directly in Gradle scripts ([b2bc5aa5c9](https://github.com/facebook/react-native/commit/b2bc5aa5c903ad057a53d4caa82b0fe74e01c07c) by [@cortinico](https://github.com/cortinico)) +- Adding null check for context in redbox surface delegate ([9527ab1584](https://github.com/facebook/react-native/commit/9527ab1584869d7966c562e8aa7cbf48788156a3) by [@ryancat](https://github.com/ryancat)) +- Fix crash on empty snapToOffsets array ([145fd041c7](https://github.com/facebook/react-native/commit/145fd041c7afe9a18f08f461487bb515ab2f516a) by [@ryancat](https://github.com/ryancat)) +- Fix StatusBar not updating to use translucent values when set to the same value across different activities ([d34a75e9e5](https://github.com/facebook/react-native/commit/d34a75e9e5932adcac4a16f5b815bb909c3aa0dd)) +- Fix underlineColorAndroid transparent not working on API 21 ([52aee50a70](https://github.com/facebook/react-native/commit/52aee50a704bbeab91f5fa05fe3220dee304422f) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Fixed regression on content in scroll view not responding to touch when fling got interrupted ([bb8ff9260f](https://github.com/facebook/react-native/commit/bb8ff9260fe6a783171f35ce1a459927d8179d08) by [@ryancat](https://github.com/ryancat)) +- Fixes android build error when compiling as library ([c34ef5841c](https://github.com/facebook/react-native/commit/c34ef5841cf3a63a9cc96add577d6bf6d52e4397) by [@nickfujita](https://github.com/nickfujita)) +- Cancel post touch process when new touch is received ([0368081858](https://github.com/facebook/react-native/commit/0368081858193d7c2537acd9080d11bb701ee98b) by [@ryancat](https://github.com/ryancat)) +- Improve rendering of images when resampled and corner radius applied ([f743bed657](https://github.com/facebook/react-native/commit/f743bed657591b078300a6519e3d68db542fd757) by [@javache](https://github.com/javache)) +- Fix transform when calculate overflowInset ([0975e96d53](https://github.com/facebook/react-native/commit/0975e96d53546ac05b2154352fe56e5d82e2a1f8) by [@ryancat](https://github.com/ryancat)) +- Fix ReactHorizontalScrollView contentOffset ([9f6f97151c](https://github.com/facebook/react-native/commit/9f6f97151c44a0f727c9dd938222be1860ecf3f9) by [@genkikondo](https://github.com/genkikondo)) +- Text Component does not announce disabled and disables click functionality when disabled ([7b2d8178b1](https://github.com/facebook/react-native/commit/7b2d8178b155f5f1b247614c46e5e20f31bbd438) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Fix StatusBar on Android API 30 ([9ed2df628d](https://github.com/facebook/react-native/commit/9ed2df628ddd410cc3383e68b0386471432445c0) by [@ieatfood](https://github.com/ieatfood)) +- Use root locale when converting string case. ([5341ad8962](https://github.com/facebook/react-native/commit/5341ad896245c40a00b6faead1b90d01aac58f8c) by [@halaei](https://github.com/halaei)) +- Fix DarkMode on Calendar DateTimePicker ([97064ae1fb](https://github.com/facebook/react-native/commit/97064ae1fbf84a8a6b653c02c5872191b7d2d622) by [@mdvacca](https://github.com/mdvacca)) +- Fix ScrollView contentOffset ([be260b9f47](https://github.com/facebook/react-native/commit/be260b9f479a3b55ee43d2959d2c49fd3c1eb4ac) by [@genkikondo](https://github.com/genkikondo)) +- Do not bundle libhermes.so or libjsc.so inside the React Native Android AAR ([fa85417179](https://github.com/facebook/react-native/commit/fa854171798e67b8a10820f77d7198315e1784ed) by [@cortinico](https://github.com/cortinico)) +- Enable hitSlop to be set using a single number. ([d682753244](https://github.com/facebook/react-native/commit/d682753244feba28c6a15c31966a3da075a090e6) by [@javache](https://github.com/javache)) +- Fix crash caused by Image.queryCache parsing null ([ae3d4f7008](https://github.com/facebook/react-native/commit/ae3d4f700843ae4cbb6927ee620095136d1abc3f) by [@skychx](https://github.com/skychx)) +- Fix NullPointerException when disaptching events ([fbeb51ef51](https://github.com/facebook/react-native/commit/fbeb51ef5133303a5cb71569507d44403ded3447) by [@mdvacca](https://github.com/mdvacca)) + +#### iOS specific + +- ScrollView's contentInsetAdjustmentBehavior is reset to Never at every reuse to avoid layout artifacts. ([28a65f4387](https://github.com/facebook/react-native/commit/28a65f438789c29309d6e7c58063a73ca721ef43)) +- Prevent Nullptr segfault in TurboModule init path ([7f3cc256b5](https://github.com/facebook/react-native/commit/7f3cc256b5bcbf2e64540ca69401f62ec6869f0e) by [@RSNara](https://github.com/RSNara)) +- Expose the extraData dict attached to JavaScript errors to the native ExceptionManager on iOS, similar to Android ([a65ae8eff6](https://github.com/facebook/react-native/commit/a65ae8eff6ec6f9ad283ac8e96f00802421a14da) by [@GijsWeterings](https://github.com/GijsWeterings)) +- `RCTLocalizationProvider` Fall back to input when no localization is available ([18196512db](https://github.com/facebook/react-native/commit/18196512db6b8b4469a5e1b098d8892ae72d743a) by [@robhogan](https://github.com/robhogan)) +- Update iOS LogBox to render its UIWindow with the key window's UIWindowScene ([d31d83f410](https://github.com/facebook/react-native/commit/d31d83f4109c167ec612058c805fd65f69b82476) by [@vincentriemer](https://github.com/vincentriemer)) +- Remove Gemfile.lock from template ([1907bd31f0](https://github.com/facebook/react-native/commit/1907bd31f066865aa1c5fe4ec88e98ee46448771) by [@danilobuerger](https://github.com/danilobuerger)) +- Fix `pod install` when `RCT-Folly` version has been updated. ([b2517c3bdc](https://github.com/facebook/react-native/commit/b2517c3bdccc3f9d935f4ee06f959d6ce8f27bbe) by [@fortmarek](https://github.com/fortmarek)) +- Fix usage of cocoapods with --project-directory flag and new arch ([2f813f873a](https://github.com/facebook/react-native/commit/2f813f873a1692044ea3461e59ca732a4d952300) by [@danilobuerger](https://github.com/danilobuerger)) +- Ensure LogBoxView is sized relative to the key window instead of the full screen ([84f8c9ad55](https://github.com/facebook/react-native/commit/84f8c9ad550f98295d2e718b4b1d6b1ac724b898) by [@vincentriemer](https://github.com/vincentriemer)) +- Improved template fastlane gitignore ([f43f05d292](https://github.com/facebook/react-native/commit/f43f05d292fd2fbdf3d5fdfd194ed81b0e346657) by [@danilobuerger](https://github.com/danilobuerger)) +- Set RCTView borderColor to UIColor ([267d36d0af](https://github.com/facebook/react-native/commit/267d36d0afb4b3713df9b679c2019c44ac6bcc3f) by [@danilobuerger](https://github.com/danilobuerger)) +- Fix action sheet callback invoked more than once on iPad ([8935d6e697](https://github.com/facebook/react-native/commit/8935d6e697dffb0971f5a8ee1dfbc580080de3e0) by [@janicduplessis](https://github.com/janicduplessis)) +- Resolve border platform color based on current trait collection ([9a35818797](https://github.com/facebook/react-native/commit/9a3581879764f3f1b2743905e3e54611e96bb618) by [@danilobuerger](https://github.com/danilobuerger)) +- Enable custom sound for local push notifications. ([eb19499484](https://github.com/facebook/react-native/commit/eb1949948406195c4c02c6041d07cba074ae820c)) +- Invoke registerForRemoteNotifications on main UI thread. ([3633a05299](https://github.com/facebook/react-native/commit/3633a05299d99b12acc5c3c056b977463df1924e)) +- Bump flipper pods to get arm64 catalyst slice ([f811da7cc2](https://github.com/facebook/react-native/commit/f811da7cc20cc49ca5c8d4e023d6c61e36e15dd1) by [@fortmarek](https://github.com/fortmarek)) +- Fix `pod install --project-directory=ios` failing when Hermes is enabled ([1b22e8a039](https://github.com/facebook/react-native/commit/1b22e8a039081887ffd450596d822bff975d6900), ([eb7cc85a91](https://github.com/facebook/react-native/commit/eb7cc85a9146d058694247178f03d57cc125c97a) by [@tido64](https://github.com/tido64)) +- Fix compilation warning in yoga ([52d8a797e7](https://github.com/facebook/react-native/commit/52d8a797e7a6be3fa472f323ceca4814a28ef596) by [@cuva](https://github.com/cuva)) +- Prevent deadlock when dispatching events from observers on the same thread. ([68fd1e5508](https://github.com/facebook/react-native/commit/68fd1e55085e871a854563721ee29ca698239607) by [@Pickleboyonline](https://github.com/Pickleboyonline)) +- In RCTSurfaceHostingComponent, access ckComponent from main queue to pass assertion ([1874c81003](https://github.com/facebook/react-native/commit/1874c81003b468554c227541fec5e29c4adfb82f) by [@p-sun](https://github.com/p-sun)) +- Fix modal redbox for onDismiss ([46f68aceb2](https://github.com/facebook/react-native/commit/46f68aceb20a10c95c92b5ffeb90f289b015a559) by [@HeyImChris](https://github.com/HeyImChris)) +- Attempt to fix crash during app termination ([9cd43340a7](https://github.com/facebook/react-native/commit/9cd43340a7e2443564c2ff5e8e85d37f6e1e47ef) by [@sammy-SC](https://github.com/sammy-SC)) + +### Security + +- Encode URL params in URLSearchParams.toString() ([1042a8012f](https://github.com/facebook/react-native/commit/1042a8012fb472bd5c882b469fe507dd6279d562) by [@sshic](https://github.com/sshic)) + + +## v0.68.2 + +### Changed + +- Bump used version of react-native-codegen to 0.0.17 ([dfda480a98](https://github.com/facebook/react-native/commit/dfda480a9888d95c542cea40f25e8e783565c1db) by [@cortinico](https://github.com/cortinico)) +- Bump react-native-codegen to 0.0.17 ([a5ddc2e165](https://github.com/facebook/react-native/commit/a5ddc2e16523ea336ffbecf7acfd4820469a29e7) by [@cortinico](https://github.com/cortinico)) + +### Fixed + +#### Android specific + +- Working around Long paths limitation on Windows ([62ef6f5fa1](https://github.com/facebook/react-native/commit/62ef6f5fa1ecb918bde130a6024b65afcd34c7e3) by [@mganandraj](https://github.com/mganandraj)) + +## v0.68.1 + +### Changed + +#### Android specific + +- Bump React Native Gradle plugin to 0.0.6 ([9573d7b84d](https://github.com/facebook/react-native/commit/9573d7b84d35233fbb39a4067cfef65490aa34a7) by [@cortinico](https://github.com/cortinico)) +- Don't require yarn for codegen tasks ([d5da70e17e](https://github.com/facebook/react-native/commit/d5da70e17e8c8210cd79a4d7b09c6a5ded4b5607) by [@danilobuerger](https://github.com/danilobuerger)) + +### Fixed + +- Fix dynamic_cast (RTTI) by adding key function to ShadowNodeWrapper and related classes ([58a2eb7f37](https://github.com/facebook/react-native/commit/58a2eb7f37c2dc27ad3575618778ad5b23599b27) by [@kmagiera](https://github.com/kmagiera)) +- Pin use-subscription to < 1.6.0 ([5534634892](https://github.com/facebook/react-native/commit/5534634892f47a3890e58b661faa2260373acb25) by [@danilobuerger](https://github.com/danilobuerger)) + +#### Android specific + +- Use NDK 23 only for Windows users. ([e48a580080](https://github.com/facebook/react-native/commit/e48a580080bdae58b375f30fbcf8a83cc1915b2f) by [@cortinico](https://github.com/cortinico)) +- Improve support for Android users on M1 machine ([4befd2a29c](https://github.com/facebook/react-native/commit/4befd2a29cb94b026d9c048a041aa9f1817295b5) by [@cortinico](https://github.com/cortinico)) +- Template: Specify abiFilters if enableSeparateBuildPerCPUArchitecture is not set. ([5dff920177](https://github.com/facebook/react-native/commit/5dff920177220ae5f4e37c662c63c27ebf696c83) by [@cortinico](https://github.com/cortinico)) +- Fix for building new architecture sources on Windows ([5a8033df98](https://github.com/facebook/react-native/commit/5a8033df98296c941b0a57e49f2349e252339bf9) by [@mganandraj](https://github.com/mganandraj)) + +## v0.68.0 + +### Breaking Changes + +- CI moved to Node 16. ([f1488db109](https://github.com/facebook/react-native/commit/f1488db109d13e748b071c02b40e90cdca1cc79d) by [@kelset](https://github.com/kelset)). + This change enforces Node >= 14 for React Native builds. +- Bump Android Gradle Plugin to 7.0.1. ([272cfe5d13](https://github.com/facebook/react-native/commit/272cfe5d1371c38a281cf3883ff0254a8d3505a3) by [@dulmandakh](https://github.com/dulmandakh)) + This version of Android Gradle plugin enforces JDK 11 for Android builds. Do not upgrade to AGP 7.1 as it is not supported by this version of react-native. +- Removed `fallbackResource` from `RCTBundleURLProvider` API ([0912ee179c](https://github.com/facebook/react-native/commit/0912ee179c210fb6b2ed9afbb3f2fbc5fb8a2bb3)) by [@philIip](https://github.com/philIip) + +### New Architecture + +*If you are interested in enabling the new architecture, please refer to [the dedicated documentation](https://reactnative.dev/docs/next/new-architecture-intro).* + +- Do not include Facebook license on users codegen'd code ([450967938a](https://github.com/facebook/react-native/commit/450967938ab25c4dabb9d5ecd9f7b57afb1c78dd) by [@cortinico](https://github.com/cortinico)) + +#### Android specific + +- Setup a `newArchEnabled` property to Opt-in the New Architecture in the template ([8d652fba4c](https://github.com/facebook/react-native/commit/8d652fba4ce07256784a1b7e86713c810336856d) by [@cortinico](https://github.com/cortinico)) + +#### iOS specific + +- Add fabric option to the default app template. ([2e9a376c84](https://github.com/facebook/react-native/commit/2e9a376c8488d1fb11c0b5d604137712321fd90d) by [@sota000](https://github.com/sota000)) +- Add turbo module support in the default app template. ([8ec0e6919c](https://github.com/facebook/react-native/commit/8ec0e6919c5fab118c8b54538860ee36009bfaa7) by [@sota000](https://github.com/sota000)) +- Rename the new architecture flag to RCT_NEW_ARCH_ENABLED. ([c0c5439959e](https://github.com/facebook/react-native/commit/c0c5439959e21d7806178bb9139c2cd19b857506) by [@sota000](https://github.com/sota000)) + +### Added + +- Create @fb-tools-support/yarn package ([7db294d6d5](https://github.com/facebook/react-native/commit/7db294d6d5b00a38f305dd52be3e0961f35695c8) by [@motiz88](https://github.com/motiz88)) +- Support string color values in Animated.Color ([d3a0c4129d](https://github.com/facebook/react-native/commit/d3a0c4129d6a5a7beced4e9aa62b2da4e3f4fed4)) +- New Animated.Color node ([ea90a76efe](https://github.com/facebook/react-native/commit/ea90a76efef60df0f46d29228289f8fc1d26f350)) +- Added linter warning config for unstable nested components ([988fefc44d](https://github.com/facebook/react-native/commit/988fefc44d39957e8c5e1eecb02dfd1ce119f34c) by [@javache](https://github.com/javache)) +- Option to supply `platformConfig` to NativeAnimated ([4a227ce2ab](https://github.com/facebook/react-native/commit/4a227ce2ab3f8c181150461ab28b831979093db0) by [@rozele](https://github.com/rozele)) +- Animated.event can be used to extract values with numeric keys from native events ([b2105711a0](https://github.com/facebook/react-native/commit/b2105711a0b90859f8e3fc1aaec4998e252c2d14) by [@javache](https://github.com/javache)) +- Adds a setSelection imperative method to TextInput ([771ca921b5](https://github.com/facebook/react-native/commit/771ca921b59cc3b3fd12c8fe3b08ed150bcf7a04) by [@lyahdav](https://github.com/lyahdav)) +- Native-only prop to optimize text hit testing on some RN platforms ([f3bf2e4f51](https://github.com/facebook/react-native/commit/f3bf2e4f51897f1bb71e37002c288ebf3b23cf78) by [@rozele](https://github.com/rozele)) + +#### Android specific + +- Added DoNotStripAny proguard rules ([48318b1542](https://github.com/facebook/react-native/commit/48318b1542910b939ab977c0bc82e98f098abe50) by [@ShikaSD](https://github.com/ShikaSD)) +- Add new API in ScrollView and HorizontalScrollView to process pointerEvents prop. ([48f6967ae8](https://github.com/facebook/react-native/commit/48f6967ae88100110160e1faf03e6c0d37e404bd) by [@ryancat](https://github.com/ryancat)) +- Add `accessibilityLabelledBy` props ([36037fa81b](https://github.com/facebook/react-native/commit/36037fa81bbdcc460057e7e7cf608cd364ca48a6) by [@grgr-dkrk](https://github.com/grgr-dkrk)) +- Added missing constructor to WritableNativeArray ([c68c47d2ba](https://github.com/facebook/react-native/commit/c68c47d2bafa8e8e25b534d6cdd1a63bc77a1cf4) by [@piaskowyk](https://github.com/piaskowyk)) +- Add new API for custom fling animator to provide predicted travel distance for its fling animation. ([fe6277a30d](https://github.com/facebook/react-native/commit/fe6277a30d3ec19e4772991e30ae20c3a9cfe565) by [@ryancat](https://github.com/ryancat)) +- Adding new API `onChildEndedNativeGesture` to the RootView interface to let its implementations notify the JS side that a child gesture is ended. ([9b33c31ee0](https://github.com/facebook/react-native/commit/9b33c31ee024bae30e441107f838e1b5044525ba) by [@ryancat](https://github.com/ryancat)) +- Make the `reactNativeArchitectures` property more discoverable ([0f39a1076d](https://github.com/facebook/react-native/commit/0f39a1076dc154995a2db79352adc36452f46210) by [@cortinico](https://github.com/cortinico)) +- Added `isAccessibilityServiceEnabled` to get if accessibility services are enabled ([c8b83d4e0b](https://github.com/facebook/react-native/commit/c8b83d4e0b33c2af45093f7b2262ee578ece2faf) by [@grgr-dkrk](https://github.com/grgr-dkrk)) +- Add bundleForVariant option ([d2c10da5d5](https://github.com/facebook/react-native/commit/d2c10da5d5687833545691f281473381e4466c2e) by [@grit96](https://github.com/grit96)) +- Add ACCEPT_HANDOVER, ACTIVITY_RECOGNITION, ANSWER_PHONE_CALLS, READ_PHONE_NUMBERS & UWB_RANGING to PermissionsAndroid ([4b25a0aaa0](https://github.com/facebook/react-native/commit/4b25a0aaa077caf9c437bcfeef8a226eda5a102e) by [@iBotPeaches](https://github.com/iBotPeaches)) + +#### iOS specific + +- Add new argument to announceForAccessibility to allow queueing on iOS ([4d1357918a](https://github.com/facebook/react-native/commit/4d1357918a4dcb331ccea2140699f487ca45ea30) by [@peterc1731](https://github.com/peterc1731)) +- Add volta support to find-node.sh ([765844055b](https://github.com/facebook/react-native/commit/765844055ba0d02262a11114bad5da67e935d8df) by [@liamjones](https://github.com/liamjones)) +- Support fnm when detecting node binary ([c9e4d34885](https://github.com/facebook/react-native/commit/c9e4d3488578d65e55198ad597252a2ac8cc5f73) by [@MoOx](https://github.com/MoOx)) +- Find-node.sh now respects .nvmrc ([35bcf934b1](https://github.com/facebook/react-native/commit/35bcf934b186e581d100d43e563044300759557f) by [@igrayson](https://github.com/igrayson)) +- Add macros to be able to stub C functions in tests ([749a9207b6](https://github.com/facebook/react-native/commit/749a9207b6f0545c03ca83efbda7971ffd4d2d57) by [@philIip](https://github.com/philIip)) + + +### Changed + +- Bump RN CLI to v7.0.3, and Metro to 67 ([848ba6fb1d](https://github.com/facebook/react-native/commit/848ba6fb1db81bbb44efd373af9e81f31f227aef) by [@kelset](https://github.com/kelset)) and ([df2e934a69](https://github.com/facebook/react-native/commit/df2e934a697b5b207053db3bbcf71492932a6062) by [@kelset](https://github.com/kelset)) +- Upgraded react-devtools-core dependency to 4.23.0 ([1cc217d5ef](https://github.com/facebook/react-native/commit/1cc217d5effdbee4cf2f64063a443ecb331673d4) by [@bvaughn](https://github.com/bvaughn)) +- Bump Flipper to 0.125.0 ([50057158ca](https://github.com/facebook/react-native/commit/50057158ca32842d70160541e3cb5d4bd512f8f5) by [@cortinico](https://github.com/cortinico)) +- Export Flow type for deceleration rate for use in other files to keep deceleration rate prop values consistently typed ([9b0ed920ef](https://github.com/facebook/react-native/commit/9b0ed920ef087c4c18504adacf9d4f557812cf1b)) +- Upgrade deprecated-react-native-prop-types dependency ([badd30885f](https://github.com/facebook/react-native/commit/badd30885fb999124b6b54b3fb016edbd988c16b) by [@chiaramooney](https://github.com/chiaramooney)) +- Improved error message in react.gradle ([7366a866b3](https://github.com/facebook/react-native/commit/7366a866b381db6fc5615153e7788aa4828cfd96) by [@vonovak](https://github.com/vonovak)) +- Upgraded packages to the latest versions for ESLint v7. ([cf763cdf81](https://github.com/facebook/react-native/commit/cf763cdf816e1cad20caf2347c54bc96c7f6dd47) by [@yungsters](https://github.com/yungsters)) +- Updated the links for the discussions and changelog ([daf37a1fce](https://github.com/facebook/react-native/commit/daf37a1fce43403e6320e1e3023e86fd1b970bdf) by [@MikeyAlmighty](https://github.com/MikeyAlmighty)) +- XMLHttpRequest.getAllResponseHeaders() now returns headers with names lowercased and sorted in ascending order, as per specification ([b2415c4866](https://github.com/facebook/react-native/commit/b2415c48669391ee1ab7c6450748c4d91097a666) by [@ascherkus](https://github.com/ascherkus)) +- Bump react-native-codegen to 0.0.9 ([e3a71b019f](https://github.com/facebook/react-native/commit/e3a71b019fa78e2b4b3454ccc59ea9c8cc543b29) by [@cortinico](https://github.com/cortinico)) +- Accessing `Image.propTypes`, `Text.propTypes`, `TextInput.propTypes`, `ColorPropType`, `EdgeInsetsPropType`, `PointPropType`, or `ViewPropTypes` now emits a deprecation warning. ([3f629049ba](https://github.com/facebook/react-native/commit/3f629049ba9773793978cf9093c7a71af15e3e8d) by [@yungsters](https://github.com/yungsters)) +- Bump `core-workflow-apply-version-label` version ([e973b3afc2](https://github.com/facebook/react-native/commit/e973b3afc274f892a0e5a6fdea9004dc5d84eb2b) by [@lucasbento](https://github.com/lucasbento)) +- Add `vendor/bundle` into .gitignore template ([2f67f5d68b](https://github.com/facebook/react-native/commit/2f67f5d68b17010c49f2996a788fe68c1fe2e9f6) by [@MoOx](https://github.com/MoOx)) + +#### Android specific + +- Add allowsEdgeAntialiasing on views with rotations or skew transforms ([e6a3410afe](https://github.com/facebook/react-native/commit/e6a3410afe7d9a4cecf3db0a95503d2ff05bb862)) +- Bump Kotlin version to 1.6.10 ([d0f0234656](https://github.com/facebook/react-native/commit/d0f0234656dc981b422d1e9aa0885afd5fd29879) by [@AKB48](https://github.com/AKB48)) +- Bump Soloader to 0.10.3 ([f45889ef95](https://github.com/facebook/react-native/commit/f45889ef95ec694520e91b0032e591a087e088e5) by [@osartun](https://github.com/osartun)) +- Bump Gradle to 7.3 ([c180627ac7](https://github.com/facebook/react-native/commit/c180627ac7e5e155707b3c9433c4582839e1820e) by [@dulmandakh](https://github.com/dulmandakh)) +- Bump Android compile and target SDK to 31 ([00ac034353](https://github.com/facebook/react-native/commit/00ac034353cbc867991bf79cb1dd103353f47126) by [@ShikaSD](https://github.com/ShikaSD)) +- Use side-by-side NDK for Android ([bd7caa64f5](https://github.com/facebook/react-native/commit/bd7caa64f5d6ee5ea9484e92c3629c9ce711f73c) by [@cortinico](https://github.com/cortinico)) +- Leverage Gradle implicit dependency substitution for Gradle Plugin ([0fccbd53af](https://github.com/facebook/react-native/commit/0fccbd53af86083a8742a33282dc183d07eb27a2) by [@cortinico](https://github.com/cortinico)) +- Remove unused import of JMessageQueueThread.h ([705236e363](https://github.com/facebook/react-native/commit/705236e3637e4f80e5fa4bd7234df9f1e14a5d3d) by [@sshic](https://github.com/sshic)) +- Made `MessageQueueThread#runOnQueue` return a boolean. Made `MessageQueueThreadImpl#runOnQueue` return false when the runnable is not submitted. ([89faf0c9a8](https://github.com/facebook/react-native/commit/89faf0c9a87f6de68ca416d10566dbcbe80d9450)) +- Assume *.ktx assets are packaged as Android drawables ([cb610ddca7](https://github.com/facebook/react-native/commit/cb610ddca79fe29b88568545ab011671fc392c9a) by [@motiz88](https://github.com/motiz88)) +- Add ViewConfigs to support onEnter/onExit/onMove events ([44143b50fd](https://github.com/facebook/react-native/commit/44143b50fdcafe22caa43d76ec3210132ce3af21) by [@mdvacca](https://github.com/mdvacca)) +- Let react_native_assert really abort the app ([2ae06df58f](https://github.com/facebook/react-native/commit/2ae06df58f5f5eaf4386c14d28af25b643401bf3) by [@cortinico](https://github.com/cortinico)) +- Bugfix for multiple shadow threads rendered at the same time, small probability crash. ([9d71b166a6](https://github.com/facebook/react-native/commit/9d71b166a6c9d9afec7186c6a33aedc6975aa43c) by [@chenmo187](https://github.com/chenmo187)) +- RootView's onChildStartedNativeGesture now takes the child view as its first argument ([03e513de41](https://github.com/facebook/react-native/commit/03e513de41bf60f071eacbbb9604c83605abf625) by [@javache](https://github.com/javache)) +- Add ReactInstanceEventListenerV2 for migration ([ce74aa4ed3](https://github.com/facebook/react-native/commit/ce74aa4ed335d4c36ce722d47937b582045e05c4) by [@sshic](https://github.com/sshic)) +- Improved logic of findTargetPathAndCoordinatesForTouch ([dfe42d6b75](https://github.com/facebook/react-native/commit/dfe42d6b75005f519c0e2c87c75e7886dce3345c) by [@javache](https://github.com/javache)) +- Set a resolution strategy for com.facebook.react:react-native when on New Architecture ([e695bc0bb5](https://github.com/facebook/react-native/commit/e695bc0bb50fc1c712e9862ed8fe4e7cc6619fae) by [@cortinico](https://github.com/cortinico)) +- Make hermes-executor-common a static lib ([b2cf24f41c](https://github.com/facebook/react-native/commit/b2cf24f41cb5f15653b34d396ef2a1c90defdf43) by [@janicduplessis](https://github.com/janicduplessis)) +- Static link for hermes-inspector ([20b0eba581](https://github.com/facebook/react-native/commit/20b0eba581a00e5e7e300f6377379b836617c147) by [@janicduplessis](https://github.com/janicduplessis)) + +#### iOS specific + +- Don't capitalize the first letter of a word that is starting by a number ([8b5a5d4645](https://github.com/facebook/react-native/commit/8b5a5d4645136ef3d6ee043348e583cbbac87ee3) by [@MaeIg](https://github.com/MaeIg)) +- updated `jsBundleURLForBundleRoot:fallbackResource` to `jsBundleURLForBundleRoot:` ([aef843bfe6](https://github.com/facebook/react-native/commit/aef843bfe60bda6bcc98d3fb4a6c295c9f4b66e3) by [@philIip](https://github.com/philIip)) +- Remove iOS 11 availability check ([9b059b6709](https://github.com/facebook/react-native/commit/9b059b67092f4e7d568867a2b3a51dfd7c6f1db6) by [@ken0nek](https://github.com/ken0nek)) +- Refactor: Assign string label to each case in RCTPLTag enum for startup performance logging ([60e60a9b3d](https://github.com/facebook/react-native/commit/60e60a9b3d42d342eaf5ddee4841b121f6474a6c) by [@p-sun](https://github.com/p-sun)) +- IOS Ruby Updates ([1e6add1a43](https://github.com/facebook/react-native/commit/1e6add1a43355bb88c57400a7420a656966bef97) by [@barbieri](https://github.com/barbieri)) +- Update Flipper pods to support re-enable macCatalyst ([2a5265dff7](https://github.com/facebook/react-native/commit/2a5265dff7e654f57b43335804840692313f2a56) by [@mikehardy](https://github.com/mikehardy)) +- Apple Silicon builds of glog & Flipper-Glog ([274c617f5b](https://github.com/facebook/react-native/commit/274c617f5bda263ff29115b3dcc013e47085a78d) by [@rayzr522](https://github.com/rayzr522)) + +### Fixed + +- Fix error "mockModal is not a function" ([507b05f4c0](https://github.com/facebook/react-native/commit/507b05f4c02b46109f483a2b79c924a775fd7bd3) by [@AntoineDoubovetzky](https://github.com/AntoineDoubovetzky)) +- Fixes execution of animation when a toValue of AnimatedValue is used. ([8858c21124](https://github.com/facebook/react-native/commit/8858c2112421be5212c024f9e404e66437a41389)) +- Fix RN version syntax to match new nightly build structure. ([3d1d4ee457](https://github.com/facebook/react-native/commit/3d1d4ee4572600425b8eb5d0d6512bb0d2a6ea44) by [@chiaramooney](https://github.com/chiaramooney)) +- Fix typo in _updateBottomIfNecessary function on KeyboardAvoidingView component ([0cc80b4d0c](https://github.com/facebook/react-native/commit/0cc80b4d0cb78a835977dbe5100262a16882bbea) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Fix: Removes interface only check from third party components GenerateThirdPartyFabricComponentsProvider ([3e6902244a](https://github.com/facebook/react-native/commit/3e6902244a0d189261dbbe327296db1349e37410) by [@Ubax](https://github.com/Ubax)) +- Set CxxModules' Instance before retrieving their Method vector. ([1d45b20b6c](https://github.com/facebook/react-native/commit/1d45b20b6c6ba66df0485cdb9be36463d96cf182) by [@JunielKatarn](https://github.com/JunielKatarn)) +- AnimatedValue.__detach should store getValue result with offset deducted ([fe53cae954](https://github.com/facebook/react-native/commit/fe53cae954b37528eeaa1258ac0060c4298473bb) by [@rozele](https://github.com/rozele)) +- AnimatedValue.stopAnimation callback with correct value for NativeAnimated ([8ba771c3dd](https://github.com/facebook/react-native/commit/8ba771c3ddc00b1499e95a2812b4cd5ac904c8df) by [@rozele](https://github.com/rozele)) +- ESLint no-undef rule clashing with TypeScript compiler for TS files ([ae67c5ac45](https://github.com/facebook/react-native/commit/ae67c5ac45a8044fc1db66aee8eae6e881d660e4) by [@fiznool](https://github.com/fiznool)) +- ESLint `no-shadow` rule returning false positive for TypeScript enums ([722a0ff6f8](https://github.com/facebook/react-native/commit/722a0ff6f88bed4d54579a2b8bc574e87948187f) by [@fiznool](https://github.com/fiznool)) +- Fix support for custom port ([b399c2e3d1](https://github.com/facebook/react-native/commit/b399c2e3d10fa521dbec87243d3e96f6bca7df1e) by [@enniel](https://github.com/enniel)) +- `onLayout` prop is handled correctly in `` ([9c5e177a79](https://github.com/facebook/react-native/commit/9c5e177a79c64c77f281ce727538973e8222e975)) +- Modal accepts a testID but didn't forward it to RCTModalHostView, therefore not making it show up for e2e tests depending on viewhierarchy. ([5050e7eaa1](https://github.com/facebook/react-native/commit/5050e7eaa17cb417baf7c20eb5c4406cce6790a5) by [@GijsWeterings](https://github.com/GijsWeterings)) +- Remove unused and incorrect type declarations in WebSocketInterceptor ([91728e2266](https://github.com/facebook/react-native/commit/91728e2266375b954302ba0cd4b5daf641aefc23) by [@mischnic](https://github.com/mischnic)) +- Complete missing Flow declarations in URL ([98abf1b02f](https://github.com/facebook/react-native/commit/98abf1b02f64ad40d523335e677a2ede15b3650d) by [@mischnic](https://github.com/mischnic)) +- Pressable not passing hover props and event handlers to PressabilityConfig ([1b30dd074b](https://github.com/facebook/react-native/commit/1b30dd074b579c2ae138a1111d07ddb56761315d) by [@Saadnajmi](https://github.com/Saadnajmi)) +- Composite animations will now be ran immediately when the app is in testing mode ([b03e824c52](https://github.com/facebook/react-native/commit/b03e824c52123219a5c8fbd89473391bf0bc31c8) by [@javache](https://github.com/javache)) +- Remove duplicate class members ([c0e489b729](https://github.com/facebook/react-native/commit/c0e489b7293f15858cb706f1b8587600e429af28) by [@bradzacher](https://github.com/bradzacher)) +- Fix: Use same implementation for `performance.now()` on iOS and Android ([1721efb54f](https://github.com/facebook/react-native/commit/1721efb54ff9cc4f577b5ae27f13fcf56801a92c) by [@mrousavy](https://github.com/mrousavy)) + +#### Android specific + +- Enable cliPath to have an absolute path value ([5d560ca99f](https://github.com/facebook/react-native/commit/5d560ca99ff7220de11d2d76dbe77d73990894a8) by [@Krisztiaan](https://github.com/Krisztiaan)) +- Make sure configureNdkBuild* tasks are depending on preBuild ([2fdbf6a10f](https://github.com/facebook/react-native/commit/2fdbf6a10fe67fa3209a51a1105a97c16991f561) by [@cortinico](https://github.com/cortinico)) +- Added a null check to native.value in Switch to fix https://github.com/facebook/react-native/issues/32594 ([8d50bf1133](https://github.com/facebook/react-native/commit/8d50bf113352a6ccdf74c979e1022c6c2ccf6e56) by [@jonathanmos](https://github.com/jonathanmos)) +- Fix overflowInset calculation by using transform values ([8aa87814f6](https://github.com/facebook/react-native/commit/8aa87814f62e42741ebb01994796625473c1310f) by [@ryancat](https://github.com/ryancat)) +- Add missing sources jar into published android artifacts ([384e1a0c7b](https://github.com/facebook/react-native/commit/384e1a0c7bc50d2aab5b59bcedcea5a3e98f1659) by [@Kudo](https://github.com/Kudo)) +- Fix math for detecting if children views are in parent's overflowInset area. ([45244ebce2](https://github.com/facebook/react-native/commit/45244ebce228dfbc3412670e64c11491ba8d8c47) by [@ryancat](https://github.com/ryancat)) +- Fixed empty screen after retrying a BundleDownloader failure in dev mode ([c8d823b9bd](https://github.com/facebook/react-native/commit/c8d823b9bd9619dfa1f5851af003cc24ba2e8830) by [@samkline](https://github.com/samkline)) +- Fix crash from ScrollView that occurs while reporting an error from JS ([2151d11527](https://github.com/facebook/react-native/commit/2151d1152719a230565165f1a8dcfab172689eb3) by [@JoshuaGross](https://github.com/JoshuaGross)) +- Enable hitSlop to be set using a single number. ([589b129581](https://github.com/facebook/react-native/commit/589b129581903a737a64e14eab3f2e29620831d5) by [@javache](https://github.com/javache)) +- Fix fling and snap with recycler viewgroup where fling to the end of scrollable distance when it goes over current rendered children views. ([ead7b97944](https://github.com/facebook/react-native/commit/ead7b97944522e3066ceb2bd50c63c268c961277) by [@ryancat](https://github.com/ryancat)) +- Fixed edge case for quick small scrolls causing unexpected scrolling behaviors. ([f70018b375](https://github.com/facebook/react-native/commit/f70018b37532622f08f20b2c51cdbfca55d730ea) by [@ryancat](https://github.com/ryancat)) +- Fix crash on ReactEditText with AppCompat 1.4.0 ([e21f8ec349](https://github.com/facebook/react-native/commit/e21f8ec34984551f87a306672160cc88e67e4793) by [@cortinico](https://github.com/cortinico)) +- Do not .lowerCase the library name when codegenerating TurboModule Specs ([28aeb7b865](https://github.com/facebook/react-native/commit/28aeb7b8659b38ee3a27fae213c4d0800f4d7e31) by [@cortinico](https://github.com/cortinico)) +- Enable hitSlop to be set using a single number. ([a96bdb7154](https://github.com/facebook/react-native/commit/a96bdb7154b0d8c7f43977d8a583e8d2cbdcb795) by [@javache](https://github.com/javache)) +- Updated TextInput prop types to accomodate for new autoComplete values ([9eb0881c8f](https://github.com/facebook/react-native/commit/9eb0881c8fecd0e974b1cb9f479bad3075854340) by [@TheWirv](https://github.com/TheWirv)) +- Don't reconstruct app components https://github.com/facebook/react-native/issues/25040 ([fc962c9b6c](https://github.com/facebook/react-native/commit/fc962c9b6c4bf9f88decbe014ab9a9d5c1cf51bc) by [@Somena1](https://github.com/Somena1)) +- Do NOT skip the first child view in the scroll view group when measuring the lower and upper bounds for snapping. ([61e1b6f86c](https://github.com/facebook/react-native/commit/61e1b6f86cf98d8a74eeb9353143fe0c624fe6e6) by [@ryancat](https://github.com/ryancat)) +- Fix crash when a Switch is initialised with both backgroundColor and thumbColor. ([456cf3db14](https://github.com/facebook/react-native/commit/456cf3db14c443c483d63aa97c88b45ffd25799b) by [@smarki](https://github.com/smarki)) +- Fix devDisabledIn not working with multiple productFlavors ([055ea9c7b7](https://github.com/facebook/react-native/commit/055ea9c7b7dea030ef16da72d1f6ecb5d95ac468) by [@grit96](https://github.com/grit96)) +- Revert `ReactScrollView` to use `Context` instead of `ReactContext` in the constructor to be less restrictive. ([7b77cc637e](https://github.com/facebook/react-native/commit/7b77cc637e1faf4a2b134853f8415f277d0decdc) by [@ryancat](https://github.com/ryancat)) +- Fix onPress event for nested Text in RN Android ([e494e4beb6](https://github.com/facebook/react-native/commit/e494e4beb6a124008fd116178cbc38335bd87809) by [@mdvacca](https://github.com/mdvacca)) +- Fix enableVmCleanup not working for apps with product flavors ([a2b5e4cd82](https://github.com/facebook/react-native/commit/a2b5e4cd825a358419cef1e3823b72215b689686) by [@cortinico](https://github.com/cortinico)) +- Prevent NPE on ThemedReactContext ([f1b5fe1d3e](https://github.com/facebook/react-native/commit/f1b5fe1d3ea49294d8c89accfa27d76a1a97ccea) by [@sshic](https://github.com/sshic)) +- fix: jvm 11 error message from ReactPlugin.kt and react.gradle ([4e947ecb2d](https://github.com/facebook/react-native/commit/4e947ecb2dabfa0226af7f859c828847b4d891c0) by [@nomi9995](https://github.com/nomi9995)) + +#### iOS specific + +- ScrollView: Respect `contentInset` when animating new items with `autoscrollToTopThreshold`, make `automaticallyAdjustKeyboardInsets` work with `autoscrollToTopThreshold` (includes vertical, vertical-inverted, horizontal and horizontal-inverted ScrollViews) ([49a1460a37](https://github.com/facebook/react-native/commit/49a1460a379e3a71358fb38888477ce6ea17e81a) by [@mrousavy](https://github.com/mrousavy)) +- Prevent RCTConvert error for allowed null blob types ([e1b698c5f2](https://github.com/facebook/react-native/commit/e1b698c5f2b1d689fb3940f8c6a3e298d381ea3a) by [@habovh](https://github.com/habovh)) +- Migrate ScreenshotManager from NativeModule to TurboModule ([b13e41d98e](https://github.com/facebook/react-native/commit/b13e41d98e818279d1941f3425707d3c0ce407fc) by [@p-sun](https://github.com/p-sun)) +- Fix usage of cocoapods with --project-directory flag and new arch ([9e7d91f2fc](https://github.com/facebook/react-native/commit/9e7d91f2fc4d576b8fba81304a24e50134da93d6) by [@danilobuerger](https://github.com/danilobuerger)) +- Post RCTContentDidAppearNotification with new arch ([75105e692c](https://github.com/facebook/react-native/commit/75105e692c2be9bd192089a6a6ffde7572ee1ce1) by [@danilobuerger](https://github.com/danilobuerger)) +- Remove absolute paths from pods project ([42b01a32a1](https://github.com/facebook/react-native/commit/42b01a32a137f18ae9fd2f00914f2edb0e107421) by [@danilobuerger](https://github.com/danilobuerger)) +- Respect RCTSetDefaultFontHandler chosen font ([89efa1a0c1](https://github.com/facebook/react-native/commit/89efa1a0c1b633bf9edee66583800ad3fc54ce63) by [@danilobuerger](https://github.com/danilobuerger)) +- Fixed duplicated UUIDs problem during pod install phase. ([f595a4e681](https://github.com/facebook/react-native/commit/f595a4e681e75aaf737b6582f69855d76a1f33dd)) +- Fix `Time.h` patch not being applied when running `pod install --project-directory=ios` ([60cef850bd](https://github.com/facebook/react-native/commit/60cef850bd3fd12c32ee1196bd19a559592d1465) by [@tido64](https://github.com/tido64)) +- Fix WebSocket control frames having payloads longer than 125 bytes ([86db62b7a8](https://github.com/facebook/react-native/commit/86db62b7a8b28ac82dd0a0627a8b6c351875f682) by [@asmeikal](https://github.com/asmeikal)) +- Stop RedBox from appearing for LogBox handled errors ([9d2df5b8ae](https://github.com/facebook/react-native/commit/9d2df5b8ae95b3cfeae26f64bd1d50bd2b0bbae9) by [@liamjones](https://github.com/liamjones)) +- Enable hitSlop to be set using a single number. ([3addafa525](https://github.com/facebook/react-native/commit/3addafa5257ade685216900bebbad8c35e24e124) by [@javache](https://github.com/javache)) +- Fix `__apply_Xcode_12_5_M1_post_install_workaround` failing when one of the Pods has no IPHONEOS_DEPLOYMENT_TARGET set ([9cd4092336](https://github.com/facebook/react-native/commit/9cd40923362ff717a722f8f36c8250a29a5142b7) by [@Yonom](https://github.com/Yonom)) +- This is a quick speculative fix since we know `CFRunLoopPerformBlock` does not push/pop an autorelease pool. ([3fff164dfa](https://github.com/facebook/react-native/commit/3fff164dfa1c97f69b1701e974effc92a94152d6) by [@christophpurrer](https://github.com/christophpurrer)) +- Fixed RCTImageLoaderTests ([1542f83527](https://github.com/facebook/react-native/commit/1542f835273c08776b960929b5aa7cefbd225971) by [@philIip](https://github.com/philIip)) +- Fix Rosetta2 CocoaPods warning on Apple Silicon ([e918362be3](https://github.com/facebook/react-native/commit/e918362be3cb03ae9dee3b8d50a240c599f6723f) by [@oblador](https://github.com/oblador)) +- Fix `pod install --project-directory=ios` failing due to wrong path to `React-Codegen` ([ebb26cf2e4](https://github.com/facebook/react-native/commit/ebb26cf2e420616c8bf01a5148ca4f8419b238d3) by [@tido64](https://github.com/tido64)) + +### Deprecated + +#### Android specific + +- Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir` ([8bc324fd34](https://github.com/facebook/react-native/commit/8bc324fd34337ab159e2e21e213a6c5b06c548da) by [@cortinico](https://github.com/cortinico)) + + +### Removed + +- DeprecatedPropTypes (deep-link) modules removed from React Native. ([23717c6381](https://github.com/facebook/react-native/commit/23717c6381a41b1c5f189376bfa5bc73c7a4da87) by [@yungsters](https://github.com/yungsters)) +- `accessibilityStates` no longer passed through to RCTView. ([1121ed94ab](https://github.com/facebook/react-native/commit/1121ed94ab470be27207b0c8dbae5d19860c08da) by [@luism3861](https://github.com/luism3861)) + +#### iOS specific + +- Remove RCTUIManagerObserver from RCTNativeAnimatedTurboModule ([e9ed115bab](https://github.com/facebook/react-native/commit/e9ed115babbc82968380dae22fa928d4ce3cd6da) by [@p-sun](https://github.com/p-sun)) + + +## v0.67.4 + +### Fixed + +#### Android specific + +- Added a null check to native.value in Switch to fix https://github.com/facebook/react-native/issues/32594 ([8d50bf1133](https://github.com/facebook/react-native/commit/8d50bf113352a6ccdf74c979e1022c6c2ccf6e56) by [@jonathanmos](https://github.com/jonathanmos)) + +## v0.67.3 + +### Fixed + +#### Android specific + +- Text with adjustsFontSizeToFit changes the text layout infinitely ([c1db41f060](https://github.com/facebook/react-native/commit/c1db41f060908e6ab001aaace7c20c610056f59a)) + +#### iOS specific + +- Fix a broken input for the Korean alphabet in TextInput ([1a83dc36ce](https://github.com/facebook/react-native/commit/1a83dc36ce0af33ac7a3c311354fce4bfa5ba1a3) by [@bernard-kms](https://github.com/bernard-kms)) + +## v0.67.2 + +### Fixed + +- Fix error "mockModal is not a function" ([507b05f4c0](https://github.com/facebook/react-native/commit/507b05f4c02b46109f483a2b79c924a775fd7bd3) by [@AntoineDoubovetzky](https://github.com/AntoineDoubovetzky)) + +#### Android specific + +- Fix potential crash if ReactRootView does not have insets attached. ([6239e2f5ce](https://github.com/facebook/react-native/commit/6239e2f5ce82f7c2e683eb4699b9ce3ff1b58ac5) by [@enahum](https://github.com/enahum)) +- Upgrading OkHttp from 4.9.1 to 4.9.2 to fix CVE-2021-0341. ([e896d21](https://github.com/facebook/react-native/commit/e896d21ced3c0c917c2fc0044d2b93b44df9a081) by [@owjsub](https://github.com/owjsub)) + +#### iOS specific + +- Fix `Time.h` patch not being applied when running `pod install --project-directory=ios` ([60cef850bd](https://github.com/facebook/react-native/commit/60cef850bd3fd12c32ee1196bd19a559592d1465) by [@tido64](https://github.com/tido64)) +- Find-node.sh now respects .nvmrc ([35bcf934b1](https://github.com/facebook/react-native/commit/35bcf934b186e581d100d43e563044300759557f) by [@igrayson](https://github.com/igrayson)) + +## v0.67.1 + +### Fixed + +#### Android specific + +- Do not remove libjscexecutor.so from release builds ([574a773f8f](https://github.com/facebook/react-native/commit/574a773f8f55fe7808fbb672066be8174c64d76d) by [@cortinico](https://github.com/cortinico)) + +#### iOS specific + +- Remove alert's window when call to `hide`. ([a46a99e120](https://github.com/facebook/react-native/commit/a46a99e12039c2b92651af1996489d660e237f1b) by [@asafkorem](https://github.com/asafkorem)) + +## v0.67.0 + +### Added + +#### Android specific +- Add `ACCESS_MEDIA_LOCATION` permission to PermisionsAndroid library. ([79db483568](https://github.com/facebook/react-native/commit/79db4835681f5d0149620ec8e0990411cb882241) by [@Skrilltrax](https://github.com/Skrilltrax)) +- Implement `SnapToAlignment` in `ReactScrollView` ([e774c037bc](https://github.com/facebook/react-native/commit/e774c037bce40a4b48e78d2d0a1085a1e4f5a328)), `ReactScrollViewManager` ([c6e5640e87](https://github.com/facebook/react-native/commit/c6e5640e87e7cb5b514ded2c8d4cbb039bd02c5f)), `ReactHorizontalScrollView` ([b12256394e](https://github.com/facebook/react-native/commit/b12256394e34c375942ca508ef79a8c816317976)), `ReactHorizontalScrollViewManager` ([deec1db9fd](https://github.com/facebook/react-native/commit/deec1db9fdf2848941326ba5bebc11f3592a301e)) and update `ScrollView.js` ([a54cfb9e57](https://github.com/facebook/react-native/commit/a54cfb9e5794f196d3834e19762f3aacf47a177d)) and reach parity with iOS ([04184ef851](https://github.com/facebook/react-native/commit/04184ef851c71141009c523ba59838ae6af19ba5)) by [@mdvacca](https://github.com/mdvacca) +- Show Redbox for C++ errors. ([d6c879edba](https://github.com/facebook/react-native/commit/d6c879edbad068d0f461381875b7fae6db99d18d) by [@sota000](https://github.com/sota000)) +- Added an experimental touch dispatch path ([a2feaeb5f1](https://github.com/facebook/react-native/commit/a2feaeb5f1121a860a9416b5d4e0e96debd45b09) by [@ShikaSD](https://github.com/ShikaSD)) + +#### iOS specific +- Added `cancelButtonTintColor` prop for `ActionSheetIOS` to change only the text color of the cancel button ([01856633a1](https://github.com/facebook/react-native/commit/01856633a1d42ed3b26e7cc93a007d7948e1f76e) by [@nomi9995](https://github.com/nomi9995)) +- Added [`LSApplicationQueriesSchemes`](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW14) in info.plist with entries tel, telprompt, http, fb, geo ([b26f277262](https://github.com/facebook/react-native/commit/b26f2772624c863c91fa1ff627b481c92d7562fb) by [@utkarsh-dixit](https://github.com/utkarsh-dixit)) +- Add `UIAccessibilityTraitUpdatesFrequently` to progressBar role ([1a42bd6e97](https://github.com/facebook/react-native/commit/1a42bd6e97ae44a3b38ca552865bac63a6f35da5) by [@jimmy623](https://github.com/jimmy623)) +- Add `asdf-vm` support in `find-node.sh` ([3e7c310b1d](https://github.com/facebook/react-native/commit/3e7c310b1dcf5643920535eea70afa451888792a) by [@pastleo](https://github.com/pastleo)) + + +### Changed +- `ImageBackground` now respects `imageStyle` width and height ([dbd5c3d8e5](https://github.com/facebook/react-native/commit/dbd5c3d8e5e35685be89156194a96cead553a330) by [@Naturalclar](https://github.com/Naturalclar)) +- Rename deprecated `Keyboard.removeEventListener` to `Keyboard.removeListener`. ([8880c09076](https://github.com/facebook/react-native/commit/8880c09076e4727768ace26a74766cbe6f64021c) by [@yungsters](https://github.com/yungsters)) +- Update `Modal`'s mock to not render its children when it is not visible ([ec614c16b3](https://github.com/facebook/react-native/commit/ec614c16b331bf3f793fda5780fa273d181a8492) by [@AntoineDoubovetzky](https://github.com/AntoineDoubovetzky)) +- Upgraded `react-devtools-core` dependency to 4.19.1 ([356236471a](https://github.com/facebook/react-native/commit/356236471abc6b5b8c139223e15388fd1eecd2d1) by [@jstejada](https://github.com/jstejada)) +- React-native/normalize-color now supports Node.js ([65e58f26e1](https://github.com/facebook/react-native/commit/65e58f26e1fbd06b1ae32e2ab3a2616c8eef08e0) by [@yungsters](https://github.com/yungsters)) +- Updated to Contributor Covenant v2.1 ([19f8d2f7da](https://github.com/facebook/react-native/commit/19f8d2f7da13f4524f31acf7aa10cc0aa91b5da4)) + + +#### Android specific +- Hermes initialization will no longer need an explicit configuration. ([a40f973f58](https://github.com/facebook/react-native/commit/a40f973f58609ca717fac63bc501d5cf93b748ad) by [@Ashoat](https://github.com/Ashoat)) +- Setting `overflow: scroll` in View component style will clip the children in the View container ([93beb83abe](https://github.com/facebook/react-native/commit/93beb83abef42b92db43ee3bb8b156f486a6c00f) by [@ryancat](https://github.com/ryancat)) +- Native views backing `Animated.View` (w/ JavaScript-driven animations) will no longer be flattened; this should be a transparent change. ([4fdbc44ab5](https://github.com/facebook/react-native/commit/4fdbc44ab5945399338e4ed94ea5611098bd2142) by [@yungsters](https://github.com/yungsters)) +- Use new Locale API on Android 11 (API 30)+ ([b7c023a8c1](https://github.com/facebook/react-native/commit/b7c023a8c1122500c6ceb7de2547569b3b9251ba)) +- Changed `react.gradle` `detectCliPath` function logic for `cliPath` case ([ce51b62494](https://github.com/facebook/react-native/commit/ce51b6249449361ee50b8c99a427c28af7ab3531) by [@vitalyiegorov](https://github.com/vitalyiegorov)) +- Remove `"high"` and `"balanced"` as values for `android_hyphenationFrequency` on `Text` ([a0d30b848a](https://github.com/facebook/react-native/commit/a0d30b848a07480d0fccec608a62a505c71f8cac)) +- Bump Gradle version to 7.2, Bump Kotlin version to 1.5.31 ([9ae3367431](https://github.com/facebook/react-native/commit/9ae3367431428748f5486c782199beb4f9c6b477) by [@svbutko](https://github.com/svbutko)) +- Move mavenCentral repo below local paths ([046b02628d](https://github.com/facebook/react-native/commit/046b02628d32eadd6d44160ab79932f6c26b188d) by [@friederbluemle](https://github.com/friederbluemle)) + +#### iOS specific +- Optimized font handling for iOS ([4ac42d88ef](https://github.com/facebook/react-native/commit/4ac42d88ef60ae3fed7319851d47b93e98ac9afa) by [@Adlai-Holler](https://github.com/Adlai-Holler)) +- Remove iOS 11 version check as minimum deployment is iOS 11 ([398595e074](https://github.com/facebook/react-native/commit/398595e07483fa8f45579de4ca1aee9585e20620) by [@ken0nek](https://github.com/ken0nek)) +- Don't hang app for 60s if packager can't be reached, changed to 10s ([c0e04460f5](https://github.com/facebook/react-native/commit/c0e04460f546dfef2623bff367eb8db8fd75fa34) by [@radex](https://github.com/radex)) + +### Removed + +- Removed unnecessary global variable `GLOBAL`. ([a101fc768c](https://github.com/facebook/react-native/commit/a101fc768cedc7ac9754006e5b7292bb7084ab54) by [@rubennorte](https://github.com/rubennorte)) +- Removed unused files: `StaticContainer.react.js`, `ensurePositiveDelayProps.js`, `InteractionMixin.js`, `queryLayoutByID.js` ([64aa1e5ffe](https://github.com/facebook/react-native/commit/64aa1e5ffe5d577c04cabb3692246b956f65597b) by [@ecreeth](https://github.com/ecreeth)) + +#### Android specific + +- Remove `DatePickerAndroid` from react-native. ([7a770526c6](https://github.com/facebook/react-native/commit/7a770526c626e6659a12939f8c61057a688aa623) by [@andresantonioriveros](https://github.com/andresantonioriveros)) + +#### iOS specific + +### Fixed + +- Update metro config language to `blockList` ([7923804c28](https://github.com/facebook/react-native/commit/7923804c28aac731396f0db112cb6c3a9d30c08f) by [@rh389](https://github.com/rh389)) +- Ignores global npm prefix ([6334ac35ac](https://github.com/facebook/react-native/commit/6334ac35ac3cbc2c84b2d46d46ec118bf9bf714d) by [@redreceipt](https://github.com/redreceipt)) +- Support `Animated.ValueXY` when validating `Animated.event`. ([27dd2ecb70](https://github.com/facebook/react-native/commit/27dd2ecb70f1d08787c93a2e18250ffaff328e5f) by [@javache](https://github.com/javache)) +- Add a function `getIgnorePatterns` in `LogBoxData.js` for tests or other usecases. ([a950634424](https://github.com/facebook/react-native/commit/a950634424cddf31c0adb6c9799adf1cc5f83bf0)) + +#### Android specific + +- TextInput Drawable to avoid Null Pointer Exception RuntimeError https://github.com/facebook/react-native/issues/17530 ([254493e1fb](https://github.com/facebook/react-native/commit/254493e1fb0c3a1e279e2c957e83edac6252d041) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Nested Text Android `onPress` does not work with last character ([132d1d00f8](https://github.com/facebook/react-native/commit/132d1d00f885fe5a45d712fd7698db285c22bc4b) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Fix non selectable Text in FlatList ([c360b1d92b](https://github.com/facebook/react-native/commit/c360b1d92b69e1d298b390ec88c4d29c1023945a) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Set `textBreakStrategy` default to be `'highQuality'` ([3b2d541989](https://github.com/facebook/react-native/commit/3b2d5419899363d84aea4f5cc3a4c75253dd6406)) +- Fix error handling when loading JSC or Hermes ([d839b24b06](https://github.com/facebook/react-native/commit/d839b24b06d31b4ce91fb459742831b942972f56) by [@iqqmuT](https://github.com/iqqmuT)) +- Fix encoding for gradlew.bat files ([ab2bdee735](https://github.com/facebook/react-native/commit/ab2bdee735cd0d53d3dbfbac5cd31f96eefb7e61) by [@yungsters](https://github.com/yungsters)) +- Fix `hermesFlags` not working with multiple variants ([91adb761cf](https://github.com/facebook/react-native/commit/91adb761cf1583598d4d63ce879fd7e0f4ae793c) by [@grit96](https://github.com/grit96)) +- `ScrollTo` API in ScrollView will check the actual scroll position before setting the scroll state ([1a9e2d5d55](https://github.com/facebook/react-native/commit/1a9e2d5d5589ce5cee92868ea5bccceb6e161eff) by [@ryancat](https://github.com/ryancat)) +- Compute Android Notch in `keyboardDidShow` height calculation API 28+ ([8bef3b1f11](https://github.com/facebook/react-native/commit/8bef3b1f1136ab5c2f2309a3101a7d9626ced1f5) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Fix `currentActivity` being null when launching Redbox ([f4fdf4b55e](https://github.com/facebook/react-native/commit/f4fdf4b55e4489c21f4552b4ac01ef253c038b2d)) +- When sending OS intents, always set `"FLAG_ACTIVITY_NEW_TASK"` flag (required by OS). ([04fe3ed80d](https://github.com/facebook/react-native/commit/04fe3ed80d9c201a483a2b477aeebd3d4169fd6d) by [@Krizzu](https://github.com/Krizzu)) +- Fix missing WebView provider crash in ForwardingCookieHandler ([d40cb0e1b0](https://github.com/facebook/react-native/commit/d40cb0e1b0fb233a27b9d476167814d2853acf2a) by [@RodolfoGS](https://github.com/RodolfoGS)) +- Fix `keyboardDismissMode="on-drag"` on Android ([7edf9274cf](https://github.com/facebook/react-native/commit/7edf9274cf6d3398075c19cd1cb020a5d6a346a2) by [@janicduplessis](https://github.com/janicduplessis)) +- Fixed `alignItems: baseline` for elements on Android ([1acf334614](https://github.com/facebook/react-native/commit/1acf33461451834097463f43e70d90bae0f67198)) +- `OnKeyPress` event not fired with numeric keys ([ee3e71f536](https://github.com/facebook/react-native/commit/ee3e71f536127295ba4ea377e618499409a2e9ba) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Exclude unused .so files for reduce android .apk and .aab ([6f126740fa](https://github.com/facebook/react-native/commit/6f126740fa560d7a831979b9f3747baacfb28dba) by [@enniel](https://github.com/enniel)) + +#### iOS specific + +- Fixed an edge case when scroll to item/index is called without animation, the offset position is not updated. This caused the measurement of the position to be wrong. ([55392f65a6](https://github.com/facebook/react-native/commit/55392f65a6addbdd8214b61d4ae286f26d63a94f) by [@ryancat](https://github.com/ryancat)) +- Fixed the issue when moving cursor in multi-line TextInput. ([22801870f0](https://github.com/facebook/react-native/commit/22801870f0613c2544ade1ebc5363e6e2f015c79) by [@xiankuncheng](https://github.com/xiankuncheng)) +- Fix NSInvalidArgumentException for invalid font family names. ([5683932862](https://github.com/facebook/react-native/commit/5683932862ab870e735342342c68e03fb5ca9e09) by [@yungsters](https://github.com/yungsters)) +- Fix Image `defaultSource` not showing on iOS ([900210cacc](https://github.com/facebook/react-native/commit/900210cacc4abca0079e3903781bc223c80c8ac7) by [@cristianoccazinsp](https://github.com/cristianoccazinsp)) +- Warn if Rosetta2 is being used (x86_64 on arm64) ([51bf557948](https://github.com/facebook/react-native/commit/51bf55794899284e1c465d346a3f6ebd8a485da2) by [@barbieri](https://github.com/barbieri)) +- Source map path for schemes containing whitespaces ([f3fe7a0fb5](https://github.com/facebook/react-native/commit/f3fe7a0fb5fc0325fbe062c6df4cbf8b58779189) by [@andersonvom](https://github.com/andersonvom)) +- Fix build error after running `pod install` with `--project-directory=ios` ([ef5ff3e055](https://github.com/facebook/react-native/commit/ef5ff3e055482771cbe866d4961ee2d0a9e00e45) by [@sonicdoe](https://github.com/sonicdoe)) +- Fixed inability to build apps when gflags is installed ([ab8dbdf663](https://github.com/facebook/react-native/commit/ab8dbdf66363f3d65f0dfbcc4ec7c71b1cd69b2a) by [@KDederichs](https://github.com/KDederichs)) + +### Security + +- Avoiding logging root view params outside of dev / debug mode builds ([e612d3a116](https://github.com/facebook/react-native/commit/e612d3a116f39ab354169643bab0d4bb9cfc1a85) by [@sterlingwes](https://github.com/sterlingwes)) + +## v0.66.4 + +### Fixed + +#### iOS specific + +- Revert "Fix Deadlock in RCTi18nUtil (iOS)" ([70ddf46](https://github.com/facebook/react-native/commit/70ddf46c8afcd720e188b6d82568eac6ac8125e6) by [@Saadnajmi](https://github.com/Saadnajmi)) +- `apply_Xcode_12_5_M1_post_install_workaround` causing pods targetting iOS 12 and above to fail ([a4a3e67554](https://github.com/facebook/react-native/commit/a4a3e675542827bb281a7ceccc7b8f5533eae29f) by [@Yonom](https://github.com/Yonom)) + ## v0.66.3 ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0cf6f7273ee031..786600c1a62205 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,113 +1,7 @@ # Contributing to React Native -Thank you for your interest in contributing to React Native! From commenting on and triaging issues, to reviewing and sending Pull Requests, all contributions are welcome. We aim to build a vibrant and inclusive [ecosystem of partners, core contributors, and community](ECOSYSTEM.md) that goes beyond the main React Native GitHub repository. +Thank you for your interest in contributing to React Native! From commenting on and triaging issues, to reviewing and sending Pull Requests, all contributions are welcome. +We aim to build a vibrant and inclusive [ecosystem of partners, core contributors, and community](ECOSYSTEM.md) that goes beyond the main React Native GitHub repository. -The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies who want to learn how to run and contribute to an open source project. Contributors and people new to open source alike will find the following guides especially useful: - -* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) -* [Building Welcoming Communities](https://opensource.guide/building-community/) - - -### [Code of Conduct](https://github.com/facebook/react-native/blob/HEAD/CODE_OF_CONDUCT.md) - -As a reminder, all contributors are expected to adhere to the [Code of Conduct](https://github.com/facebook/react-native/blob/HEAD/CODE_OF_CONDUCT.md). - -## Ways to Contribute - -If you are eager to start contributing code right away, we have a list of [good first issues](https://github.com/facebook/react-native/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. As you gain more experience and demonstrate a commitment to evolving React Native, you may be granted issue management permissions in the repository. - -There are other ways you can contribute without writing a single line of code. Here are a few things you can do to help out: - -1. **Replying and handling open issues.** We get a lot of issues every day, and some of them may lack necessary information. You can help out by guiding people through the process of filling out the issue template, asking for clarifying information, or pointing them to existing issues that match their description of the problem. We cover more about this process in the [Issue Triage wiki](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues). -2. **Reviewing pull requests for the docs.** Reviewing [documentation updates](https://github.com/facebook/react-native-website/pulls) can be as simple as checking for spelling and grammar. If you encounter situations that can be explained better in the docs, click **Edit** at the top of most docs pages to get started with your own contribution. -3. **Help people write test plans.** Some pull requests sent to the main repository may lack a proper test plan. These help reviewers understand how the change was tested, and can speed up the time it takes for a contribution to be accepted. - -Each of these tasks is highly impactful, and maintainers will greatly appreciate your help. - -### Our Development Process - -We use GitHub issues and pull requests to keep track of bug reports and contributions from the community. All changes from engineers at Facebook will sync to [GitHub](https://github.com/facebook/react-native) through a bridge with Facebook's internal source control. Changes from the community are handled through GitHub pull requests. Once a change made on GitHub is approved, it will first be imported into Facebook's internal source control and tested against Facebook's codebase. Once merged at Facebook, the change will eventually sync back to GitHub as a single commit once it has passed Facebook's internal tests. - -You can learn more about the contribution process in the following documents: - -* [Issues](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues) -* [Pull Requests](https://github.com/facebook/react-native/wiki/Managing-Pull-Requests) - -We also have a thriving community of contributors who would be happy to help you get set up. You can reach out to us through [@ReactNative](http://twitter.com/reactnative) (the React Native team) and [@ReactNativeComm](http://twitter.com/reactnativecomm) (the React Native Community organization). - -### Repositories - -The main repository, , contains the React Native framework itself and it is here where we keep track of bug reports and manage pull requests. - -There are a few other repositories you might want to familiarize yourself with: - -* **React Native website** which contains the source code for the website, including the documentation, located at -* **Releases** Conversations for new releases are happening [in this discussion repo](https://github.com/reactwg/react-native-releases/discussions). -* **Changelog** The changelog can be found [here](https://github.com/facebook/react-native/blob/main/CHANGELOG.md). -* **Discussions** about the future of React Native take place in the repository. -* **High-quality plugins** for React Native can be found throughout the [React Native Community GitHub Organization](http://github.com/react-native-community/). - -Browsing through these repositories should provide some insight into how the React Native open source project is managed. - -## GitHub Issues - -We use GitHub issues to track bugs exclusively. We have documented our issue handling processes in the [Issues wiki](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues). - -### Security Bugs - -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue. - -## Helping with Documentation - -The React Native documentation is hosted as part of the React Native website repository at https://github.com/facebook/react-native-website. The website itself is located at and it is built using [Docusaurus](https://docusaurus.io/). If there's anything you'd like to change in the docs, you can get started by clicking on the "Edit" button located on the upper right of most pages in the website. - -If you are adding new functionality or introducing a change in behavior, we will ask you to update the documentation to reflect your changes. - -### Contributing to the Blog - -The React Native blog is generated [from the Markdown sources for the blog](https://github.com/facebook/react-native-website/tree/HEAD/website/blog). - -Please open an issue in the https://github.com/facebook/react-native-website repository or tag us on [@ReactNative on Twitter](http://twitter.com/reactnative) and get the go-ahead from a maintainer before writing an article intended for the React Native blog. In most cases, you might want to share your article on your own blog or writing medium instead. It's worth asking, though, in case we find your article is a good fit for the blog. - -We recommend referring to the [CONTRIBUTING](https://github.com/facebook/react-native-website/blob/HEAD/CONTRIBUTING.md) document for the `react-native-website` repository to learn more about contributing to the website in general. - -## Contributing Code - -Code-level contributions to React Native generally come in the form of [pull requests](https://help.github.com/en/articles/about-pull-requests). These are done by forking the repo and making changes locally. Directly in the repo, there is the [`rn-tester` app](/packages/rn-tester) that you can install on your device (or simulators) and use to test the changes you're making to React Native sources. - -The process of proposing a change to React Native can be summarized as follows: - -1. Fork the React Native repository and create your branch from `main`. -2. Make the desired changes to React Native sources. Use the `packages/rn-tester` app to test them out. -3. If you've added code that should be tested, add tests. -4. If you've changed APIs, update the documentation, which lives in [another repo](https://github.com/facebook/react-native-website/). -5. Ensure the test suite passes, either locally or on CI once you opened a pull request. -6. Make sure your code lints (for example via `yarn lint --fix`). -7. Push the changes to your fork. -8. Create a pull request to the React Native repository. -9. Review and address comments on your pull request. - 1. A bot may comment with suggestions. Generally we ask you to resolve these first before a maintainer will review your code. - 2. If changes are requested and addressed, please [request review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) to notify reviewers to take another look. -10. If you haven't already, please complete the [Contributor License Agreement](https://github.com/facebook/react-native/wiki/Contributor-License-Agreement) ("CLA"). **[Complete your CLA here.](https://code.facebook.com/cla)** - -If all goes well, your pull request will be merged. If it is not merged, maintainers will do their best to explain the reason why. - -### Step-by-step Guide - -Whenever you are ready to contribute code, check out our [step-by-step guide to sending your first pull request](https://github.com/facebook/react-native/wiki/How-to-Open-a-Pull-Request), or read the [How to Contribute Code](https://github.com/facebook/react-native/wiki/How-to-Contribute-Code) wiki for more details. - -### Tests - -Tests help us prevent regressions from being introduced to the codebase. The GitHub repository is continuously tested using Circle and Appveyor, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/HEAD) and pull requests. You can learn more about running and writing tests in the [Tests wiki](http://github.com/facebook/react-native/wiki/Tests). - -## Community Contributions - -Contributions to React Native are not limited to GitHub. You can help others by sharing your experience using React Native, whether that is through blog posts, presenting talks at conferences, or simply sharing your thoughts on Twitter and tagging @ReactNative. - -## Where to Get Help - -As you work on React Native, it is natural that sooner or later you may require help. In addition to the resources listed in [SUPPORT](.github/SUPPORT.md), people interested in contributing may take advantage of the following: - -* **Twitter**. The React Native team at Facebook has its own account at [@reactnative](https://twitter.com/reactnative), and the React Native Community uses [@reactnativecomm](https://twitter.com/reactnativecomm). If you feel stuck, or need help contributing, please do not hesitate to reach out. -* **Proposals Repository**. If you are considering working on a feature large in scope, consider [creating a proposal first](https://github.com/react-native-community/discussions-and-proposals). The community can help you figure out the right approach, and we'd be happy to help. -* **React Native Community Discord**. While we try to hold most discussions in public, sometimes it can be beneficial to have conversations in real time with other contributors. People who have demonstrated a commitment to moving React Native forward through sustained contributions to the project may eventually be invited to join the React Native Community Discord. +To learn more about how to contribute check out the Contributing section on the React Native website: +* https://reactnative.dev/contributing/overview diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md index 657cfb43a11366..2505baabf0cc29 100644 --- a/ECOSYSTEM.md +++ b/ECOSYSTEM.md @@ -12,14 +12,14 @@ There are three types of stakeholders: Partners are companies that are significantly invested in React Native and have been for years. Informed by their use of React Native, they push for improvements of the core and/or the ecosystem around it. Partners think of React Native as a product: they understand the trade offs that the project makes as well as future plans and goals. Together we shape the vision for React Native to make it the best way to build applications. -React Native's current set of partners include Callstack, Expo, Facebook, Infinite Red, Microsoft and Software Mansion. Many engineers from these companies are core contributors, and their partner responsibilities also include: +React Native's current set of partners include Callstack, Expo, Infinite Red, Meta, Microsoft and Software Mansion. Many engineers from these companies are core contributors, and their partner responsibilities also include: * **[Callstack](https://callstack.com/):** Manages releases, maintains the [React Native CLI](https://github.com/react-native-community/react-native-cli) and organizes [React Native EU](https://react-native.eu/) -* **[Expo](https://expo.io/):** Builds [expo](https://github.com/expo/expo) on top of React Native to simplify app development -* **[Facebook](https://opensource.facebook.com):** Oversees the React Native product and maintains the [React Native core repo](https://reactnative.dev/) +* **[Expo](https://expo.dev/):** Builds [expo](https://github.com/expo/expo) and [EAS](https://expo.dev/eas) on top of React Native to simplify app development * **[Infinite Red](https://infinite.red/):** Maintains the [ignite cli/boilerplate](https://github.com/infinitered/ignite), organizes [Chain React Conf](https://cr.infinite.red/) +* **[Meta](https://opensource.fb.com/):** Oversees the React Native product and maintains the [React Native core repo](https://reactnative.dev/) * **[Microsoft](http://aka.ms/reactnative):** Develops [React Native Windows](https://github.com/Microsoft/react-native-windows) and [React Native macOS](https://github.com/microsoft/react-native-macos) for building apps that target Windows and macOS -* **[Software Mansion](https://swmansion.com/):** Maintain core infrastructure including JSC, Animated, and other popular third-party plugins. +* **[Software Mansion](https://swmansion.com/):** Maintain core infrastructure including JSC, Animated, and other popular third-party plugins and organizes [App.js Conf](https://appjs.co/) In terms of open source work, pull requests from partners are commonly prioritized. When you are contributing to React Native, you'll most likely meet somebody who works at one of the partner companies and who is a core contributor: @@ -44,7 +44,7 @@ We aim to make contributing to React Native as easy and transparent as possible. ## Community Contributors -Community contributors are individuals who support projects in the [react-native-community](https://github.com/react-native-community) organization. This organization exists as an incubator for high quality components that extend the capabilities of React Native with functionality that many but not all applications require. Facebook engineers will provide guidance to help build a vibrant community of people and components that make React Native better. +Community contributors are individuals who support projects in the [react-native-community](https://github.com/react-native-community) organization. This organization exists as an incubator for high quality components that extend the capabilities of React Native with functionality that many but not all applications require. Meta engineers will provide guidance to help build a vibrant community of people and components that make React Native better. This structure has multiple benefits: diff --git a/Gemfile b/Gemfile index 2c3edcf4b7011d..5efda89f452582 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby '2.7.4' +ruby '2.7.5' gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/Gemfile.lock b/Gemfile.lock index e0f260750f1659..fd7c2f3b84692b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.4) + CFPropertyList (3.0.5) rexml - activesupport (6.1.4.1) + activesupport (6.1.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -15,11 +15,11 @@ GEM httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) - claide (1.0.3) - cocoapods (1.11.2) + claide (1.1.0) + cocoapods (1.11.3) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.2) + cocoapods-core (= 1.11.3) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -34,7 +34,7 @@ GEM nap (~> 1.0) ruby-macho (>= 1.0, < 3.0) xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.2) + cocoapods-core (1.11.3) activesupport (>= 5.0, < 7) addressable (~> 2.8) algoliasearch (~> 1.0) @@ -45,7 +45,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.5.1) + cocoapods-downloader (1.6.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -54,19 +54,19 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) escape (0.0.4) ethon (0.15.0) ffi (>= 1.15.0) - ffi (1.15.4) + ffi (1.15.5) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.8.10) + i18n (1.10.0) concurrent-ruby (~> 1.0) - json (2.6.0) - minitest (5.14.4) + json (2.6.1) + minitest (5.15.0) molinillo (0.8.0) nanaimo (0.3.0) nap (1.1.0) @@ -85,7 +85,7 @@ GEM colored2 (~> 3.1) nanaimo (~> 0.3.0) rexml (~> 3.2.4) - zeitwerk (2.5.1) + zeitwerk (2.5.4) PLATFORMS ruby @@ -94,7 +94,7 @@ DEPENDENCIES cocoapods (~> 1.11, >= 1.11.2) RUBY VERSION - ruby 2.7.4p191 + ruby 2.7.5p203 BUNDLED WITH - 2.2.29 + 2.3.10 diff --git a/IntegrationTests/AccessibilityManagerTest.js b/IntegrationTests/AccessibilityManagerTest.js index a6f4c0d93bb64c..f23972f25da1bd 100644 --- a/IntegrationTests/AccessibilityManagerTest.js +++ b/IntegrationTests/AccessibilityManagerTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/AppEventsTest.js b/IntegrationTests/AppEventsTest.js index 1cec9ee0179ecc..5ff829b20c5a5e 100644 --- a/IntegrationTests/AppEventsTest.js +++ b/IntegrationTests/AppEventsTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index 209a5e9b77fae7..42bdbd62965458 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,7 +33,7 @@ const VAL_MERGE_EXPECT = {foo: 1, bar: {hoo: 2, boo: 1}, baz: 2, moo: {a: 3}}; let done = (result: ?boolean) => {}; let updateMessage = (message: string) => {}; -function runTestCase(description: string, fn) { +function runTestCase(description: string, fn: () => void) { updateMessage(description); fn(); } @@ -61,7 +61,20 @@ function stringify( return JSON.stringify(value); } -function expectEqual(lhs, rhs, testname: string) { +function expectEqual( + lhs: ?(any | string | Array>), + rhs: + | null + | string + | { + bar: {boo: number, hoo: number}, + baz: number, + foo: number, + moo: {a: number}, + } + | Array>, + testname: string, +) { expectTrue( !deepDiffer(lhs, rhs), 'Error in test ' + @@ -73,7 +86,10 @@ function expectEqual(lhs, rhs, testname: string) { ); } -function expectAsyncNoError(place, err) { +function expectAsyncNoError( + place: string, + err: ?(Error | string | Array), +) { if (err instanceof Error) { err = err.message; } @@ -207,7 +223,7 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> { this.setState({done: true}, () => { TestModule.markTestCompleted(); }); - updateMessage = msg => { + updateMessage = (msg: string) => { this.setState({messages: this.state.messages.concat('\n' + msg)}); DEBUG && console.log(msg); }; diff --git a/IntegrationTests/BUCK b/IntegrationTests/BUCK index 61e3de6466aaa5..fa6fe51a3c538a 100644 --- a/IntegrationTests/BUCK +++ b/IntegrationTests/BUCK @@ -1,4 +1,4 @@ -load("@fbsource//tools/build_defs:js_glob.bzl", "js_glob") +load("@fbsource//tools/build_defs:js_library_glob.bzl", "js_library_glob") load("@fbsource//tools/build_defs/oss:metro_defs.bzl", "rn_library") # This file was generated by running @@ -6,7 +6,7 @@ load("@fbsource//tools/build_defs/oss:metro_defs.bzl", "rn_library") rn_library( name = "IntegrationTests", - srcs = js_glob( + srcs = js_library_glob( [ "**/*", ], @@ -17,7 +17,10 @@ rn_library( "websocket_integration_test_server.js", ], ), - labels = ["supermodule:xplat/default/public.react_native.tests"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.tests", + ], skip_processors = True, visibility = ["PUBLIC"], deps = [ diff --git a/IntegrationTests/GlobalEvalWithSourceUrlTest.js b/IntegrationTests/GlobalEvalWithSourceUrlTest.js index a69ee3728c48b0..dd3206f3c9a34d 100644 --- a/IntegrationTests/GlobalEvalWithSourceUrlTest.js +++ b/IntegrationTests/GlobalEvalWithSourceUrlTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/ImageCachePolicyTest.js b/IntegrationTests/ImageCachePolicyTest.js index 00d65fb736d119..808da56ce8e980 100644 --- a/IntegrationTests/ImageCachePolicyTest.js +++ b/IntegrationTests/ImageCachePolicyTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/ImageSnapshotTest.js b/IntegrationTests/ImageSnapshotTest.js index cff8a5adb59786..0d6aa3bb67f627 100644 --- a/IntegrationTests/ImageSnapshotTest.js +++ b/IntegrationTests/ImageSnapshotTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/IntegrationTestHarnessTest.js b/IntegrationTests/IntegrationTestHarnessTest.js index 75c525abfbe3a5..3d76dc7c0681ee 100644 --- a/IntegrationTests/IntegrationTestHarnessTest.js +++ b/IntegrationTests/IntegrationTestHarnessTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/IntegrationTestsApp.js b/IntegrationTests/IntegrationTestsApp.js index a9af9b940b4105..bb8efcbcd497a4 100644 --- a/IntegrationTests/IntegrationTestsApp.js +++ b/IntegrationTests/IntegrationTestsApp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/LayoutEventsTest.js b/IntegrationTests/LayoutEventsTest.js index 8c24abf36622ed..46efb579d825c7 100644 --- a/IntegrationTests/LayoutEventsTest.js +++ b/IntegrationTests/LayoutEventsTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,7 +19,7 @@ import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer'); -function debug(...args) { +function debug(...args: Array) { // console.log.apply(null, arguments); } @@ -119,16 +119,19 @@ class LayoutEventsTest extends React.Component { } onViewLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { + // $FlowFixMe[incompatible-call] debug('received view layout event\n', e.nativeEvent); this.setState({viewLayout: e.nativeEvent.layout}, this.checkLayout); }; onTextLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { + // $FlowFixMe[incompatible-call] debug('received text layout event\n', e.nativeEvent); this.setState({textLayout: e.nativeEvent.layout}, this.checkLayout); }; onImageLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { + // $FlowFixMe[incompatible-call] debug('received image layout event\n', e.nativeEvent); this.setState({imageLayout: e.nativeEvent.layout}, this.checkLayout); }; diff --git a/IntegrationTests/LoggingTestModule.js b/IntegrationTests/LoggingTestModule.js index 70df6c333207f2..c18cd8b4254378 100644 --- a/IntegrationTests/LoggingTestModule.js +++ b/IntegrationTests/LoggingTestModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/PromiseTest.js b/IntegrationTests/PromiseTest.js index 809f6eb873db8d..39b7c49d47ca12 100644 --- a/IntegrationTests/PromiseTest.js +++ b/IntegrationTests/PromiseTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/PropertiesUpdateTest.js b/IntegrationTests/PropertiesUpdateTest.js index 8c61685bf8848e..5c1355ac0513d5 100644 --- a/IntegrationTests/PropertiesUpdateTest.js +++ b/IntegrationTests/PropertiesUpdateTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/RCTRootViewIntegrationTestApp.js b/IntegrationTests/RCTRootViewIntegrationTestApp.js index 4df83a0752d0d0..5fd9e57d932f38 100644 --- a/IntegrationTests/RCTRootViewIntegrationTestApp.js +++ b/IntegrationTests/RCTRootViewIntegrationTestApp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/ReactContentSizeUpdateTest.js b/IntegrationTests/ReactContentSizeUpdateTest.js index 9c826d9f4f5328..ea00f975c37515 100644 --- a/IntegrationTests/ReactContentSizeUpdateTest.js +++ b/IntegrationTests/ReactContentSizeUpdateTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/SimpleSnapshotTest.js b/IntegrationTests/SimpleSnapshotTest.js index e7d91aa4b7021d..27e5d2c12d5454 100644 --- a/IntegrationTests/SimpleSnapshotTest.js +++ b/IntegrationTests/SimpleSnapshotTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/SizeFlexibilityUpdateTest.js b/IntegrationTests/SizeFlexibilityUpdateTest.js index 3577a5363b5339..79635eaffe52d9 100644 --- a/IntegrationTests/SizeFlexibilityUpdateTest.js +++ b/IntegrationTests/SizeFlexibilityUpdateTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/SyncMethodTest.js b/IntegrationTests/SyncMethodTest.js index 077884256d2fd9..febe02154375f9 100644 --- a/IntegrationTests/SyncMethodTest.js +++ b/IntegrationTests/SyncMethodTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/TimersTest.js b/IntegrationTests/TimersTest.js index 30473e3b8e752c..64b3f1233b6a65 100644 --- a/IntegrationTests/TimersTest.js +++ b/IntegrationTests/TimersTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/WebSocketTest.js b/IntegrationTests/WebSocketTest.js index d361ede9f639ba..6fbcbfb6cd8fa2 100644 --- a/IntegrationTests/WebSocketTest.js +++ b/IntegrationTests/WebSocketTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/IntegrationTests/launchWebSocketServer.command b/IntegrationTests/launchWebSocketServer.sh similarity index 56% rename from IntegrationTests/launchWebSocketServer.command rename to IntegrationTests/launchWebSocketServer.sh index 1ce2cf5317c010..cc736a5ceffd42 100755 --- a/IntegrationTests/launchWebSocketServer.command +++ b/IntegrationTests/launchWebSocketServer.sh @@ -1,18 +1,12 @@ #!/bin/bash - -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. -# Set terminal title -echo -en "\033]0;Web Socket Test Server\a" -clear - THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) -pushd "$THIS_DIR" +pushd "$THIS_DIR" || exit ./websocket_integration_test_server.js -popd +popd || exit -echo "Process terminated. Press to close the window" -read +echo "Process terminated." diff --git a/IntegrationTests/websocket_integration_test_server.js b/IntegrationTests/websocket_integration_test_server.js index 36c73bed65ec33..0f0b597b63a74c 100755 --- a/IntegrationTests/websocket_integration_test_server.js +++ b/IntegrationTests/websocket_integration_test_server.js @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/LICENSE b/LICENSE index b96dcb0480a0b0..b93be90515ccd0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) Facebook, Inc. and its affiliates. +Copyright (c) Meta Platforms, Inc. and affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index 889832df1b77e5..0904d14024f27f 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,7 @@ import type {ProcessedColorValue} from '../StyleSheet/processColor'; /** * Display action sheets and share sheets on iOS. * - * See https://reactnative.dev/docs/actionsheetios.html + * See https://reactnative.dev/docs/actionsheetios */ const ActionSheetIOS = { /** @@ -36,7 +36,7 @@ const ActionSheetIOS = { * The 'callback' function takes one parameter, the zero-based index * of the selected item. * - * See https://reactnative.dev/docs/actionsheetios.html#showactionsheetwithoptions + * See https://reactnative.dev/docs/actionsheetios#showactionsheetwithoptions */ showActionSheetWithOptions( options: {| @@ -117,7 +117,7 @@ const ActionSheetIOS = { * - a boolean value signifying success or failure * - a string that, in the case of success, indicates the method of sharing * - * See https://reactnative.dev/docs/actionsheetios.html#showshareactionsheetwithoptions + * See https://reactnative.dev/docs/actionsheetios#showshareactionsheetwithoptions */ showShareActionSheetWithOptions( options: Object, @@ -143,6 +143,13 @@ const ActionSheetIOS = { successCallback, ); }, + + dismissActionSheet: () => { + invariant(RCTActionSheetManager, "ActionSheetManager doesn't exist"); + if (typeof RCTActionSheetManager.dismissActionSheet === 'function') { + RCTActionSheetManager.dismissActionSheet(); + } + }, }; module.exports = ActionSheetIOS; diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index 56429c658ac0a6..1f9ead0bdd8f73 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,6 +47,7 @@ export interface Spec extends TurboModule { |}) => void, successCallback: (completed: boolean, activityType: ?string) => void, ) => void; + +dismissActionSheet?: () => void; } export default (TurboModuleRegistry.get('ActionSheetManager'): ?Spec); diff --git a/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec b/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec index f080a2b2ffb25f..a9bd4ca8235d0d 100644 --- a/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec +++ b/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -24,7 +24,7 @@ Pod::Spec.new do |s| s.documentation_url = "https://reactnative.dev/docs/actionsheetios" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "*.{m}" s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs" diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 091ff74ab654d9..1a943e1bbd7b0f 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,8 +8,9 @@ * @flow */ -import Platform from '../Utilities/Platform'; import type {DialogOptions} from '../NativeModules/specs/NativeDialogManagerAndroid'; + +import Platform from '../Utilities/Platform'; import RCTAlertManager from './RCTAlertManager'; export type AlertType = @@ -27,6 +28,7 @@ export type Buttons = Array<{ type Options = { cancelable?: ?boolean, + userInterfaceStyle?: 'unspecified' | 'light' | 'dark', onDismiss?: ?() => void, ... }; @@ -34,7 +36,7 @@ type Options = { /** * Launches an alert dialog with the specified title and message. * - * See https://reactnative.dev/docs/alert.html + * See https://reactnative.dev/docs/alert */ class Alert { static alert( @@ -44,7 +46,15 @@ class Alert { options?: Options, ): void { if (Platform.OS === 'ios') { - Alert.prompt(title, message, buttons, 'default'); + Alert.prompt( + title, + message, + buttons, + 'default', + undefined, + undefined, + options, + ); } else if (Platform.OS === 'android') { const NativeDialogManagerAndroid = require('../NativeModules/specs/NativeDialogManagerAndroid').default; @@ -82,6 +92,8 @@ class Alert { config.buttonPositive = buttonPositive.text || defaultPositiveText; } + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const onAction = (action, buttonKey) => { if (action === constants.buttonClicked) { if (buttonKey === constants.buttonNeutral) { @@ -95,7 +107,7 @@ class Alert { options && options.onDismiss && options.onDismiss(); } }; - const onError = errorMessage => console.warn(errorMessage); + const onError = (errorMessage: string) => console.warn(errorMessage); NativeDialogManagerAndroid.showAlert(config, onError, onAction); } } @@ -107,6 +119,7 @@ class Alert { type?: ?AlertType = 'plain-text', defaultValue?: string, keyboardType?: string, + options?: Options, ): void { if (Platform.OS === 'ios') { let callbacks = []; @@ -124,7 +137,7 @@ class Alert { destructiveButtonKey = String(index); } if (btn.text || index < (callbackOrButtons || []).length - 1) { - const btnDef = {}; + const btnDef: {[number]: string} = {}; btnDef[index] = btn.text || ''; buttons.push(btnDef); } @@ -141,6 +154,7 @@ class Alert { cancelButtonKey, destructiveButtonKey, keyboardType, + userInterfaceStyle: options?.userInterfaceStyle || undefined, }, (id, value) => { const cb = callbacks[id]; diff --git a/Libraries/Alert/NativeAlertManager.js b/Libraries/Alert/NativeAlertManager.js index ec01b4a916e911..9597ef155a522d 100644 --- a/Libraries/Alert/NativeAlertManager.js +++ b/Libraries/Alert/NativeAlertManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,6 +20,7 @@ export type Args = {| cancelButtonKey?: string, destructiveButtonKey?: string, keyboardType?: string, + userInterfaceStyle?: string, |}; export interface Spec extends TurboModule { diff --git a/Libraries/Alert/RCTAlertManager.android.js b/Libraries/Alert/RCTAlertManager.android.js index 72f0e1b1cce27e..3a15b76ac57c55 100644 --- a/Libraries/Alert/RCTAlertManager.android.js +++ b/Libraries/Alert/RCTAlertManager.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Alert/RCTAlertManager.ios.js b/Libraries/Alert/RCTAlertManager.ios.js index a5dbdac5daf7dc..01f055da53d402 100644 --- a/Libraries/Alert/RCTAlertManager.ios.js +++ b/Libraries/Alert/RCTAlertManager.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/Animated.js b/Libraries/Animated/Animated.js index 2f6ee99ae6b04e..88fd9dbb188dbe 100644 --- a/Libraries/Animated/Animated.js +++ b/Libraries/Animated/Animated.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,8 +16,8 @@ import typeof AnimatedSectionList from './components/AnimatedSectionList'; import typeof AnimatedText from './components/AnimatedText'; import typeof AnimatedView from './components/AnimatedView'; -const AnimatedMock = require('./AnimatedMock'); -const AnimatedImplementation = require('./AnimatedImplementation'); +import * as AnimatedMock from './AnimatedMock'; +import * as AnimatedImplementation from './AnimatedImplementation'; const Animated = ((Platform.isTesting ? AnimatedMock diff --git a/Libraries/Animated/AnimatedEvent.js b/Libraries/Animated/AnimatedEvent.js index b9101f16d42653..af1d660a8de794 100644 --- a/Libraries/Animated/AnimatedEvent.js +++ b/Libraries/Animated/AnimatedEvent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,6 +19,8 @@ const invariant = require('invariant'); const {shouldUseNativeDriver} = require('./NativeAnimatedHelper'); +import type {PlatformConfig} from './AnimatedPlatformConfig'; + export type Mapping = | {[key: string]: Mapping, ...} | AnimatedValue @@ -26,20 +28,22 @@ export type Mapping = export type EventConfig = { listener?: ?Function, useNativeDriver: boolean, + platformConfig?: PlatformConfig, }; function attachNativeEvent( viewRef: any, eventName: string, argMapping: $ReadOnlyArray, + platformConfig: ?PlatformConfig, ): {detach: () => void} { // Find animated values in `argMapping` and create an array representing their // key path inside the `nativeEvent` object. Ex.: ['contentOffset', 'x']. const eventMappings = []; - const traverse = (value, path) => { + const traverse = (value: mixed, path: Array) => { if (value instanceof AnimatedValue) { - value.__makeNative(); + value.__makeNative(platformConfig); eventMappings.push({ nativeEventPath: path, @@ -90,8 +94,8 @@ function attachNativeEvent( }; } -function validateMapping(argMapping, args) { - const validate = (recMapping, recEvt, key) => { +function validateMapping(argMapping: $ReadOnlyArray, args: any) { + const validate = (recMapping: ?Mapping, recEvt: any, key: string) => { if (recMapping instanceof AnimatedValue) { invariant( typeof recEvt === 'number', @@ -145,9 +149,9 @@ function validateMapping(argMapping, args) { class AnimatedEvent { _argMapping: $ReadOnlyArray; _listeners: Array = []; - _callListeners: Function; _attachedEvent: ?{detach: () => void, ...}; __isNative: boolean; + __platformConfig: ?PlatformConfig; constructor(argMapping: $ReadOnlyArray, config: EventConfig) { this._argMapping = argMapping; @@ -160,9 +164,9 @@ class AnimatedEvent { if (config.listener) { this.__addListener(config.listener); } - this._callListeners = this._callListeners.bind(this); this._attachedEvent = null; this.__isNative = shouldUseNativeDriver(config); + this.__platformConfig = config.platformConfig; } __addListener(callback: Function): void { @@ -183,6 +187,7 @@ class AnimatedEvent { viewRef, eventName, this._argMapping, + this.__platformConfig, ); } @@ -218,7 +223,10 @@ class AnimatedEvent { validatedMapping = true; } - const traverse = (recMapping, recEvt) => { + const traverse = ( + recMapping: ?(Mapping | AnimatedValue), + recEvt: any, + ) => { if (recMapping instanceof AnimatedValue) { if (typeof recEvt === 'number') { recMapping.setValue(recEvt); @@ -245,9 +253,9 @@ class AnimatedEvent { }; } - _callListeners(...args: any) { + _callListeners = (...args: any) => { this._listeners.forEach(listener => listener(...args)); - } + }; } module.exports = {AnimatedEvent, attachNativeEvent}; diff --git a/Libraries/Animated/AnimatedImplementation.js b/Libraries/Animated/AnimatedImplementation.js index 517c7b59ff66a0..5aaa29f336537f 100644 --- a/Libraries/Animated/AnimatedImplementation.js +++ b/Libraries/Animated/AnimatedImplementation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -38,6 +38,8 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation'; import type {SpringAnimationConfig} from './animations/SpringAnimation'; import type {Mapping, EventConfig} from './AnimatedEvent'; +import AnimatedColor from './nodes/AnimatedColor'; + export type CompositeAnimation = { start: (callback?: ?EndCallback) => void, stop: () => void, @@ -89,10 +91,10 @@ const diffClamp = function ( const _combineCallbacks = function ( callback: ?EndCallback, - config: {...AnimationConfig, ...}, + config: $ReadOnly<{...AnimationConfig, ...}>, ) { if (callback && config.onComplete) { - return (...args) => { + return (...args: Array) => { config.onComplete && config.onComplete(...args); callback && callback(...args); }; @@ -102,7 +104,7 @@ const _combineCallbacks = function ( }; const maybeVectorAnim = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: Object, anim: (value: AnimatedValue, config: Object) => CompositeAnimation, ): ?CompositeAnimation { @@ -121,16 +123,42 @@ const maybeVectorAnim = function ( // We use `stopTogether: false` here because otherwise tracking will break // because the second animation will get stopped before it can update. return parallel([aX, aY], {stopTogether: false}); + } else if (value instanceof AnimatedColor) { + const configR = {...config}; + const configG = {...config}; + const configB = {...config}; + const configA = {...config}; + for (const key in config) { + const {r, g, b, a} = config[key]; + if ( + r !== undefined && + g !== undefined && + b !== undefined && + a !== undefined + ) { + configR[key] = r; + configG[key] = g; + configB[key] = b; + configA[key] = a; + } + } + const aR = anim((value: AnimatedColor).r, configR); + const aG = anim((value: AnimatedColor).g, configG); + const aB = anim((value: AnimatedColor).b, configB); + const aA = anim((value: AnimatedColor).a, configA); + // We use `stopTogether: false` here because otherwise tracking will break + // because the second animation will get stopped before it can update. + return parallel([aR, aG, aB, aA], {stopTogether: false}); } return null; }; const spring = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: SpringAnimationConfig, ): CompositeAnimation { const start = function ( - animatedValue: AnimatedValue | AnimatedValueXY, + animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor, configuration: SpringAnimationConfig, callback?: ?EndCallback, ): void { @@ -179,11 +207,11 @@ const spring = function ( }; const timing = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: TimingAnimationConfig, ): CompositeAnimation { const start = function ( - animatedValue: AnimatedValue | AnimatedValueXY, + animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor, configuration: TimingAnimationConfig, callback?: ?EndCallback, ): void { @@ -233,11 +261,11 @@ const timing = function ( }; const decay = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: DecayAnimationConfig, ): CompositeAnimation { const start = function ( - animatedValue: AnimatedValue | AnimatedValueXY, + animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor, configuration: DecayAnimationConfig, callback?: ?EndCallback, ): void { @@ -280,7 +308,7 @@ const sequence = function ( let current = 0; return { start: function (callback?: ?EndCallback) { - const onComplete = function (result) { + const onComplete = function (result: EndResult) { if (!result.finished) { callback && callback(result); return; @@ -352,7 +380,7 @@ const parallel = function ( } animations.forEach((animation, idx) => { - const cb = function (endResult) { + const cb = function (endResult: EndResult | {finished: boolean}) { hasEnded[idx] = true; doneCount++; if (doneCount === animations.length) { @@ -432,6 +460,7 @@ type LoopAnimationConfig = { const loop = function ( animation: CompositeAnimation, + // $FlowFixMe[prop-missing] {iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {}, ): CompositeAnimation { let isFinished = false; @@ -523,6 +552,19 @@ const event = function ( } }; +// All types of animated nodes that represent scalar numbers and can be interpolated (etc) +type AnimatedNumeric = + | AnimatedAddition + | AnimatedDiffClamp + | AnimatedDivision + | AnimatedInterpolation + | AnimatedModulo + | AnimatedMultiplication + | AnimatedSubtraction + | AnimatedValue; + +export type {AnimatedNumeric as Numeric}; + /** * The `Animated` library is designed to make animations fluid, powerful, and * easy to build and maintain. `Animated` focuses on declarative relationships @@ -547,6 +589,10 @@ module.exports = { * See https://reactnative.dev/docs/animatedvaluexy */ ValueXY: AnimatedValueXY, + /** + * Value class for driving color animations. + */ + Color: AnimatedColor, /** * Exported to use the Interpolation type in flow. * diff --git a/Libraries/Animated/AnimatedMock.js b/Libraries/Animated/AnimatedMock.js index 8f69819310f3a6..b7af8042fb90e5 100644 --- a/Libraries/Animated/AnimatedMock.js +++ b/Libraries/Animated/AnimatedMock.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,6 +10,8 @@ 'use strict'; +import type {EndResult} from './animations/Animation'; + const {AnimatedEvent, attachNativeEvent} = require('./AnimatedEvent'); const AnimatedImplementation = require('./AnimatedImplementation'); const AnimatedInterpolation = require('./nodes/AnimatedInterpolation'); @@ -23,6 +25,8 @@ import type {EndCallback} from './animations/Animation'; import type {TimingAnimationConfig} from './animations/TimingAnimation'; import type {DecayAnimationConfig} from './animations/DecayAnimation'; import type {SpringAnimationConfig} from './animations/SpringAnimation'; +import type {Numeric as AnimatedNumeric} from './AnimatedImplementation'; +import AnimatedColor from './nodes/AnimatedColor'; /** * Animations are a source of flakiness in snapshot testing. This mock replaces @@ -41,7 +45,7 @@ function mockAnimationStart( const guardedCallback = callback == null ? callback - : (...args) => { + : (...args: Array) => { if (inAnimationCallback) { console.warn( 'Ignoring recursive animation callback when running mock animations', @@ -89,7 +93,7 @@ const mockCompositeAnimation = ( }); const spring = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: SpringAnimationConfig, ): CompositeAnimation { const anyValue: any = value; @@ -103,7 +107,7 @@ const spring = function ( }; const timing = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: TimingAnimationConfig, ): CompositeAnimation { const anyValue: any = value; @@ -117,7 +121,7 @@ const timing = function ( }; const decay = function ( - value: AnimatedValue | AnimatedValueXY, + value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: DecayAnimationConfig, ): CompositeAnimation { return emptyAnimation; @@ -156,14 +160,18 @@ type LoopAnimationConfig = { const loop = function ( animation: CompositeAnimation, + // $FlowFixMe[prop-missing] {iterations = -1}: LoopAnimationConfig = {}, ): CompositeAnimation { return emptyAnimation; }; +export type {AnimatedNumeric as Numeric}; + module.exports = { Value: AnimatedValue, ValueXY: AnimatedValueXY, + Color: AnimatedColor, Interpolation: AnimatedInterpolation, Node: AnimatedNode, decay, diff --git a/Libraries/ReactNative/UIManagerInjection.js b/Libraries/Animated/AnimatedPlatformConfig.js similarity index 59% rename from Libraries/ReactNative/UIManagerInjection.js rename to Libraries/Animated/AnimatedPlatformConfig.js index 00a16ac045780a..fb0b52f3f1c8bd 100644 --- a/Libraries/ReactNative/UIManagerInjection.js +++ b/Libraries/Animated/AnimatedPlatformConfig.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,6 @@ * @format */ -export default { - unstable_UIManager: (null: ?any), -}; +'use strict'; + +export type PlatformConfig = {}; diff --git a/Libraries/Animated/AnimatedWeb.js b/Libraries/Animated/AnimatedWeb.js index 513f322b709d08..e1c016b753241b 100644 --- a/Libraries/Animated/AnimatedWeb.js +++ b/Libraries/Animated/AnimatedWeb.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/Easing.js b/Libraries/Animated/Easing.js index 39f873b902c248..f8b5bac2f30404 100644 --- a/Libraries/Animated/Easing.js +++ b/Libraries/Animated/Easing.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -57,20 +57,20 @@ let ease; * - [`inOut`](docs/easing.html#inout) makes any easing function symmetrical * - [`out`](docs/easing.html#out) runs an easing function backwards */ -class Easing { +const Easing = { /** * A stepping function, returns 1 for any positive value of `n`. */ - static step0(n: number): number { + step0(n: number): number { return n > 0 ? 1 : 0; - } + }, /** * A stepping function, returns 1 if `n` is greater than or equal to 1. */ - static step1(n: number): number { + step1(n: number): number { return n >= 1 ? 1 : 0; - } + }, /** * A linear function, `f(t) = t`. Position correlates to elapsed time one to @@ -78,9 +78,9 @@ class Easing { * * http://cubic-bezier.com/#0,0,1,1 */ - static linear(t: number): number { + linear(t: number): number { return t; - } + }, /** * A simple inertial interaction, similar to an object slowly accelerating to @@ -88,12 +88,12 @@ class Easing { * * http://cubic-bezier.com/#.42,0,1,1 */ - static ease(t: number): number { + ease(t: number): number { if (!ease) { ease = Easing.bezier(0.42, 0, 1, 1); } return ease(t); - } + }, /** * A quadratic function, `f(t) = t * t`. Position equals the square of elapsed @@ -101,9 +101,9 @@ class Easing { * * http://easings.net/#easeInQuad */ - static quad(t: number): number { + quad(t: number): number { return t * t; - } + }, /** * A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed @@ -111,9 +111,9 @@ class Easing { * * http://easings.net/#easeInCubic */ - static cubic(t: number): number { + cubic(t: number): number { return t * t * t; - } + }, /** * A power function. Position is equal to the Nth power of elapsed time. @@ -121,36 +121,36 @@ class Easing { * n = 4: http://easings.net/#easeInQuart * n = 5: http://easings.net/#easeInQuint */ - static poly(n: number): (t: number) => number { + poly(n: number): (t: number) => number { return (t: number) => Math.pow(t, n); - } + }, /** * A sinusoidal function. * * http://easings.net/#easeInSine */ - static sin(t: number): number { + sin(t: number): number { return 1 - Math.cos((t * Math.PI) / 2); - } + }, /** * A circular function. * * http://easings.net/#easeInCirc */ - static circle(t: number): number { + circle(t: number): number { return 1 - Math.sqrt(1 - t * t); - } + }, /** * An exponential function. * * http://easings.net/#easeInExpo */ - static exp(t: number): number { + exp(t: number): number { return Math.pow(2, 10 * (t - 1)); - } + }, /** * A simple elastic interaction, similar to a spring oscillating back and @@ -162,10 +162,10 @@ class Easing { * * http://easings.net/#easeInElastic */ - static elastic(bounciness: number = 1): (t: number) => number { + elastic(bounciness: number = 1): (t: number) => number { const p = bounciness * Math.PI; return t => 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p); - } + }, /** * Use with `Animated.parallel()` to create a simple effect where the object @@ -173,16 +173,16 @@ class Easing { * * https://easings.net/#easeInBack */ - static back(s: number = 1.70158): (t: number) => number { + back(s: number = 1.70158): (t: number) => number { return t => t * t * ((s + 1) * t - s); - } + }, /** * Provides a simple bouncing effect. * * http://easings.net/#easeInBounce */ - static bounce(t: number): number { + bounce(t: number): number { if (t < 1 / 2.75) { return 7.5625 * t * t; } @@ -199,7 +199,7 @@ class Easing { const t2 = t - 2.625 / 2.75; return 7.5625 * t2 * t2 + 0.984375; - } + }, /** * Provides a cubic bezier curve, equivalent to CSS Transitions' @@ -208,7 +208,7 @@ class Easing { * A useful tool to visualize cubic bezier curves can be found at * http://cubic-bezier.com/ */ - static bezier( + bezier( x1: number, y1: number, x2: number, @@ -216,35 +216,35 @@ class Easing { ): (t: number) => number { const _bezier = require('./bezier'); return _bezier(x1, y1, x2, y2); - } + }, /** * Runs an easing function forwards. */ - static in(easing: (t: number) => number): (t: number) => number { + in(easing: (t: number) => number): (t: number) => number { return easing; - } + }, /** * Runs an easing function backwards. */ - static out(easing: (t: number) => number): (t: number) => number { + out(easing: (t: number) => number): (t: number) => number { return t => 1 - easing(1 - t); - } + }, /** * Makes any easing function symmetrical. The easing function will run * forwards for half of the duration, then backwards for the rest of the * duration. */ - static inOut(easing: (t: number) => number): (t: number) => number { + inOut(easing: (t: number) => number): (t: number) => number { return t => { if (t < 0.5) { return easing(t * 2) / 2; } return 1 - easing((1 - t) * 2) / 2; }; - } -} + }, +}; module.exports = Easing; diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index dff0f541d0837f..255f6a3ee9ff55 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,7 +20,10 @@ import type { } from './NativeAnimatedModule'; import type {AnimationConfig, EndCallback} from './animations/Animation'; import type {InterpolationConfigType} from './nodes/AnimatedInterpolation'; +import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags'; import invariant from 'invariant'; +import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter'; +import type {EventSubscription} from '../vendor/emitter/EventEmitter'; // TODO T69437152 @petetheheat - Delete this fork when Fabric ships to 100%. const NativeAnimatedModule = @@ -36,24 +39,83 @@ let nativeEventEmitter; let waitingForQueuedOperations = new Set(); let queueOperations = false; let queue: Array<() => void> = []; +// $FlowFixMe +let singleOpQueue: Array = []; + +const useSingleOpBatching = + Platform.OS === 'android' && + !!NativeAnimatedModule?.queueAndExecuteBatchedOperations && + ReactNativeFeatureFlags.animatedShouldUseSingleOp(); +let flushQueueTimeout = null; + +const eventListenerGetValueCallbacks = {}; +const eventListenerAnimationFinishedCallbacks = {}; +let globalEventEmitterGetValueListener: ?EventSubscription = null; +let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null; + +const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching + ? ((function () { + const apis = [ + 'createAnimatedNode', // 1 + 'updateAnimatedNodeConfig', // 2 + 'getValue', // 3 + 'startListeningToAnimatedNodeValue', // 4 + 'stopListeningToAnimatedNodeValue', // 5 + 'connectAnimatedNodes', // 6 + 'disconnectAnimatedNodes', // 7 + 'startAnimatingNode', // 8 + 'stopAnimation', // 9 + 'setAnimatedNodeValue', // 10 + 'setAnimatedNodeOffset', // 11 + 'flattenAnimatedNodeOffset', // 12 + 'extractAnimatedNodeOffset', // 13 + 'connectAnimatedNodeToView', // 14 + 'disconnectAnimatedNodeFromView', // 15 + 'restoreDefaultValues', // 16 + 'dropAnimatedNode', // 17 + 'addAnimatedEventToView', // 18 + 'removeAnimatedEventFromView', // 19 + 'addListener', // 20 + 'removeListener', // 21 + ]; + return apis.reduce((acc, functionName, i) => { + // These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform). + // $FlowFixMe[prop-missing] + acc[functionName] = i + 1; + return acc; + }, {}); + })(): $FlowFixMe) + : NativeAnimatedModule; /** - * Simple wrappers around NativeAnimatedModule to provide flow and autocomplete support for - * the native module methods + * Wrappers around NativeAnimatedModule to provide flow and autocomplete support for + * the native module methods, and automatic queue management on Android */ const API = { getValue: function ( tag: number, saveValueCallback: (value: number) => void, ): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => { - NativeAnimatedModule.getValue(tag, saveValueCallback); - }); + invariant(nativeOps, 'Native animated module is not available'); + if (useSingleOpBatching) { + if (saveValueCallback) { + eventListenerGetValueCallbacks[tag] = saveValueCallback; + } + // $FlowFixMe + API.queueOperation(nativeOps.getValue, tag); + } else { + API.queueOperation(nativeOps.getValue, tag, saveValueCallback); + } }, setWaitingForIdentifier: function (id: string): void { waitingForQueuedOperations.add(id); queueOperations = true; + if ( + ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush() && + flushQueueTimeout + ) { + clearTimeout(flushQueueTimeout); + } }, unsetWaitingForIdentifier: function (id: string): void { waitingForQueuedOperations.delete(id); @@ -64,58 +126,103 @@ const API = { } }, disableQueue: function (): void { + invariant(nativeOps, 'Native animated module is not available'); + + if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) { + const prevTimeout = flushQueueTimeout; + clearImmediate(prevTimeout); + flushQueueTimeout = setImmediate(API.flushQueue); + } else { + API.flushQueue(); + } + }, + flushQueue: function (): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); + flushQueueTimeout = null; - if (Platform.OS === 'android') { - NativeAnimatedModule.startOperationBatch(); + // Early returns before calling any APIs + if (useSingleOpBatching && singleOpQueue.length === 0) { + return; } - for (let q = 0, l = queue.length; q < l; q++) { - queue[q](); + if (!useSingleOpBatching && queue.length === 0) { + return; } - queue.length = 0; - if (Platform.OS === 'android') { - NativeAnimatedModule.finishOperationBatch(); + + if (useSingleOpBatching) { + // Set up event listener for callbacks if it's not set up + if ( + !globalEventEmitterGetValueListener || + !globalEventEmitterAnimationFinishedListener + ) { + setupGlobalEventEmitterListeners(); + } + // Single op batching doesn't use callback functions, instead we + // use RCTDeviceEventEmitter. This reduces overhead of sending lots of + // JSI functions across to native code; but also, TM infrastructure currently + // does not support packing a function into native arrays. + NativeAnimatedModule.queueAndExecuteBatchedOperations?.(singleOpQueue); + singleOpQueue.length = 0; + } else { + Platform.OS === 'android' && NativeAnimatedModule.startOperationBatch?.(); + for (let q = 0, l = queue.length; q < l; q++) { + queue[q](); + } + queue.length = 0; + Platform.OS === 'android' && + NativeAnimatedModule.finishOperationBatch?.(); } }, - queueOperation: (fn: () => void): void => { - if (queueOperations) { - queue.push(fn); + queueOperation: , Fn: (...Args) => void>( + fn: Fn, + ...args: Args + ): void => { + if (useSingleOpBatching) { + // Get the command ID from the queued function, and push that ID and any arguments needed to execute the operation + // $FlowFixMe: surprise, fn is actually a number + singleOpQueue.push(fn, ...args); + return; + } + + // If queueing is explicitly on, *or* the queue has not yet + // been flushed, use the queue. This is to prevent operations + // from being executed out of order. + if (queueOperations || queue.length !== 0) { + queue.push(() => fn(...args)); } else { - fn(); + fn(...args); } }, createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.createAnimatedNode(tag, config), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.createAnimatedNode, tag, config); + }, + updateAnimatedNodeConfig: function ( + tag: number, + config: AnimatedNodeConfig, + ): void { + invariant(nativeOps, 'Native animated module is not available'); + if (nativeOps.updateAnimatedNodeConfig) { + API.queueOperation(nativeOps.updateAnimatedNodeConfig, tag, config); + } }, startListeningToAnimatedNodeValue: function (tag: number) { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.startListeningToAnimatedNodeValue(tag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.startListeningToAnimatedNodeValue, tag); }, stopListeningToAnimatedNodeValue: function (tag: number) { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.stopListeningToAnimatedNodeValue(tag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.stopListeningToAnimatedNodeValue, tag); }, connectAnimatedNodes: function (parentTag: number, childTag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.connectAnimatedNodes(parentTag, childTag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.connectAnimatedNodes, parentTag, childTag); }, disconnectAnimatedNodes: function ( parentTag: number, childTag: number, ): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.disconnectAnimatedNodes, parentTag, childTag); }, startAnimatingNode: function ( animationId: number, @@ -123,84 +230,85 @@ const API = { config: AnimatingNodeConfig, endCallback: EndCallback, ): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.startAnimatingNode( + invariant(nativeOps, 'Native animated module is not available'); + if (useSingleOpBatching) { + if (endCallback) { + eventListenerAnimationFinishedCallbacks[animationId] = endCallback; + } + // $FlowFixMe + API.queueOperation( + nativeOps.startAnimatingNode, + animationId, + nodeTag, + config, + ); + } else { + API.queueOperation( + nativeOps.startAnimatingNode, animationId, nodeTag, config, endCallback, - ), - ); + ); + } }, stopAnimation: function (animationId: number) { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => NativeAnimatedModule.stopAnimation(animationId)); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.stopAnimation, animationId); }, setAnimatedNodeValue: function (nodeTag: number, value: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.setAnimatedNodeValue(nodeTag, value), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.setAnimatedNodeValue, nodeTag, value); }, setAnimatedNodeOffset: function (nodeTag: number, offset: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.setAnimatedNodeOffset, nodeTag, offset); }, flattenAnimatedNodeOffset: function (nodeTag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.flattenAnimatedNodeOffset, nodeTag); }, extractAnimatedNodeOffset: function (nodeTag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.extractAnimatedNodeOffset(nodeTag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.extractAnimatedNodeOffset, nodeTag); }, connectAnimatedNodeToView: function (nodeTag: number, viewTag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag), - ); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.connectAnimatedNodeToView, nodeTag, viewTag); }, disconnectAnimatedNodeFromView: function ( nodeTag: number, viewTag: number, ): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.disconnectAnimatedNodeFromView(nodeTag, viewTag), + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation( + nativeOps.disconnectAnimatedNodeFromView, + nodeTag, + viewTag, ); }, restoreDefaultValues: function (nodeTag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); + invariant(nativeOps, 'Native animated module is not available'); // Backwards compat with older native runtimes, can be removed later. - if (NativeAnimatedModule.restoreDefaultValues != null) { - API.queueOperation(() => - NativeAnimatedModule.restoreDefaultValues(nodeTag), - ); + if (nativeOps.restoreDefaultValues != null) { + API.queueOperation(nativeOps.restoreDefaultValues, nodeTag); } }, dropAnimatedNode: function (tag: number): void { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => NativeAnimatedModule.dropAnimatedNode(tag)); + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation(nativeOps.dropAnimatedNode, tag); }, addAnimatedEventToView: function ( viewTag: number, eventName: string, eventMapping: EventMapping, ) { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.addAnimatedEventToView( - viewTag, - eventName, - eventMapping, - ), + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation( + nativeOps.addAnimatedEventToView, + viewTag, + eventName, + eventMapping, ); }, removeAnimatedEventFromView( @@ -208,36 +316,77 @@ const API = { eventName: string, animatedNodeTag: number, ) { - invariant(NativeAnimatedModule, 'Native animated module is not available'); - API.queueOperation(() => - NativeAnimatedModule.removeAnimatedEventFromView( - viewTag, - eventName, - animatedNodeTag, - ), + invariant(nativeOps, 'Native animated module is not available'); + API.queueOperation( + nativeOps.removeAnimatedEventFromView, + viewTag, + eventName, + animatedNodeTag, ); }, }; +function setupGlobalEventEmitterListeners() { + globalEventEmitterGetValueListener = RCTDeviceEventEmitter.addListener( + 'onNativeAnimatedModuleGetValue', + function (params) { + const {tag} = params; + const callback = eventListenerGetValueCallbacks[tag]; + if (!callback) { + return; + } + callback(params.value); + delete eventListenerGetValueCallbacks[tag]; + }, + ); + globalEventEmitterAnimationFinishedListener = + RCTDeviceEventEmitter.addListener( + 'onNativeAnimatedModuleAnimationFinished', + function (params) { + const {animationId} = params; + const callback = eventListenerAnimationFinishedCallbacks[animationId]; + if (!callback) { + return; + } + callback(params); + delete eventListenerAnimationFinishedCallbacks[animationId]; + }, + ); +} + /** * Styles allowed by the native animated implementation. * - * In general native animated implementation should support any numeric property that doesn't need - * to be updated through the shadow view hierarchy (all non-layout properties). + * In general native animated implementation should support any numeric or color property that + * doesn't need to be updated through the shadow view hierarchy (all non-layout properties). */ +const SUPPORTED_COLOR_STYLES = { + backgroundColor: true, + borderBottomColor: true, + borderColor: true, + borderEndColor: true, + borderLeftColor: true, + borderRightColor: true, + borderStartColor: true, + borderTopColor: true, + color: true, + tintColor: true, +}; + const SUPPORTED_STYLES = { - opacity: true, - transform: true, - borderRadius: true, + ...SUPPORTED_COLOR_STYLES, borderBottomEndRadius: true, borderBottomLeftRadius: true, borderBottomRightRadius: true, borderBottomStartRadius: true, + borderRadius: true, borderTopEndRadius: true, borderTopLeftRadius: true, borderTopRightRadius: true, borderTopStartRadius: true, elevation: true, + opacity: true, + transform: true, zIndex: true, /* ios styles */ shadowOpacity: true, @@ -282,6 +431,22 @@ function addWhitelistedInterpolationParam(param: string): void { SUPPORTED_INTERPOLATION_PARAMS[param] = true; } +function isSupportedColorStyleProp(prop: string): boolean { + return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop); +} + +function isSupportedStyleProp(prop: string): boolean { + return SUPPORTED_STYLES.hasOwnProperty(prop); +} + +function isSupportedTransformProp(prop: string): boolean { + return SUPPORTED_TRANSFORMS.hasOwnProperty(prop); +} + +function isSupportedInterpolationParam(param: string): boolean { + return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param); +} + function validateTransform( configs: Array< | { @@ -299,7 +464,7 @@ function validateTransform( >, ): void { configs.forEach(config => { - if (!SUPPORTED_TRANSFORMS.hasOwnProperty(config.property)) { + if (!isSupportedTransformProp(config.property)) { throw new Error( `Property '${config.property}' is not supported by native animated module`, ); @@ -309,7 +474,7 @@ function validateTransform( function validateStyles(styles: {[key: string]: ?number, ...}): void { for (const key in styles) { - if (!SUPPORTED_STYLES.hasOwnProperty(key)) { + if (!isSupportedStyleProp(key)) { throw new Error( `Style property '${key}' is not supported by native animated module`, ); @@ -317,9 +482,11 @@ function validateStyles(styles: {[key: string]: ?number, ...}): void { } } -function validateInterpolation(config: InterpolationConfigType): void { +function validateInterpolation( + config: InterpolationConfigType, +): void { for (const key in config) { - if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) { + if (!isSupportedInterpolationParam(key)) { throw new Error( `Interpolation property '${key}' is not supported by native animated module`, ); @@ -342,7 +509,7 @@ function assertNativeAnimatedModule(): void { let _warnedMissingNativeAnimated = false; function shouldUseNativeDriver( - config: {...AnimationConfig, ...} | EventConfig, + config: $ReadOnly<{...AnimationConfig, ...}> | EventConfig, ): boolean { if (config.useNativeDriver == null) { console.warn( @@ -385,6 +552,10 @@ function transformDataType(value: number | string): number | string { module.exports = { API, + isSupportedColorStyleProp, + isSupportedStyleProp, + isSupportedTransformProp, + isSupportedInterpolationParam, addWhitelistedStyleProp, addWhitelistedTransformProp, addWhitelistedInterpolationParam, diff --git a/Libraries/Animated/NativeAnimatedModule.js b/Libraries/Animated/NativeAnimatedModule.js index d126bfdaff96eb..73f3bb76f90c08 100644 --- a/Libraries/Animated/NativeAnimatedModule.js +++ b/Libraries/Animated/NativeAnimatedModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,6 +29,7 @@ export interface Spec extends TurboModule { +startOperationBatch: () => void; +finishOperationBatch: () => void; +createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void; + +updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void; +getValue: (tag: number, saveValueCallback: SaveValueCallback) => void; +startListeningToAnimatedNodeValue: (tag: number) => void; +stopListeningToAnimatedNodeValue: (tag: number) => void; @@ -63,6 +64,9 @@ export interface Spec extends TurboModule { // Events +addListener: (eventName: string) => void; +removeListeners: (count: number) => void; + + // All of the above in a batched mode + +queueAndExecuteBatchedOperations?: (operationsAndArgs: Array) => void; } export default (TurboModuleRegistry.get('NativeAnimatedModule'): ?Spec); diff --git a/Libraries/Animated/NativeAnimatedTurboModule.js b/Libraries/Animated/NativeAnimatedTurboModule.js index 03ff0f26116560..3adac4237daed4 100644 --- a/Libraries/Animated/NativeAnimatedTurboModule.js +++ b/Libraries/Animated/NativeAnimatedTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,6 +29,7 @@ export interface Spec extends TurboModule { +startOperationBatch: () => void; +finishOperationBatch: () => void; +createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void; + +updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void; +getValue: (tag: number, saveValueCallback: SaveValueCallback) => void; +startListeningToAnimatedNodeValue: (tag: number) => void; +stopListeningToAnimatedNodeValue: (tag: number) => void; @@ -63,6 +64,9 @@ export interface Spec extends TurboModule { // Events +addListener: (eventName: string) => void; +removeListeners: (count: number) => void; + + // All of the above in a batched mode + +queueAndExecuteBatchedOperations?: (operationsAndArgs: Array) => void; } export default (TurboModuleRegistry.get( diff --git a/Libraries/Animated/SpringConfig.js b/Libraries/Animated/SpringConfig.js index a1a00ec0c1a6e8..c687f6b97126eb 100644 --- a/Libraries/Animated/SpringConfig.js +++ b/Libraries/Animated/SpringConfig.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/__tests__/Animated-test.js b/Libraries/Animated/__tests__/Animated-test.js index 21aa7358e2a8d8..8f62804c73b781 100644 --- a/Libraries/Animated/__tests__/Animated-test.js +++ b/Libraries/Animated/__tests__/Animated-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -782,6 +782,19 @@ describe('Animated tests', () => { value1.setValue(1492); expect(value2.__getValue()).toBe(7); }); + + it('should start tracking immediately on animation start', () => { + const value1 = new Animated.Value(42); + const value2 = new Animated.Value(0); + Animated.timing(value2, { + toValue: value1, + duration: 0, + useNativeDriver: false, + }).start(); + expect(value2.__getValue()).toBe(42); + value1.setValue(7); + expect(value2.__getValue()).toBe(7); + }); }); describe('Animated Vectors', () => { @@ -959,4 +972,115 @@ describe('Animated tests', () => { } }); }); + + describe('Animated Colors', () => { + it('should normalize colors', () => { + let color = new Animated.Color(); + expect(color.__getValue()).toEqual('rgba(0, 0, 0, 1)'); + + color = new Animated.Color({r: 11, g: 22, b: 33, a: 1.0}); + expect(color.__getValue()).toEqual('rgba(11, 22, 33, 1)'); + + color = new Animated.Color('rgba(255, 0, 0, 1.0)'); + expect(color.__getValue()).toEqual('rgba(255, 0, 0, 1)'); + + color = new Animated.Color('#ff0000ff'); + expect(color.__getValue()).toEqual('rgba(255, 0, 0, 1)'); + + color = new Animated.Color('red'); + expect(color.__getValue()).toEqual('rgba(255, 0, 0, 1)'); + + color = new Animated.Color({ + r: new Animated.Value(255), + g: new Animated.Value(0), + b: new Animated.Value(0), + a: new Animated.Value(1.0), + }); + expect(color.__getValue()).toEqual('rgba(255, 0, 0, 1)'); + + color = new Animated.Color('unknown'); + expect(color.__getValue()).toEqual('rgba(0, 0, 0, 1)'); + + color = new Animated.Color({key: 'value'}); + expect(color.__getValue()).toEqual('rgba(0, 0, 0, 1)'); + }); + + it('should animate colors', () => { + const color = new Animated.Color({r: 255, g: 0, b: 0, a: 1.0}); + const callback = jest.fn(); + const node = new AnimatedProps( + { + style: { + backgroundColor: color, + transform: [ + { + scale: color.a.interpolate({ + inputRange: [0, 1], + outputRange: [1, 2], + }), + }, + ], + }, + }, + callback, + ); + + expect(node.__getValue()).toEqual({ + style: { + backgroundColor: 'rgba(255, 0, 0, 1)', + transform: [{scale: 2}], + }, + }); + + node.__attach(); + expect(callback.mock.calls.length).toBe(0); + + color.setValue({r: 11, g: 22, b: 33, a: 0.5}); + expect(callback.mock.calls.length).toBe(4); + expect(node.__getValue()).toEqual({ + style: { + backgroundColor: 'rgba(11, 22, 33, 0.5)', + transform: [{scale: 1.5}], + }, + }); + + node.__detach(); + color.setValue({r: 255, g: 0, b: 0, a: 1.0}); + expect(callback.mock.calls.length).toBe(4); + }); + + it('should track colors', () => { + const color1 = new Animated.Color(); + const color2 = new Animated.Color(); + Animated.timing(color2, { + toValue: color1, + duration: 0, + useNativeDriver: false, + }).start(); + color1.setValue({r: 11, g: 22, b: 33, a: 0.5}); + expect(color2.__getValue()).toEqual('rgba(11, 22, 33, 0.5)'); + + // Make sure tracking keeps working (see stopTogether in ParallelConfig used + // by maybeVectorAnim). + color1.setValue({r: 255, g: 0, b: 0, a: 1.0}); + expect(color2.__getValue()).toEqual('rgba(255, 0, 0, 1)'); + }); + + it('should track with springs', () => { + const color1 = new Animated.Color(); + const color2 = new Animated.Color(); + Animated.spring(color2, { + toValue: color1, + tension: 3000, // faster spring for faster test + friction: 60, + useNativeDriver: false, + }).start(); + color1.setValue({r: 11, g: 22, b: 33, a: 0.5}); + jest.runAllTimers(); + expect(color2.__getValue()).toEqual('rgba(11, 22, 33, 0.5)'); + color1.setValue({r: 44, g: 55, b: 66, a: 0.0}); + jest.runAllTimers(); + expect(color2.__getValue()).toEqual('rgba(44, 55, 66, 0)'); + }); + }); }); diff --git a/Libraries/Animated/__tests__/AnimatedMock-test.js b/Libraries/Animated/__tests__/AnimatedMock-test.js index 8ba4e998b36564..cc510feefefb33 100644 --- a/Libraries/Animated/__tests__/AnimatedMock-test.js +++ b/Libraries/Animated/__tests__/AnimatedMock-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/__tests__/AnimatedNative-test.js b/Libraries/Animated/__tests__/AnimatedNative-test.js index 597aae9b6c4b0f..677527e22c9d15 100644 --- a/Libraries/Animated/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/__tests__/AnimatedNative-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -134,6 +134,28 @@ describe('Native Animated', () => { expect(opacity.__getValue()).toBe(1); }); + it('should deduct offset when saving value on unmount', () => { + NativeAnimatedModule.getValue = jest.fn((tag, saveCallback) => { + // Assume current raw value of value node is 0.5, the NativeAnimated + // getValue API returns the sum of raw value and offset, so return 1. + saveCallback(1); + }); + const opacity = new Animated.Value(0); + opacity.setOffset(0.5); + opacity.__makeNative(); + + const root = TestRenderer.create(); + const tag = opacity.__getNativeTag(); + + root.unmount(); + + expect(NativeAnimatedModule.getValue).toBeCalledWith( + tag, + expect.any(Function), + ); + expect(opacity.__getValue()).toBe(1); + }); + it('should extract offset', () => { const opacity = new Animated.Value(0); opacity.__makeNative(); @@ -928,6 +950,30 @@ describe('Native Animated', () => { animation.stop(); expect(NativeAnimatedModule.stopAnimation).toBeCalledWith(animationId); }); + + it('calls stopAnimation callback with native value', () => { + NativeAnimatedModule.getValue = jest.fn((tag, saveCallback) => { + saveCallback(1); + }); + + const anim = new Animated.Value(0); + Animated.timing(anim, { + duration: 1000, + useNativeDriver: true, + }).start(); + + const tag = anim.__getNativeTag(); + + let currentValue = 0; + anim.stopAnimation(value => (currentValue = value)); + + expect(NativeAnimatedModule.getValue).toBeCalledWith( + tag, + expect.any(Function), + ); + + expect(currentValue).toEqual(1); + }); }); describe('Animated Components', () => { diff --git a/Libraries/Animated/__tests__/Easing-test.js b/Libraries/Animated/__tests__/Easing-test.js index a478919587c007..8efeed00037d74 100644 --- a/Libraries/Animated/__tests__/Easing-test.js +++ b/Libraries/Animated/__tests__/Easing-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/__tests__/Interpolation-test.js b/Libraries/Animated/__tests__/Interpolation-test.js index 2bdebfd4935c53..64585ac683bd9a 100644 --- a/Libraries/Animated/__tests__/Interpolation-test.js +++ b/Libraries/Animated/__tests__/Interpolation-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/__tests__/TimingAnimation-test.js b/Libraries/Animated/__tests__/TimingAnimation-test.js index 8576ea426ba8e6..e82407876a2d9c 100644 --- a/Libraries/Animated/__tests__/TimingAnimation-test.js +++ b/Libraries/Animated/__tests__/TimingAnimation-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/__tests__/bezier-test.js b/Libraries/Animated/__tests__/bezier-test.js index 846edc12828bfe..48bfdef0f2d605 100644 --- a/Libraries/Animated/__tests__/bezier-test.js +++ b/Libraries/Animated/__tests__/bezier-test.js @@ -1,5 +1,5 @@ /** - * Portions Copyright (c) Facebook, Inc. and its affiliates. + * Portions 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. @@ -19,21 +19,26 @@ const bezier = require('../bezier'); -const identity = function (x) { +const identity = function (x: number) { return x; }; -function assertClose(a, b, precision = 3) { +function assertClose(a: number, b: number, precision: number = 3) { expect(a).toBeCloseTo(b, precision); } -function makeAssertCloseWithPrecision(precision) { - return function (a, b) { +function makeAssertCloseWithPrecision(precision: number) { + return function (a: number, b: number) { assertClose(a, b, precision); }; } -function allEquals(be1, be2, samples, assertion) { +function allEquals( + be1: (x: number) => number, + be2: (x: number) => number, + samples: number, + assertion: $FlowFixMe, +) { if (!assertion) { assertion = assertClose; } @@ -43,8 +48,8 @@ function allEquals(be1, be2, samples, assertion) { } } -function repeat(n) { - return function (f) { +function repeat(n: number) { + return function (f: () => void) { for (let i = 0; i < n; ++i) { f(); } @@ -99,7 +104,7 @@ describe('bezier', function () { d = Math.random(); const easing = bezier(a, b, c, d); const projected = bezier(b, a, d, c); - const composed = function (x) { + const composed = function (x: number) { return projected(easing(x)); }; allEquals(identity, composed, 100, makeAssertCloseWithPrecision(2)); @@ -135,7 +140,7 @@ describe('bezier', function () { c = 1 - a, d = 1 - b; const easing = bezier(a, b, c, d); - const sym = function (x) { + const sym = function (x: number) { return 1 - easing(1 - x); }; allEquals(easing, sym, 100, makeAssertCloseWithPrecision(2)); diff --git a/Libraries/Animated/__tests__/createAnimatedComponentInjection-test.js b/Libraries/Animated/__tests__/createAnimatedComponentInjection-test.js index e82ea170a3eb95..9d8fa9b1869d99 100644 --- a/Libraries/Animated/__tests__/createAnimatedComponentInjection-test.js +++ b/Libraries/Animated/__tests__/createAnimatedComponentInjection-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/animations/Animation.js b/Libraries/Animated/animations/Animation.js index 3555bf2cc2665a..f22c5e9e4adaa5 100644 --- a/Libraries/Animated/animations/Animation.js +++ b/Libraries/Animated/animations/Animation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,7 +11,7 @@ 'use strict'; const NativeAnimatedHelper = require('../NativeAnimatedHelper'); - +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type AnimatedValue from '../nodes/AnimatedValue'; export type EndResult = {finished: boolean, ...}; @@ -20,6 +20,7 @@ export type EndCallback = (result: EndResult) => void; export type AnimationConfig = { isInteraction?: boolean, useNativeDriver: boolean, + platformConfig?: PlatformConfig, onComplete?: ?EndCallback, iterations?: number, }; @@ -65,12 +66,13 @@ class Animation { startNativeAnimationWaitId, ); try { - animatedValue.__makeNative(); + const config = this.__getNativeAnimationConfig(); + animatedValue.__makeNative(config.platformConfig); this.__nativeId = NativeAnimatedHelper.generateNewAnimationId(); NativeAnimatedHelper.API.startAnimatingNode( this.__nativeId, animatedValue.__getNativeTag(), - this.__getNativeAnimationConfig(), + config, // $FlowFixMe[method-unbinding] added when improving typing for this parameters this.__debouncedOnEnd.bind(this), ); diff --git a/Libraries/Animated/animations/DecayAnimation.js b/Libraries/Animated/animations/DecayAnimation.js index b04b911e7600c7..c53ff08ac0fea4 100644 --- a/Libraries/Animated/animations/DecayAnimation.js +++ b/Libraries/Animated/animations/DecayAnimation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,7 @@ const Animation = require('./Animation'); const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type AnimatedValue from '../nodes/AnimatedValue'; import type {AnimationConfig, EndCallback} from './Animation'; @@ -44,12 +45,14 @@ class DecayAnimation extends Animation { _onUpdate: (value: number) => void; _animationFrame: any; _useNativeDriver: boolean; + _platformConfig: ?PlatformConfig; constructor(config: DecayAnimationConfigSingle) { super(); this._deceleration = config.deceleration ?? 0.998; this._velocity = config.velocity; this._useNativeDriver = shouldUseNativeDriver(config); + this._platformConfig = config.platformConfig; this.__isInteraction = config.isInteraction ?? !this._useNativeDriver; this.__iterations = config.iterations ?? 1; } @@ -57,6 +60,7 @@ class DecayAnimation extends Animation { __getNativeAnimationConfig(): {| deceleration: number, iterations: number, + platformConfig: ?PlatformConfig, type: $TEMPORARY$string<'decay'>, velocity: number, |} { @@ -65,6 +69,7 @@ class DecayAnimation extends Animation { deceleration: this._deceleration, velocity: this._velocity, iterations: this.__iterations, + platformConfig: this._platformConfig, }; } diff --git a/Libraries/Animated/animations/SpringAnimation.js b/Libraries/Animated/animations/SpringAnimation.js index e09db93b7c5340..e02ed31872daa7 100644 --- a/Libraries/Animated/animations/SpringAnimation.js +++ b/Libraries/Animated/animations/SpringAnimation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,8 +20,11 @@ const invariant = require('invariant'); const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type {AnimationConfig, EndCallback} from './Animation'; +import AnimatedColor from '../nodes/AnimatedColor'; + export type SpringAnimationConfig = { ...AnimationConfig, toValue: @@ -33,7 +36,15 @@ export type SpringAnimationConfig = { ... } | AnimatedValueXY - | AnimatedInterpolation, + | { + r: number, + g: number, + b: number, + a: number, + ... + } + | AnimatedColor + | AnimatedInterpolation, overshootClamping?: boolean, restDisplacementThreshold?: number, restSpeedThreshold?: number, @@ -56,7 +67,7 @@ export type SpringAnimationConfig = { export type SpringAnimationConfigSingle = { ...AnimationConfig, - toValue: number | AnimatedValue | AnimatedInterpolation, + toValue: number, overshootClamping?: boolean, restDisplacementThreshold?: number, restSpeedThreshold?: number, @@ -79,7 +90,7 @@ class SpringAnimation extends Animation { _startPosition: number; _lastPosition: number; _fromValue: number; - _toValue: any; + _toValue: number; _stiffness: number; _damping: number; _mass: number; @@ -92,6 +103,7 @@ class SpringAnimation extends Animation { _onUpdate: (value: number) => void; _animationFrame: any; _useNativeDriver: boolean; + _platformConfig: ?PlatformConfig; constructor(config: SpringAnimationConfigSingle) { super(); @@ -104,6 +116,7 @@ class SpringAnimation extends Animation { this._toValue = config.toValue; this._delay = config.delay ?? 0; this._useNativeDriver = shouldUseNativeDriver(config); + this._platformConfig = config.platformConfig; this.__isInteraction = config.isInteraction ?? !this._useNativeDriver; this.__iterations = config.iterations ?? 1; @@ -162,6 +175,7 @@ class SpringAnimation extends Animation { initialVelocity: number, iterations: number, mass: number, + platformConfig: ?PlatformConfig, overshootClamping: boolean, restDisplacementThreshold: number, restSpeedThreshold: number, @@ -180,6 +194,7 @@ class SpringAnimation extends Animation { initialVelocity: this._initialVelocity ?? this._lastVelocity, toValue: this._toValue, iterations: this.__iterations, + platformConfig: this._platformConfig, }; } diff --git a/Libraries/Animated/animations/TimingAnimation.js b/Libraries/Animated/animations/TimingAnimation.js index 7f239ce0102faf..94c4b3a4b8361b 100644 --- a/Libraries/Animated/animations/TimingAnimation.js +++ b/Libraries/Animated/animations/TimingAnimation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,9 +17,13 @@ const Animation = require('./Animation'); const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type {AnimationConfig, EndCallback} from './Animation'; +import type {RgbaValue} from '../nodes/AnimatedColor'; -export type TimingAnimationConfig = { +import AnimatedColor from '../nodes/AnimatedColor'; + +export type TimingAnimationConfig = $ReadOnly<{ ...AnimationConfig, toValue: | number @@ -30,25 +34,26 @@ export type TimingAnimationConfig = { ... } | AnimatedValueXY - | AnimatedInterpolation, + | RgbaValue + | AnimatedColor + | AnimatedInterpolation, easing?: (value: number) => number, duration?: number, delay?: number, -}; +}>; -export type TimingAnimationConfigSingle = { +export type TimingAnimationConfigSingle = $ReadOnly<{ ...AnimationConfig, - toValue: number | AnimatedValue | AnimatedInterpolation, + toValue: number, easing?: (value: number) => number, duration?: number, delay?: number, -}; +}>; let _easeInOut; function easeInOut() { if (!_easeInOut) { const Easing = require('../Easing'); - // $FlowFixMe[method-unbinding] _easeInOut = Easing.inOut(Easing.ease); } return _easeInOut; @@ -57,7 +62,7 @@ function easeInOut() { class TimingAnimation extends Animation { _startTime: number; _fromValue: number; - _toValue: any; + _toValue: number; _duration: number; _delay: number; _easing: (value: number) => number; @@ -65,6 +70,7 @@ class TimingAnimation extends Animation { _animationFrame: any; _timeout: any; _useNativeDriver: boolean; + _platformConfig: ?PlatformConfig; constructor(config: TimingAnimationConfigSingle) { super(); @@ -74,6 +80,7 @@ class TimingAnimation extends Animation { this._delay = config.delay ?? 0; this.__iterations = config.iterations ?? 1; this._useNativeDriver = shouldUseNativeDriver(config); + this._platformConfig = config.platformConfig; this.__isInteraction = config.isInteraction ?? !this._useNativeDriver; } @@ -90,6 +97,7 @@ class TimingAnimation extends Animation { frames, toValue: this._toValue, iterations: this.__iterations, + platformConfig: this._platformConfig, }; } diff --git a/Libraries/Animated/bezier.js b/Libraries/Animated/bezier.js index 26c15718693fa1..da60afa0ec32e5 100644 --- a/Libraries/Animated/bezier.js +++ b/Libraries/Animated/bezier.js @@ -1,5 +1,5 @@ /** - * Portions Copyright (c) Facebook, Inc. and its affiliates. + * Portions 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. diff --git a/Libraries/Animated/components/AnimatedFlatList.js b/Libraries/Animated/components/AnimatedFlatList.js index 49a1ebcbd19b37..ebe160f12e7545 100644 --- a/Libraries/Animated/components/AnimatedFlatList.js +++ b/Libraries/Animated/components/AnimatedFlatList.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/components/AnimatedImage.js b/Libraries/Animated/components/AnimatedImage.js index c11cd41ff2a3f0..b0e7b9042020c2 100644 --- a/Libraries/Animated/components/AnimatedImage.js +++ b/Libraries/Animated/components/AnimatedImage.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/components/AnimatedScrollView.js b/Libraries/Animated/components/AnimatedScrollView.js index 8769f9382fd56e..887948366ac849 100644 --- a/Libraries/Animated/components/AnimatedScrollView.js +++ b/Libraries/Animated/components/AnimatedScrollView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/components/AnimatedSectionList.js b/Libraries/Animated/components/AnimatedSectionList.js index 98ccd918460bc6..2c467a66998282 100644 --- a/Libraries/Animated/components/AnimatedSectionList.js +++ b/Libraries/Animated/components/AnimatedSectionList.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/components/AnimatedText.js b/Libraries/Animated/components/AnimatedText.js index 98a0718f165290..0cd6cd5245d301 100644 --- a/Libraries/Animated/components/AnimatedText.js +++ b/Libraries/Animated/components/AnimatedText.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/components/AnimatedView.js b/Libraries/Animated/components/AnimatedView.js index 8f570cb371cd88..75358b003d5dfc 100644 --- a/Libraries/Animated/components/AnimatedView.js +++ b/Libraries/Animated/components/AnimatedView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/createAnimatedComponent.js b/Libraries/Animated/createAnimatedComponent.js index 25fd72fb269196..c9dbe808ed713f 100644 --- a/Libraries/Animated/createAnimatedComponent.js +++ b/Libraries/Animated/createAnimatedComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,8 +24,8 @@ const setAndForwardRef = require('../Utilities/setAndForwardRef'); let animatedComponentNextId = 1; export type AnimatedComponentType< - Props: {+[string]: mixed, ...}, - Instance, + -Props: {+[string]: mixed, ...}, + +Instance = mixed, > = React.AbstractComponent< $ObjMap< Props & @@ -55,6 +55,7 @@ function createAnimatedComponent( _prevComponent: any; _propsAnimated: AnimatedProps; _eventDetachers: Array = []; + _initialAnimatedProps: Object; // Only to be used in this file, and only in Fabric. _animatedComponentId: string = `${animatedComponentNextId++}:animatedComponent`; @@ -200,11 +201,17 @@ function createAnimatedComponent( }); render() { - const {style = {}, ...props} = this._propsAnimated.__getValue() || {}; + const animatedProps = + this._propsAnimated.__getValue(this._initialAnimatedProps) || {}; + const {style = {}, ...props} = animatedProps; const {style: passthruStyle = {}, ...passthruProps} = this.props.passthroughAnimatedPropExplicitValues || {}; const mergedStyle = {...style, ...passthruStyle}; + if (!this._initialAnimatedProps) { + this._initialAnimatedProps = animatedProps; + } + // Force `collapsable` to be false so that native view is not flattened. // Flattened views cannot be accurately referenced by a native driver. return ( diff --git a/Libraries/Animated/createAnimatedComponentInjection.js b/Libraries/Animated/createAnimatedComponentInjection.js index 5a1727e959a9b7..ab172bf12ca21d 100644 --- a/Libraries/Animated/createAnimatedComponentInjection.js +++ b/Libraries/Animated/createAnimatedComponentInjection.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js b/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js index a7d5f8169e5636..b2cd04ac56e44b 100644 --- a/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +++ b/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Animated/nodes/AnimatedAddition.js b/Libraries/Animated/nodes/AnimatedAddition.js index e2887ab8299321..b311b39a6606fc 100644 --- a/Libraries/Animated/nodes/AnimatedAddition.js +++ b/Libraries/Animated/nodes/AnimatedAddition.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,6 +15,7 @@ const AnimatedNode = require('./AnimatedNode'); const AnimatedValue = require('./AnimatedValue'); const AnimatedWithChildren = require('./AnimatedWithChildren'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type {InterpolationConfigType} from './AnimatedInterpolation'; class AnimatedAddition extends AnimatedWithChildren { @@ -27,17 +28,19 @@ class AnimatedAddition extends AnimatedWithChildren { this._b = typeof b === 'number' ? new AnimatedValue(b) : b; } - __makeNative() { - this._a.__makeNative(); - this._b.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + this._b.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number { return this._a.__getValue() + this._b.__getValue(); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } diff --git a/Libraries/Animated/nodes/AnimatedColor.js b/Libraries/Animated/nodes/AnimatedColor.js new file mode 100644 index 00000000000000..16a87f52800350 --- /dev/null +++ b/Libraries/Animated/nodes/AnimatedColor.js @@ -0,0 +1,353 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import AnimatedValue from './AnimatedValue'; +import AnimatedWithChildren from './AnimatedWithChildren'; +import normalizeColor from '../../StyleSheet/normalizeColor'; +import {processColorObject} from '../../StyleSheet/PlatformColorValueTypes'; +import NativeAnimatedHelper from '../NativeAnimatedHelper'; + +import type {PlatformConfig} from '../AnimatedPlatformConfig'; +import type {ColorValue} from '../../StyleSheet/StyleSheet'; +import type {NativeColorValue} from '../../StyleSheet/PlatformColorValueTypes'; +import type {ProcessedColorValue} from '../../StyleSheet/processColor'; + +export type AnimatedColorConfig = $ReadOnly<{ + useNativeDriver: boolean, +}>; + +type ColorListenerCallback = (value: ColorValue) => mixed; + +export type RgbaValue = { + +r: number, + +g: number, + +b: number, + +a: number, + ... +}; + +type RgbaAnimatedValue = { + +r: AnimatedValue, + +g: AnimatedValue, + +b: AnimatedValue, + +a: AnimatedValue, + ... +}; + +const NativeAnimatedAPI = NativeAnimatedHelper.API; + +const defaultColor: RgbaValue = {r: 0, g: 0, b: 0, a: 1.0}; +let _uniqueId = 1; + +/* eslint no-bitwise: 0 */ +function processColor( + color?: ?(ColorValue | RgbaValue), +): ?(RgbaValue | NativeColorValue) { + if (color === undefined || color === null) { + return null; + } + + if (isRgbaValue(color)) { + // $FlowIgnore[incompatible-cast] - Type is verified above + return (color: RgbaValue); + } + + let normalizedColor: ?ProcessedColorValue = normalizeColor( + // $FlowIgnore[incompatible-cast] - Type is verified above + (color: ColorValue), + ); + if (normalizedColor === undefined || normalizedColor === null) { + return null; + } + + if (typeof normalizedColor === 'object') { + const processedColorObj: ?NativeColorValue = + processColorObject(normalizedColor); + if (processedColorObj != null) { + return processedColorObj; + } + } else if (typeof normalizedColor === 'number') { + const r: number = (normalizedColor & 0xff000000) >>> 24; + const g: number = (normalizedColor & 0x00ff0000) >>> 16; + const b: number = (normalizedColor & 0x0000ff00) >>> 8; + const a: number = (normalizedColor & 0x000000ff) / 255; + + return {r, g, b, a}; + } + + return null; +} + +function isRgbaValue(value: any): boolean { + return ( + value && + typeof value.r === 'number' && + typeof value.g === 'number' && + typeof value.b === 'number' && + typeof value.a === 'number' + ); +} + +function isRgbaAnimatedValue(value: any): boolean { + return ( + value && + value.r instanceof AnimatedValue && + value.g instanceof AnimatedValue && + value.b instanceof AnimatedValue && + value.a instanceof AnimatedValue + ); +} + +export default class AnimatedColor extends AnimatedWithChildren { + r: AnimatedValue; + g: AnimatedValue; + b: AnimatedValue; + a: AnimatedValue; + nativeColor: ?NativeColorValue; + _listeners: { + [key: string]: { + r: string, + g: string, + b: string, + a: string, + ... + }, + ... + } = {}; + + constructor( + valueIn?: ?(RgbaValue | RgbaAnimatedValue | ColorValue), + config?: ?AnimatedColorConfig, + ) { + super(); + let value: RgbaValue | RgbaAnimatedValue | ColorValue = + valueIn ?? defaultColor; + if (isRgbaAnimatedValue(value)) { + // $FlowIgnore[incompatible-cast] - Type is verified above + const rgbaAnimatedValue: RgbaAnimatedValue = (value: RgbaAnimatedValue); + this.r = rgbaAnimatedValue.r; + this.g = rgbaAnimatedValue.g; + this.b = rgbaAnimatedValue.b; + this.a = rgbaAnimatedValue.a; + } else { + const processedColor: RgbaValue | NativeColorValue = + // $FlowIgnore[incompatible-cast] - Type is verified above + processColor((value: ColorValue | RgbaValue)) ?? defaultColor; + let initColor: RgbaValue = defaultColor; + if (isRgbaValue(processedColor)) { + // $FlowIgnore[incompatible-cast] - Type is verified above + initColor = (processedColor: RgbaValue); + } else { + // $FlowIgnore[incompatible-cast] - Type is verified above + this.nativeColor = (processedColor: NativeColorValue); + } + + this.r = new AnimatedValue(initColor.r); + this.g = new AnimatedValue(initColor.g); + this.b = new AnimatedValue(initColor.b); + this.a = new AnimatedValue(initColor.a); + } + if (this.nativeColor || (config && config.useNativeDriver)) { + this.__makeNative(); + } + } + + /** + * Directly set the value. This will stop any animations running on the value + * and update all the bound properties. + */ + setValue(value: RgbaValue | ColorValue): void { + let shouldUpdateNodeConfig = false; + if (this.__isNative) { + const nativeTag = this.__getNativeTag(); + NativeAnimatedAPI.setWaitingForIdentifier(nativeTag.toString()); + } + + const processedColor: RgbaValue | NativeColorValue = + processColor(value) ?? defaultColor; + if (isRgbaValue(processedColor)) { + // $FlowIgnore[incompatible-type] - Type is verified above + const rgbaValue: RgbaValue = processedColor; + this.r.setValue(rgbaValue.r); + this.g.setValue(rgbaValue.g); + this.b.setValue(rgbaValue.b); + this.a.setValue(rgbaValue.a); + if (this.nativeColor != null) { + this.nativeColor = null; + shouldUpdateNodeConfig = true; + } + } else { + // $FlowIgnore[incompatible-type] - Type is verified above + const nativeColor: NativeColorValue = processedColor; + if (this.nativeColor !== nativeColor) { + this.nativeColor = nativeColor; + shouldUpdateNodeConfig = true; + } + } + + if (this.__isNative) { + const nativeTag = this.__getNativeTag(); + if (shouldUpdateNodeConfig) { + NativeAnimatedAPI.updateAnimatedNodeConfig( + nativeTag, + this.__getNativeConfig(), + ); + } + NativeAnimatedAPI.unsetWaitingForIdentifier(nativeTag.toString()); + } + } + + /** + * Sets an offset that is applied on top of whatever value is set, whether + * via `setValue`, an animation, or `Animated.event`. Useful for compensating + * things like the start of a pan gesture. + */ + setOffset(offset: RgbaValue): void { + this.r.setOffset(offset.r); + this.g.setOffset(offset.g); + this.b.setOffset(offset.b); + this.a.setOffset(offset.a); + } + + /** + * Merges the offset value into the base value and resets the offset to zero. + * The final output of the value is unchanged. + */ + flattenOffset(): void { + this.r.flattenOffset(); + this.g.flattenOffset(); + this.b.flattenOffset(); + this.a.flattenOffset(); + } + + /** + * Sets the offset value to the base value, and resets the base value to + * zero. The final output of the value is unchanged. + */ + extractOffset(): void { + this.r.extractOffset(); + this.g.extractOffset(); + this.b.extractOffset(); + this.a.extractOffset(); + } + + /** + * Adds an asynchronous listener to the value so you can observe updates from + * animations. This is useful because there is no way to synchronously read + * the value because it might be driven natively. + * + * Returns a string that serves as an identifier for the listener. + */ + addListener(callback: ColorListenerCallback): string { + const id = String(_uniqueId++); + const jointCallback = ({value: number}: any) => { + callback(this.__getValue()); + }; + this._listeners[id] = { + r: this.r.addListener(jointCallback), + g: this.g.addListener(jointCallback), + b: this.b.addListener(jointCallback), + a: this.a.addListener(jointCallback), + }; + return id; + } + + /** + * Unregister a listener. The `id` param shall match the identifier + * previously returned by `addListener()`. + */ + removeListener(id: string): void { + this.r.removeListener(this._listeners[id].r); + this.g.removeListener(this._listeners[id].g); + this.b.removeListener(this._listeners[id].b); + this.a.removeListener(this._listeners[id].a); + delete this._listeners[id]; + } + + /** + * Remove all registered listeners. + */ + removeAllListeners(): void { + this.r.removeAllListeners(); + this.g.removeAllListeners(); + this.b.removeAllListeners(); + this.a.removeAllListeners(); + this._listeners = {}; + } + + /** + * Stops any running animation or tracking. `callback` is invoked with the + * final value after stopping the animation, which is useful for updating + * state to match the animation position with layout. + */ + stopAnimation(callback?: ColorListenerCallback): void { + this.r.stopAnimation(); + this.g.stopAnimation(); + this.b.stopAnimation(); + this.a.stopAnimation(); + callback && callback(this.__getValue()); + } + + /** + * Stops any animation and resets the value to its original. + */ + resetAnimation(callback?: ColorListenerCallback): void { + this.r.resetAnimation(); + this.g.resetAnimation(); + this.b.resetAnimation(); + this.a.resetAnimation(); + callback && callback(this.__getValue()); + } + + __getValue(): ColorValue { + if (this.nativeColor != null) { + return this.nativeColor; + } else { + return `rgba(${this.r.__getValue()}, ${this.g.__getValue()}, ${this.b.__getValue()}, ${this.a.__getValue()})`; + } + } + + __attach(): void { + this.r.__addChild(this); + this.g.__addChild(this); + this.b.__addChild(this); + this.a.__addChild(this); + super.__attach(); + } + + __detach(): void { + this.r.__removeChild(this); + this.g.__removeChild(this); + this.b.__removeChild(this); + this.a.__removeChild(this); + super.__detach(); + } + + __makeNative(platformConfig: ?PlatformConfig) { + this.r.__makeNative(platformConfig); + this.g.__makeNative(platformConfig); + this.b.__makeNative(platformConfig); + this.a.__makeNative(platformConfig); + super.__makeNative(platformConfig); + } + + __getNativeConfig(): {...} { + return { + type: 'color', + r: this.r.__getNativeTag(), + g: this.g.__getNativeTag(), + b: this.b.__getNativeTag(), + a: this.a.__getNativeTag(), + nativeColor: this.nativeColor, + }; + } +} diff --git a/Libraries/Animated/nodes/AnimatedDiffClamp.js b/Libraries/Animated/nodes/AnimatedDiffClamp.js index 84eb3d715765c9..61b167c2fcba57 100644 --- a/Libraries/Animated/nodes/AnimatedDiffClamp.js +++ b/Libraries/Animated/nodes/AnimatedDiffClamp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,6 +15,7 @@ const AnimatedNode = require('./AnimatedNode'); const AnimatedWithChildren = require('./AnimatedWithChildren'); import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; class AnimatedDiffClamp extends AnimatedWithChildren { _a: AnimatedNode; @@ -32,12 +33,14 @@ class AnimatedDiffClamp extends AnimatedWithChildren { this._value = this._lastValue = this._a.__getValue(); } - __makeNative() { - this._a.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + super.__makeNative(platformConfig); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } diff --git a/Libraries/Animated/nodes/AnimatedDivision.js b/Libraries/Animated/nodes/AnimatedDivision.js index fad47ae87d1242..3d77e2de6453e7 100644 --- a/Libraries/Animated/nodes/AnimatedDivision.js +++ b/Libraries/Animated/nodes/AnimatedDivision.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,6 +16,7 @@ const AnimatedValue = require('./AnimatedValue'); const AnimatedWithChildren = require('./AnimatedWithChildren'); import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; class AnimatedDivision extends AnimatedWithChildren { _a: AnimatedNode; @@ -31,10 +32,10 @@ class AnimatedDivision extends AnimatedWithChildren { this._b = typeof b === 'number' ? new AnimatedValue(b) : b; } - __makeNative() { - this._a.__makeNative(); - this._b.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + this._b.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number { @@ -53,7 +54,9 @@ class AnimatedDivision extends AnimatedWithChildren { return a / b; } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } diff --git a/Libraries/Animated/nodes/AnimatedInterpolation.js b/Libraries/Animated/nodes/AnimatedInterpolation.js index 00a872c950aed8..ee5ea21946241c 100644 --- a/Libraries/Animated/nodes/AnimatedInterpolation.js +++ b/Libraries/Animated/nodes/AnimatedInterpolation.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,16 +19,18 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper'); const invariant = require('invariant'); const normalizeColor = require('../../StyleSheet/normalizeColor'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + type ExtrapolateType = 'extend' | 'identity' | 'clamp'; -export type InterpolationConfigType = { +export type InterpolationConfigType = $ReadOnly<{ inputRange: $ReadOnlyArray, - outputRange: $ReadOnlyArray | $ReadOnlyArray, + outputRange: $ReadOnlyArray, easing?: (input: number) => number, extrapolate?: ExtrapolateType, extrapolateLeft?: ExtrapolateType, extrapolateRight?: ExtrapolateType, -}; +}>; const linear = (t: number) => t; @@ -36,28 +38,31 @@ const linear = (t: number) => t; * Very handy helper to map input ranges to output ranges with an easing * function and custom behavior outside of the ranges. */ -function createInterpolation( - config: InterpolationConfigType, -): (input: number) => number | string { +function createInterpolation( + config: InterpolationConfigType, +): (input: number) => OutputT { if (config.outputRange && typeof config.outputRange[0] === 'string') { - return createInterpolationFromStringOutputRange(config); + return (createInterpolationFromStringOutputRange((config: any)): any); } - const outputRange: Array = (config.outputRange: any); - checkInfiniteRange('outputRange', outputRange); + const outputRange: $ReadOnlyArray = (config.outputRange: any); const inputRange = config.inputRange; - checkInfiniteRange('inputRange', inputRange); - checkValidInputRange(inputRange); - invariant( - inputRange.length === outputRange.length, - 'inputRange (' + - inputRange.length + - ') and outputRange (' + - outputRange.length + - ') must have the same length', - ); + if (__DEV__) { + checkInfiniteRange('outputRange', outputRange); + checkInfiniteRange('inputRange', inputRange); + checkValidInputRange(inputRange); + + invariant( + inputRange.length === outputRange.length, + 'inputRange (' + + inputRange.length + + ') and outputRange (' + + outputRange.length + + ') must have the same length', + ); + } const easing = config.easing || linear; @@ -82,7 +87,7 @@ function createInterpolation( ); const range = findRange(input, inputRange); - return interpolate( + return (interpolate( input, inputRange[range], inputRange[range + 1], @@ -91,7 +96,7 @@ function createInterpolation( easing, extrapolateLeft, extrapolateRight, - ); + ): any); }; } @@ -190,7 +195,7 @@ const stringShapeRegex = /[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g; * -45deg // values with units */ function createInterpolationFromStringOutputRange( - config: InterpolationConfigType, + config: InterpolationConfigType, ): (input: number) => string { let outputRange: Array = (config.outputRange: any); invariant(outputRange.length >= 2, 'Bad output range'); @@ -274,16 +279,10 @@ function findRange(input: number, inputRange: $ReadOnlyArray) { function checkValidInputRange(arr: $ReadOnlyArray) { invariant(arr.length >= 2, 'inputRange must have at least 2 elements'); + const message = + 'inputRange must be monotonically non-decreasing ' + String(arr); for (let i = 1; i < arr.length; ++i) { - invariant( - arr[i] >= arr[i - 1], - /* $FlowFixMe[incompatible-type] (>=0.13.0) - In the addition expression - * below this comment, one or both of the operands may be something that - * doesn't cleanly convert to a string, like undefined, null, and object, - * etc. If you really mean this implicit string conversion, you can do - * something like String(myThing) */ - 'inputRange must be monotonically non-decreasing ' + arr, - ); + invariant(arr[i] >= arr[i - 1], message); } } @@ -300,26 +299,28 @@ function checkInfiniteRange(name: string, arr: $ReadOnlyArray) { ); } -class AnimatedInterpolation extends AnimatedWithChildren { +class AnimatedInterpolation< + OutputT: number | string, +> extends AnimatedWithChildren { // Export for testing. static __createInterpolation: ( - config: InterpolationConfigType, - ) => (input: number) => number | string = createInterpolation; + config: InterpolationConfigType, + ) => (input: number) => OutputT = createInterpolation; _parent: AnimatedNode; - _config: InterpolationConfigType; - _interpolation: (input: number) => number | string; + _config: InterpolationConfigType; + _interpolation: (input: number) => OutputT; - constructor(parent: AnimatedNode, config: InterpolationConfigType) { + constructor(parent: AnimatedNode, config: InterpolationConfigType) { super(); this._parent = parent; this._config = config; this._interpolation = createInterpolation(config); } - __makeNative() { - this._parent.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._parent.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number | string { @@ -331,7 +332,9 @@ class AnimatedInterpolation extends AnimatedWithChildren { return this._interpolation(parentValue); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } @@ -344,7 +347,7 @@ class AnimatedInterpolation extends AnimatedWithChildren { super.__detach(); } - __transformDataType(range: Array): Array { + __transformDataType(range: $ReadOnlyArray): Array { return range.map(NativeAnimatedHelper.transformDataType); } @@ -356,9 +359,6 @@ class AnimatedInterpolation extends AnimatedWithChildren { return { inputRange: this._config.inputRange, // Only the `outputRange` can contain strings so we don't need to transform `inputRange` here - /* $FlowFixMe[incompatible-call] (>=0.38.0) - Flow error detected during - * the deployment of v0.38.0. To see the error, remove this comment and - * run flow */ outputRange: this.__transformDataType(this._config.outputRange), extrapolateLeft: this._config.extrapolateLeft || this._config.extrapolate || 'extend', diff --git a/Libraries/Animated/nodes/AnimatedModulo.js b/Libraries/Animated/nodes/AnimatedModulo.js index 48dd4a6157c6a1..bc3bc1b3ad2741 100644 --- a/Libraries/Animated/nodes/AnimatedModulo.js +++ b/Libraries/Animated/nodes/AnimatedModulo.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,6 +15,7 @@ const AnimatedNode = require('./AnimatedNode'); const AnimatedWithChildren = require('./AnimatedWithChildren'); import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; class AnimatedModulo extends AnimatedWithChildren { _a: AnimatedNode; @@ -26,9 +27,9 @@ class AnimatedModulo extends AnimatedWithChildren { this._modulus = modulus; } - __makeNative() { - this._a.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number { @@ -37,7 +38,9 @@ class AnimatedModulo extends AnimatedWithChildren { ); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } diff --git a/Libraries/Animated/nodes/AnimatedMultiplication.js b/Libraries/Animated/nodes/AnimatedMultiplication.js index 8104962ead9a65..419927b71f53dc 100644 --- a/Libraries/Animated/nodes/AnimatedMultiplication.js +++ b/Libraries/Animated/nodes/AnimatedMultiplication.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,6 +16,7 @@ const AnimatedValue = require('./AnimatedValue'); const AnimatedWithChildren = require('./AnimatedWithChildren'); import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; class AnimatedMultiplication extends AnimatedWithChildren { _a: AnimatedNode; @@ -27,20 +28,21 @@ class AnimatedMultiplication extends AnimatedWithChildren { this._b = typeof b === 'number' ? new AnimatedValue(b) : b; } - __makeNative() { - this._a.__makeNative(); - this._b.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + this._b.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number { return this._a.__getValue() * this._b.__getValue(); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } - __attach(): void { this._a.__addChild(this); this._b.__addChild(this); diff --git a/Libraries/Animated/nodes/AnimatedNode.js b/Libraries/Animated/nodes/AnimatedNode.js index ab371234c27b7e..b4a649ff302afd 100644 --- a/Libraries/Animated/nodes/AnimatedNode.js +++ b/Libraries/Animated/nodes/AnimatedNode.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,6 +15,8 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper'); const NativeAnimatedAPI = NativeAnimatedHelper.API; const invariant = require('invariant'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + type ValueListenerCallback = (state: {value: number, ...}) => mixed; let _uniqueId = 1; @@ -23,6 +25,7 @@ let _uniqueId = 1; // support them yet class AnimatedNode { _listeners: {[key: string]: ValueListenerCallback, ...}; + _platformConfig: ?PlatformConfig; __nativeAnimatedValueListener: ?any; __attach(): void {} __detach(): void { @@ -50,11 +53,12 @@ class AnimatedNode { this._listeners = {}; } - __makeNative() { + __makeNative(platformConfig: ?PlatformConfig) { if (!this.__isNative) { throw new Error('This node cannot be made a "native" animated node'); } + this._platformConfig = platformConfig; if (this.hasListeners()) { this._startListeningToNativeValueUpdates(); } @@ -126,12 +130,12 @@ class AnimatedNode { if (data.tag !== this.__getNativeTag()) { return; } - this._onAnimatedValueUpdateReceived(data.value); + this.__onAnimatedValueUpdateReceived(data.value); }, ); } - _onAnimatedValueUpdateReceived(value: number) { + __onAnimatedValueUpdateReceived(value: number) { this.__callListeners(value); } @@ -163,10 +167,11 @@ class AnimatedNode { if (this.__nativeTag == null) { this.__nativeTag = nativeTag; - NativeAnimatedHelper.API.createAnimatedNode( - nativeTag, - this.__getNativeConfig(), - ); + const config = this.__getNativeConfig(); + if (this._platformConfig) { + config.platformConfig = this._platformConfig; + } + NativeAnimatedHelper.API.createAnimatedNode(nativeTag, config); this.__shouldUpdateListenersForNewNativeTag = true; } @@ -180,6 +185,13 @@ class AnimatedNode { toJSON(): any { return this.__getValue(); } + + __getPlatformConfig(): ?PlatformConfig { + return this._platformConfig; + } + __setPlatformConfig(platformConfig: ?PlatformConfig) { + this._platformConfig = platformConfig; + } } module.exports = AnimatedNode; diff --git a/Libraries/Animated/nodes/AnimatedProps.js b/Libraries/Animated/nodes/AnimatedProps.js index 6f915bb5b8fd1d..d4ed70da8d6e9c 100644 --- a/Libraries/Animated/nodes/AnimatedProps.js +++ b/Libraries/Animated/nodes/AnimatedProps.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,12 +10,13 @@ 'use strict'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + +const ReactNative = require('../../Renderer/shims/ReactNative'); const {AnimatedEvent} = require('../AnimatedEvent'); +const NativeAnimatedHelper = require('../NativeAnimatedHelper'); const AnimatedNode = require('./AnimatedNode'); const AnimatedStyle = require('./AnimatedStyle'); -const NativeAnimatedHelper = require('../NativeAnimatedHelper'); -const ReactNative = require('../../Renderer/shims/ReactNative'); - const invariant = require('invariant'); class AnimatedProps extends AnimatedNode { @@ -35,15 +36,23 @@ class AnimatedProps extends AnimatedNode { this._callback = callback; } - __getValue(): Object { - const props = {}; + __getValue(initialProps: ?Object): Object { + const props: {[string]: any | ((...args: any) => void)} = {}; for (const key in this._props) { const value = this._props[key]; if (value instanceof AnimatedNode) { - if (!value.__isNative || value instanceof AnimatedStyle) { - // We cannot use value of natively driven nodes this way as the value we have access from - // JS may not be up to date. + // During initial render we want to use the initial value of both natively and non-natively + // driven nodes. On subsequent renders, we cannot use the value of natively driven nodes + // as they may not be up to date, so we use the initial value to ensure that values of + // native animated nodes do not impact rerenders. + if (value instanceof AnimatedStyle) { + props[key] = value.__getValue( + initialProps ? initialProps.style : null, + ); + } else if (!initialProps || !value.__isNative) { props[key] = value.__getValue(); + } else if (initialProps.hasOwnProperty(key)) { + props[key] = initialProps[key]; } } else if (value instanceof AnimatedEvent) { props[key] = value.__getHandler(); @@ -51,11 +60,12 @@ class AnimatedProps extends AnimatedNode { props[key] = value; } } + return props; } __getAnimatedValue(): Object { - const props = {}; + const props: {[string]: any} = {}; for (const key in this._props) { const value = this._props[key]; if (value instanceof AnimatedNode) { @@ -91,15 +101,21 @@ class AnimatedProps extends AnimatedNode { this._callback(); } - __makeNative(): void { + __makeNative(platformConfig: ?PlatformConfig): void { if (!this.__isNative) { this.__isNative = true; for (const key in this._props) { const value = this._props[key]; if (value instanceof AnimatedNode) { - value.__makeNative(); + value.__makeNative(platformConfig); } } + + // Since this does not call the super.__makeNative, we need to store the + // supplied platformConfig here, before calling __connectAnimatedView + // where it will be needed to traverse the graph of attached values. + super.__setPlatformConfig(platformConfig); + if (this._animatedView) { this.__connectAnimatedView(); } @@ -157,11 +173,11 @@ class AnimatedProps extends AnimatedNode { } __getNativeConfig(): Object { - const propsConfig = {}; + const propsConfig: {[string]: number} = {}; for (const propKey in this._props) { const value = this._props[propKey]; if (value instanceof AnimatedNode) { - value.__makeNative(); + value.__makeNative(this.__getPlatformConfig()); propsConfig[propKey] = value.__getNativeTag(); } } diff --git a/Libraries/Animated/nodes/AnimatedStyle.js b/Libraries/Animated/nodes/AnimatedStyle.js index 3db07f98179c1c..c64706a81585ac 100644 --- a/Libraries/Animated/nodes/AnimatedStyle.js +++ b/Libraries/Animated/nodes/AnimatedStyle.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,19 +10,20 @@ 'use strict'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + +const flattenStyle = require('../../StyleSheet/flattenStyle'); +const NativeAnimatedHelper = require('../NativeAnimatedHelper'); const AnimatedNode = require('./AnimatedNode'); const AnimatedTransform = require('./AnimatedTransform'); const AnimatedWithChildren = require('./AnimatedWithChildren'); -const NativeAnimatedHelper = require('../NativeAnimatedHelper'); - -const flattenStyle = require('../../StyleSheet/flattenStyle'); class AnimatedStyle extends AnimatedWithChildren { _style: Object; constructor(style: any) { super(); - style = flattenStyle(style) || {}; + style = flattenStyle(style) || ({}: {[string]: any}); if (style.transform) { style = { ...style, @@ -33,19 +34,23 @@ class AnimatedStyle extends AnimatedWithChildren { } // Recursively get values for nested styles (like iOS's shadowOffset) - _walkStyleAndGetValues(style: any) { - const updatedStyle = {}; + _walkStyleAndGetValues(style: any, initialStyle: ?Object) { + const updatedStyle: {[string]: any | {...}} = {}; for (const key in style) { const value = style[key]; if (value instanceof AnimatedNode) { - if (!value.__isNative) { - // We cannot use value of natively driven nodes this way as the value we have access from - // JS may not be up to date. + // During initial render we want to use the initial value of both natively and non-natively + // driven nodes. On subsequent renders, we cannot use the value of natively driven nodes + // as they may not be up to date, so we use the initial value to ensure that values of + // native animated nodes do not impact rerenders. + if (!initialStyle || !value.__isNative) { updatedStyle[key] = value.__getValue(); + } else if (initialStyle.hasOwnProperty(key)) { + updatedStyle[key] = initialStyle[key]; } } else if (value && !Array.isArray(value) && typeof value === 'object') { // Support animating nested values (for example: shadowOffset.height) - updatedStyle[key] = this._walkStyleAndGetValues(value); + updatedStyle[key] = this._walkStyleAndGetValues(value, initialStyle); } else { updatedStyle[key] = value; } @@ -53,13 +58,13 @@ class AnimatedStyle extends AnimatedWithChildren { return updatedStyle; } - __getValue(): Object { - return this._walkStyleAndGetValues(this._style); + __getValue(initialStyle: ?Object): Object { + return this._walkStyleAndGetValues(this._style, initialStyle); } // Recursively get animated values for nested styles (like iOS's shadowOffset) _walkStyleAndGetAnimatedValues(style: any) { - const updatedStyle = {}; + const updatedStyle: {[string]: any | {...}} = {}; for (const key in style) { const value = style[key]; if (value instanceof AnimatedNode) { @@ -95,22 +100,22 @@ class AnimatedStyle extends AnimatedWithChildren { super.__detach(); } - __makeNative() { + __makeNative(platformConfig: ?PlatformConfig) { for (const key in this._style) { const value = this._style[key]; if (value instanceof AnimatedNode) { - value.__makeNative(); + value.__makeNative(platformConfig); } } - super.__makeNative(); + super.__makeNative(platformConfig); } __getNativeConfig(): Object { - const styleConfig = {}; + const styleConfig: {[string]: ?number} = {}; for (const styleKey in this._style) { if (this._style[styleKey] instanceof AnimatedNode) { const style = this._style[styleKey]; - style.__makeNative(); + style.__makeNative(this.__getPlatformConfig()); styleConfig[styleKey] = style.__getNativeTag(); } // Non-animated styles are set using `setNativeProps`, no need diff --git a/Libraries/Animated/nodes/AnimatedSubtraction.js b/Libraries/Animated/nodes/AnimatedSubtraction.js index 9f0e27da3d7fd3..b3a9198c662baa 100644 --- a/Libraries/Animated/nodes/AnimatedSubtraction.js +++ b/Libraries/Animated/nodes/AnimatedSubtraction.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,6 +16,7 @@ const AnimatedValue = require('./AnimatedValue'); const AnimatedWithChildren = require('./AnimatedWithChildren'); import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; class AnimatedSubtraction extends AnimatedWithChildren { _a: AnimatedNode; @@ -27,17 +28,19 @@ class AnimatedSubtraction extends AnimatedWithChildren { this._b = typeof b === 'number' ? new AnimatedValue(b) : b; } - __makeNative() { - this._a.__makeNative(); - this._b.__makeNative(); - super.__makeNative(); + __makeNative(platformConfig: ?PlatformConfig) { + this._a.__makeNative(platformConfig); + this._b.__makeNative(platformConfig); + super.__makeNative(platformConfig); } __getValue(): number { return this._a.__getValue() - this._b.__getValue(); } - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } diff --git a/Libraries/Animated/nodes/AnimatedTracking.js b/Libraries/Animated/nodes/AnimatedTracking.js index 303f8233ea32fb..e8f74eaa54ac75 100644 --- a/Libraries/Animated/nodes/AnimatedTracking.js +++ b/Libraries/Animated/nodes/AnimatedTracking.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,7 @@ const { shouldUseNativeDriver, } = require('../NativeAnimatedHelper'); +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type {EndCallback} from '../animations/Animation'; class AnimatedTracking extends AnimatedNode { @@ -44,11 +45,11 @@ class AnimatedTracking extends AnimatedNode { this.__attach(); } - __makeNative() { + __makeNative(platformConfig: ?PlatformConfig) { this.__isNative = true; - this._parent.__makeNative(); - super.__makeNative(); - this._value.__makeNative(); + this._parent.__makeNative(platformConfig); + super.__makeNative(platformConfig); + this._value.__makeNative(platformConfig); } __getValue(): Object { @@ -63,7 +64,8 @@ class AnimatedTracking extends AnimatedNode { // if we don't do this `update` method will get called. At that point it // may be too late as it would mean the JS driver has already started // updating node values - this.__makeNative(); + let {platformConfig} = this._animationConfig; + this.__makeNative(platformConfig); } } diff --git a/Libraries/Animated/nodes/AnimatedTransform.js b/Libraries/Animated/nodes/AnimatedTransform.js index 8c2dd25852fb69..c3d4175fc6f4cd 100644 --- a/Libraries/Animated/nodes/AnimatedTransform.js +++ b/Libraries/Animated/nodes/AnimatedTransform.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,9 +10,11 @@ 'use strict'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + +const NativeAnimatedHelper = require('../NativeAnimatedHelper'); const AnimatedNode = require('./AnimatedNode'); const AnimatedWithChildren = require('./AnimatedWithChildren'); -const NativeAnimatedHelper = require('../NativeAnimatedHelper'); class AnimatedTransform extends AnimatedWithChildren { _transforms: $ReadOnlyArray; @@ -22,21 +24,21 @@ class AnimatedTransform extends AnimatedWithChildren { this._transforms = transforms; } - __makeNative() { + __makeNative(platformConfig: ?PlatformConfig) { this._transforms.forEach(transform => { for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { - value.__makeNative(); + value.__makeNative(platformConfig); } } }); - super.__makeNative(); + super.__makeNative(platformConfig); } __getValue(): $ReadOnlyArray { return this._transforms.map(transform => { - const result = {}; + const result: {[string]: any} = {}; for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { @@ -51,7 +53,7 @@ class AnimatedTransform extends AnimatedWithChildren { __getAnimatedValue(): $ReadOnlyArray { return this._transforms.map(transform => { - const result = {}; + const result: {[string]: any} = {}; for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { diff --git a/Libraries/Animated/nodes/AnimatedValue.js b/Libraries/Animated/nodes/AnimatedValue.js index 1d84f5e01b091c..9530e090f923d7 100644 --- a/Libraries/Animated/nodes/AnimatedValue.js +++ b/Libraries/Animated/nodes/AnimatedValue.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,6 +20,10 @@ import type Animation, {EndCallback} from '../animations/Animation'; import type {InterpolationConfigType} from './AnimatedInterpolation'; import type AnimatedTracking from './AnimatedTracking'; +export type AnimatedValueConfig = $ReadOnly<{ + useNativeDriver: boolean, +}>; + const NativeAnimatedAPI = NativeAnimatedHelper.API; /** @@ -87,7 +91,7 @@ class AnimatedValue extends AnimatedWithChildren { _animation: ?Animation; _tracking: ?AnimatedTracking; - constructor(value: number) { + constructor(value: number, config?: ?AnimatedValueConfig) { super(); if (typeof value !== 'number') { throw new Error('AnimatedValue: Attempting to set value to undefined'); @@ -95,12 +99,15 @@ class AnimatedValue extends AnimatedWithChildren { this._startingValue = this._value = value; this._offset = 0; this._animation = null; + if (config && config.useNativeDriver) { + this.__makeNative(); + } } __detach() { if (this.__isNative) { NativeAnimatedAPI.getValue(this.__getNativeTag(), value => { - this._value = value; + this._value = value - this._offset; }); } this.stopAnimation(); @@ -127,9 +134,9 @@ class AnimatedValue extends AnimatedWithChildren { !this.__isNative /* don't perform a flush for natively driven values */, ); if (this.__isNative) { - _executeAsAnimatedBatch(this.__getNativeTag().toString(), () => { - NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value); - }); + _executeAsAnimatedBatch(this.__getNativeTag().toString(), () => + NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value), + ); } } @@ -186,7 +193,13 @@ class AnimatedValue extends AnimatedWithChildren { this.stopTracking(); this._animation && this._animation.stop(); this._animation = null; - callback && callback(this.__getValue()); + if (callback) { + if (this.__isNative) { + NativeAnimatedAPI.getValue(this.__getNativeTag(), callback); + } else { + callback(this.__getValue()); + } + } } /** @@ -205,7 +218,7 @@ class AnimatedValue extends AnimatedWithChildren { } } - _onAnimatedValueUpdateReceived(value: number): void { + __onAnimatedValueUpdateReceived(value: number): void { this._updateValue(value, false /*flush*/); } @@ -213,7 +226,9 @@ class AnimatedValue extends AnimatedWithChildren { * Interpolates the value before updating the property, e.g. mapping 0-1 to * 0-10. */ - interpolate(config: InterpolationConfigType): AnimatedInterpolation { + interpolate( + config: InterpolationConfigType, + ): AnimatedInterpolation { return new AnimatedInterpolation(this, config); } @@ -264,6 +279,8 @@ class AnimatedValue extends AnimatedWithChildren { track(tracking: AnimatedTracking): void { this.stopTracking(); this._tracking = tracking; + // Make sure that the tracking animation starts executing + this._tracking && this._tracking.update(); } _updateValue(value: number, flush: boolean): void { diff --git a/Libraries/Animated/nodes/AnimatedValueXY.js b/Libraries/Animated/nodes/AnimatedValueXY.js index 8a4f219c594393..c54a9d9d6f55e5 100644 --- a/Libraries/Animated/nodes/AnimatedValueXY.js +++ b/Libraries/Animated/nodes/AnimatedValueXY.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,11 +10,16 @@ 'use strict'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; + const AnimatedValue = require('./AnimatedValue'); const AnimatedWithChildren = require('./AnimatedWithChildren'); const invariant = require('invariant'); +export type AnimatedValueXYConfig = $ReadOnly<{ + useNativeDriver: boolean, +}>; type ValueXYListenerCallback = (value: { x: number, y: number, @@ -47,6 +52,7 @@ class AnimatedValueXY extends AnimatedWithChildren { +y: number | AnimatedValue, ... }, + config?: ?AnimatedValueXYConfig, ) { super(); const value: any = valueIn || {x: 0, y: 0}; // @flowfixme: shouldn't need `: any` @@ -63,6 +69,9 @@ class AnimatedValueXY extends AnimatedWithChildren { this.y = value.y; } this._listeners = {}; + if (config && config.useNativeDriver) { + this.__makeNative(); + } } /** @@ -168,7 +177,7 @@ class AnimatedValueXY extends AnimatedWithChildren { */ addListener(callback: ValueXYListenerCallback): string { const id = String(_uniqueId++); - const jointCallback = ({value: number}) => { + const jointCallback = ({value: number}: any) => { callback(this.__getValue()); }; this._listeners[id] = { @@ -221,6 +230,24 @@ class AnimatedValueXY extends AnimatedWithChildren { getTranslateTransform(): Array<{[key: string]: AnimatedValue, ...}> { return [{translateX: this.x}, {translateY: this.y}]; } + + __attach(): void { + this.x.__addChild(this); + this.y.__addChild(this); + super.__attach(); + } + + __detach(): void { + this.x.__removeChild(this); + this.y.__removeChild(this); + super.__detach(); + } + + __makeNative(platformConfig: ?PlatformConfig) { + this.x.__makeNative(platformConfig); + this.y.__makeNative(platformConfig); + super.__makeNative(platformConfig); + } } module.exports = AnimatedValueXY; diff --git a/Libraries/Animated/nodes/AnimatedWithChildren.js b/Libraries/Animated/nodes/AnimatedWithChildren.js index 5f4ff1c6de1f91..435365d1f6ee6d 100644 --- a/Libraries/Animated/nodes/AnimatedWithChildren.js +++ b/Libraries/Animated/nodes/AnimatedWithChildren.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,6 +10,7 @@ 'use strict'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; const AnimatedNode = require('./AnimatedNode'); const NativeAnimatedHelper = require('../NativeAnimatedHelper'); @@ -21,18 +22,18 @@ class AnimatedWithChildren extends AnimatedNode { this._children = []; } - __makeNative() { + __makeNative(platformConfig: ?PlatformConfig) { if (!this.__isNative) { this.__isNative = true; for (const child of this._children) { - child.__makeNative(); + child.__makeNative(platformConfig); NativeAnimatedHelper.API.connectAnimatedNodes( this.__getNativeTag(), child.__getNativeTag(), ); } } - super.__makeNative(); + super.__makeNative(platformConfig); } __addChild(child: AnimatedNode): void { @@ -42,7 +43,7 @@ class AnimatedWithChildren extends AnimatedNode { this._children.push(child); if (this.__isNative) { // Only accept "native" animated nodes as children - child.__makeNative(); + child.__makeNative(this.__getPlatformConfig()); NativeAnimatedHelper.API.connectAnimatedNodes( this.__getNativeTag(), child.__getNativeTag(), diff --git a/Libraries/Animated/useAnimatedProps.js b/Libraries/Animated/useAnimatedProps.js index 142faedb1b2396..9ab24a99ce1774 100644 --- a/Libraries/Animated/useAnimatedProps.js +++ b/Libraries/Animated/useAnimatedProps.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -82,6 +82,7 @@ export default function useAnimatedProps( scheduleUpdate(); } else if (!node.__isNative) { // $FlowIgnore[not-a-function] - Assume it's still a function. + // $FlowFixMe[incompatible-use] instance.setNativeProps(node.__getAnimatedValue()); } else { throw new Error( diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index 191ab4b28f2182..99e731bd43fb55 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,7 +33,7 @@ type NativeAppStateEventDefinitions = { * `AppState` can tell you if the app is in the foreground or background, * and notify you when the state changes. * - * See https://reactnative.dev/docs/appstate.html + * See https://reactnative.dev/docs/appstate */ class AppState { currentState: ?string = null; @@ -91,7 +91,7 @@ class AppState { * Add a handler to AppState changes by listening to the `change` event type * and providing the handler. * - * See https://reactnative.dev/docs/appstate.html#addeventlistener + * See https://reactnative.dev/docs/appstate#addeventlistener */ addEventListener>( type: K, @@ -127,38 +127,6 @@ class AppState { } throw new Error('Trying to subscribe to unknown event: ' + type); } - - /** - * @deprecated Use `remove` on the EventSubscription from `addEventListener`. - */ - removeEventListener>( - type: K, - listener: (...$ElementType) => mixed, - ): void { - const emitter = this._emitter; - if (emitter == null) { - throw new Error('Cannot use AppState when `isAvailable` is false.'); - } - // NOTE: This will report a deprecation notice via `console.error`. - switch (type) { - case 'change': - // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type - // $FlowIssue[incompatible-call] - emitter.removeListener('appStateDidChange', listener); - return; - case 'memoryWarning': - // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type - emitter.removeListener('memoryWarning', listener); - return; - case 'blur': - case 'focus': - // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type - // $FlowIssue[incompatible-call] - emitter.addListener('appStateFocusChange', listener); - return; - } - throw new Error('Trying to unsubscribe from unknown event: ' + type); - } } module.exports = (new AppState(): AppState); diff --git a/Libraries/AppState/NativeAppState.js b/Libraries/AppState/NativeAppState.js index b08fe5ca81a5c4..d546e70051d0d1 100644 --- a/Libraries/AppState/NativeAppState.js +++ b/Libraries/AppState/NativeAppState.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BatchedBridge/BatchedBridge.js b/Libraries/BatchedBridge/BatchedBridge.js index 5b928edcc6b3f2..0c25ba26811a46 100644 --- a/Libraries/BatchedBridge/BatchedBridge.js +++ b/Libraries/BatchedBridge/BatchedBridge.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 0b593ef203ea3e..bfe3e0c082152b 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,13 +10,12 @@ 'use strict'; -const ErrorUtils = require('../vendor/core/ErrorUtils'); const Systrace = require('../Performance/Systrace'); - const deepFreezeAndThrowOnMutationInDev = require('../Utilities/deepFreezeAndThrowOnMutationInDev'); -const invariant = require('invariant'); const stringifySafe = require('../Utilities/stringifySafe').default; const warnOnce = require('../Utilities/warnOnce'); +const ErrorUtils = require('../vendor/core/ErrorUtils'); +const invariant = require('invariant'); export type SpyData = { type: number, @@ -199,7 +198,7 @@ class MessageQueue { delete this._debugInfo[this._callID - DEBUG_INFO_LIMIT]; } if (this._successCallbacks.size > 500) { - const info = {}; + const info: {[number]: {method: string, module: string}} = {}; this._successCallbacks.forEach((_, callID) => { const debug = this._debugInfo[callID]; const module = debug && this._remoteModuleTable[debug[0]]; @@ -253,7 +252,7 @@ class MessageQueue { // folly-convertible. As a special case, if a prop value is a // function it is permitted here, and special-cased in the // conversion. - const isValidArgument = val => { + const isValidArgument = (val: mixed) => { switch (typeof val) { case 'undefined': case 'boolean': @@ -287,7 +286,7 @@ class MessageQueue { // Replacement allows normally non-JSON-convertible values to be // seen. There is ambiguity with string values, but in context, // it should at least be a strong hint. - const replacer = (key, val) => { + const replacer = (key: string, val: $FlowFixMe) => { const t = typeof val; if (t === 'function') { return '<>'; @@ -405,15 +404,25 @@ class MessageQueue { this.__spy({type: TO_JS, module, method, args}); } const moduleMethods = this.getCallableModule(module); - invariant( - !!moduleMethods, - `Module ${module} is not a registered callable module (calling ${method}). A frequent cause of the error is that the application entry file path is incorrect. - This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, - ); - invariant( - !!moduleMethods[method], - `Method ${method} does not exist on module ${module}`, - ); + if (!moduleMethods) { + const callableModuleNames = Object.keys(this._lazyCallableModules); + const n = callableModuleNames.length; + const callableModuleNameList = callableModuleNames.join(', '); + + // TODO(T122225939): Remove after investigation: Why are we getting to this line in bridgeless mode? + const isBridgelessMode = global.RN$Bridgeless === true ? 'true' : 'false'; + invariant( + false, + `Failed to call into JavaScript module method ${module}.${method}(). Module has not been registered as callable. Bridgeless Mode: ${isBridgelessMode}. Registered callable JavaScript modules (n = ${n}): ${callableModuleNameList}. + A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, + ); + } + if (!moduleMethods[method]) { + invariant( + false, + `Failed to call into JavaScript module method ${module}.${method}(). Module exists, but the method is undefined.`, + ); + } moduleMethods[method].apply(moduleMethods, args); Systrace.endEvent(); } diff --git a/Libraries/BatchedBridge/NativeModules.js b/Libraries/BatchedBridge/NativeModules.js index 257436199d3484..30259e79b9fdec 100644 --- a/Libraries/BatchedBridge/NativeModules.js +++ b/Libraries/BatchedBridge/NativeModules.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,12 +10,11 @@ 'use strict'; -const BatchedBridge = require('./BatchedBridge'); +import type {ExtendedError} from '../Core/ExtendedError'; +const BatchedBridge = require('./BatchedBridge'); const invariant = require('invariant'); -import type {ExtendedError} from '../Core/ExtendedError'; - export type ModuleConfig = [ string /* name */, ?{...} /* constants */, @@ -51,7 +50,7 @@ function genModule( return {name: moduleName}; } - const module = {}; + const module: {[string]: mixed} = {}; methods && methods.forEach((methodName, methodID) => { const isPromise = diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js index 8644d15ea0196e..0d70e66c2d76dc 100644 --- a/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +++ b/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js index d0e5477822ef83..77b9421c59820b 100644 --- a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +++ b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index 031192793de4e6..e80e024b6fedb9 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -108,8 +108,8 @@ describe('MessageQueue', function () { const unknownModule = 'UnknownModule', unknownMethod = 'UnknownMethod'; expect(() => queue.__callFunction(unknownModule, unknownMethod)).toThrow( - `Module ${unknownModule} is not a registered callable module (calling ${unknownMethod}). A frequent cause of the error is that the application entry file path is incorrect. - This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, + `Failed to call into JavaScript module method ${unknownModule}.${unknownMethod}(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 1): MessageQueueTestModule. + A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, ); }); diff --git a/Libraries/BatchedBridge/__tests__/NativeModules-test.js b/Libraries/BatchedBridge/__tests__/NativeModules-test.js index 2965e6784f592b..f4d4aa7a93a6c8 100644 --- a/Libraries/BatchedBridge/__tests__/NativeModules-test.js +++ b/Libraries/BatchedBridge/__tests__/NativeModules-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/Blob.js b/Libraries/Blob/Blob.js index 99d5e59b8e58ab..b279a030cff354 100644 --- a/Libraries/Blob/Blob.js +++ b/Libraries/Blob/Blob.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/BlobManager.js b/Libraries/Blob/BlobManager.js index 4f4310adddb582..0d4cee7282baaf 100644 --- a/Libraries/Blob/BlobManager.js +++ b/Libraries/Blob/BlobManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/BlobRegistry.js b/Libraries/Blob/BlobRegistry.js index ce1eaed340442f..01bb0d11eff48c 100644 --- a/Libraries/Blob/BlobRegistry.js +++ b/Libraries/Blob/BlobRegistry.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/BlobTypes.js b/Libraries/Blob/BlobTypes.js index cae2ee1f42c68a..2c3e00eb06e4dd 100644 --- a/Libraries/Blob/BlobTypes.js +++ b/Libraries/Blob/BlobTypes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/File.js b/Libraries/Blob/File.js index e3a22412c5ecfc..5aa2dd73c46f3d 100644 --- a/Libraries/Blob/File.js +++ b/Libraries/Blob/File.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/FileReader.js b/Libraries/Blob/FileReader.js index a71d10fc562d3d..c0b7feaec713c4 100644 --- a/Libraries/Blob/FileReader.js +++ b/Libraries/Blob/FileReader.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -46,7 +46,6 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) { _error: ?Error; _result: ?ReaderResult; _aborted: boolean = false; - _subscriptions: Array = []; constructor() { super(); @@ -59,11 +58,6 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) { this._result = null; } - _clearSubscriptions(): void { - this._subscriptions.forEach(sub => sub.remove()); - this._subscriptions = []; - } - _setReadyState(newState: ReadyState) { this._readyState = newState; this.dispatchEvent({type: 'readystatechange'}); diff --git a/Libraries/Blob/NativeBlobModule.js b/Libraries/Blob/NativeBlobModule.js index d43c8bc3e3b21f..2b474d693527b6 100644 --- a/Libraries/Blob/NativeBlobModule.js +++ b/Libraries/Blob/NativeBlobModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/NativeFileReaderModule.js b/Libraries/Blob/NativeFileReaderModule.js index a33d5d9b7754dd..ac964b3af42ea7 100644 --- a/Libraries/Blob/NativeFileReaderModule.js +++ b/Libraries/Blob/NativeFileReaderModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobCollector.h b/Libraries/Blob/RCTBlobCollector.h index 43179d922796e6..fdd68112d6820a 100644 --- a/Libraries/Blob/RCTBlobCollector.h +++ b/Libraries/Blob/RCTBlobCollector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobCollector.mm b/Libraries/Blob/RCTBlobCollector.mm index 505e98198d849f..b7387c445a5038 100644 --- a/Libraries/Blob/RCTBlobCollector.mm +++ b/Libraries/Blob/RCTBlobCollector.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobManager.h b/Libraries/Blob/RCTBlobManager.h index 04b905ccb92a24..34cd8b82cf908d 100755 --- a/Libraries/Blob/RCTBlobManager.h +++ b/Libraries/Blob/RCTBlobManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobManager.mm b/Libraries/Blob/RCTBlobManager.mm index f156461a78aa3d..567e16ffee56c1 100755 --- a/Libraries/Blob/RCTBlobManager.mm +++ b/Libraries/Blob/RCTBlobManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobPlugins.h b/Libraries/Blob/RCTBlobPlugins.h index 141ca35579cb97..d1fc8cfdae1008 100644 --- a/Libraries/Blob/RCTBlobPlugins.h +++ b/Libraries/Blob/RCTBlobPlugins.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTBlobPlugins.mm b/Libraries/Blob/RCTBlobPlugins.mm index 289094f35d43a0..db0dcd82559652 100644 --- a/Libraries/Blob/RCTBlobPlugins.mm +++ b/Libraries/Blob/RCTBlobPlugins.mm @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTFileReaderModule.h b/Libraries/Blob/RCTFileReaderModule.h index 0eb246b5c4759c..80d38089073fd6 100644 --- a/Libraries/Blob/RCTFileReaderModule.h +++ b/Libraries/Blob/RCTFileReaderModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/RCTFileReaderModule.mm b/Libraries/Blob/RCTFileReaderModule.mm index 2525de0c201b2b..f52a68aba98c19 100644 --- a/Libraries/Blob/RCTFileReaderModule.mm +++ b/Libraries/Blob/RCTFileReaderModule.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -31,24 +31,26 @@ @implementation RCTFileReaderModule reject:(RCTPromiseRejectBlock)reject) { RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobModule"]; - NSData *data = [blobManager resolve:blob]; + dispatch_async(blobManager.methodQueue, ^{ + NSData *data = [blobManager resolve:blob]; - if (data == nil) { - reject(RCTErrorUnspecified, - [NSString stringWithFormat:@"Unable to resolve data for blob: %@", [RCTConvert NSString:blob[@"blobId"]]], nil); - } else { - NSStringEncoding stringEncoding; - - if (encoding == nil) { - stringEncoding = NSUTF8StringEncoding; + if (data == nil) { + reject(RCTErrorUnspecified, + [NSString stringWithFormat:@"Unable to resolve data for blob: %@", [RCTConvert NSString:blob[@"blobId"]]], nil); } else { - stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef) encoding)); - } + NSStringEncoding stringEncoding; - NSString *text = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (encoding == nil) { + stringEncoding = NSUTF8StringEncoding; + } else { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef) encoding)); + } - resolve(text); - } + NSString *text = [[NSString alloc] initWithData:data encoding:stringEncoding]; + + resolve(text); + } + }); } RCT_EXPORT_METHOD(readAsDataURL:(NSDictionary *)blob @@ -56,19 +58,21 @@ @implementation RCTFileReaderModule reject:(RCTPromiseRejectBlock)reject) { RCTBlobManager *blobManager = [_moduleRegistry moduleForName:"BlobModule"]; - NSData *data = [blobManager resolve:blob]; - - if (data == nil) { - reject(RCTErrorUnspecified, - [NSString stringWithFormat:@"Unable to resolve data for blob: %@", [RCTConvert NSString:blob[@"blobId"]]], nil); - } else { - NSString *type = [RCTConvert NSString:blob[@"type"]]; - NSString *text = [NSString stringWithFormat:@"data:%@;base64,%@", - type != nil && [type length] > 0 ? type : @"application/octet-stream", - [data base64EncodedStringWithOptions:0]]; - - resolve(text); - } + dispatch_async(blobManager.methodQueue, ^{ + NSData *data = [blobManager resolve:blob]; + + if (data == nil) { + reject(RCTErrorUnspecified, + [NSString stringWithFormat:@"Unable to resolve data for blob: %@", [RCTConvert NSString:blob[@"blobId"]]], nil); + } else { + NSString *type = [RCTConvert NSString:blob[@"type"]]; + NSString *text = [NSString stringWithFormat:@"data:%@;base64,%@", + type != nil && [type length] > 0 ? type : @"application/octet-stream", + [data base64EncodedStringWithOptions:0]]; + + resolve(text); + } + }); } - (std::shared_ptr)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params diff --git a/Libraries/Blob/React-RCTBlob.podspec b/Libraries/Blob/React-RCTBlob.podspec index 84752a84c0af9d..ee488e04aa142a 100644 --- a/Libraries/Blob/React-RCTBlob.podspec +++ b/Libraries/Blob/React-RCTBlob.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' Pod::Spec.new do |s| s.name = "React-RCTBlob" @@ -26,7 +26,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source s.source_files = "*.{h,m,mm}" @@ -34,8 +34,8 @@ Pod::Spec.new do |s| s.header_dir = "RCTBlob" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"" + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\"" } s.dependency "RCT-Folly", folly_version diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 5cddcb0a21aed2..77b4d7f94d6d7f 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -101,7 +101,13 @@ export class URLSearchParams { } const last = this._searchParams.length - 1; return this._searchParams.reduce((acc, curr, index) => { - return acc + curr.join('=') + (index === last ? '' : '&'); + return ( + acc + + encodeURIComponent(curr[0]) + + '=' + + encodeURIComponent(curr[1]) + + (index === last ? '' : '&') + ); }, ''); } } diff --git a/Libraries/Blob/__mocks__/BlobModule.js b/Libraries/Blob/__mocks__/BlobModule.js index 8a4ba3ef783a34..99e5c405411bc2 100644 --- a/Libraries/Blob/__mocks__/BlobModule.js +++ b/Libraries/Blob/__mocks__/BlobModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__mocks__/FileReaderModule.js b/Libraries/Blob/__mocks__/FileReaderModule.js index 1f5bfeac80e622..1cc016c82abbff 100644 --- a/Libraries/Blob/__mocks__/FileReaderModule.js +++ b/Libraries/Blob/__mocks__/FileReaderModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__tests__/Blob-test.js b/Libraries/Blob/__tests__/Blob-test.js index 0ec3d8904d8a4a..5e406f024dd084 100644 --- a/Libraries/Blob/__tests__/Blob-test.js +++ b/Libraries/Blob/__tests__/Blob-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__tests__/BlobManager-test.js b/Libraries/Blob/__tests__/BlobManager-test.js index bc788cdbf61574..e03dd87d9d1c85 100644 --- a/Libraries/Blob/__tests__/BlobManager-test.js +++ b/Libraries/Blob/__tests__/BlobManager-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__tests__/File-test.js b/Libraries/Blob/__tests__/File-test.js index ee097235e220bf..21b50650a99879 100644 --- a/Libraries/Blob/__tests__/File-test.js +++ b/Libraries/Blob/__tests__/File-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__tests__/FileReader-test.js b/Libraries/Blob/__tests__/FileReader-test.js index 3ccf4924242f4e..8ae1c81a31f8a8 100644 --- a/Libraries/Blob/__tests__/FileReader-test.js +++ b/Libraries/Blob/__tests__/FileReader-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Blob/__tests__/URL-test.js b/Libraries/Blob/__tests__/URL-test.js index fa7e234385e4d1..28e89950b267db 100644 --- a/Libraries/Blob/__tests__/URL-test.js +++ b/Libraries/Blob/__tests__/URL-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BugReporting/BugReporting.js b/Libraries/BugReporting/BugReporting.js index d0f8dc2b18c73e..2ee616af829c50 100644 --- a/Libraries/BugReporting/BugReporting.js +++ b/Libraries/BugReporting/BugReporting.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BugReporting/NativeBugReporting.js b/Libraries/BugReporting/NativeBugReporting.js index 02ff311cc50f3c..13a51a585c0b25 100644 --- a/Libraries/BugReporting/NativeBugReporting.js +++ b/Libraries/BugReporting/NativeBugReporting.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BugReporting/dumpReactTree.js b/Libraries/BugReporting/dumpReactTree.js index 0960662911cc3a..6673657d42a894 100644 --- a/Libraries/BugReporting/dumpReactTree.js +++ b/Libraries/BugReporting/dumpReactTree.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/BugReporting/getReactData.js b/Libraries/BugReporting/getReactData.js index 7555422be91613..4440cc4e0d0e60 100644 --- a/Libraries/BugReporting/getReactData.js +++ b/Libraries/BugReporting/getReactData.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js index a388a6d618f4f0..1217cad123c2fe 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,7 +12,6 @@ import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter'; import {sendAccessibilityEvent} from '../../Renderer/shims/ReactNative'; import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import Platform from '../../Utilities/Platform'; -import type EventEmitter from '../../vendor/emitter/EventEmitter'; import type {EventSubscription} from '../../vendor/emitter/EventEmitter'; import NativeAccessibilityInfoAndroid from './NativeAccessibilityInfo'; import NativeAccessibilityManagerIOS from './NativeAccessibilityManager'; @@ -72,7 +71,7 @@ const EventNames: Map< * well as to register to be notified when the state of the screen reader * changes. * - * See https://reactnative.dev/docs/accessibilityinfo.html + * See https://reactnative.dev/docs/accessibilityinfo */ const AccessibilityInfo = { /** @@ -81,7 +80,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when bold text is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isBoldTextEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isBoldTextEnabled */ isBoldTextEnabled(): Promise { if (Platform.OS === 'android') { @@ -106,7 +105,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when grayscale is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isGrayscaleEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isGrayscaleEnabled */ isGrayscaleEnabled(): Promise { if (Platform.OS === 'android') { @@ -131,7 +130,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when invert color is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isInvertColorsEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isInvertColorsEnabled */ isInvertColorsEnabled(): Promise { if (Platform.OS === 'android') { @@ -156,7 +155,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when a reduce motion is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isReduceMotionEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isReduceMotionEnabled */ isReduceMotionEnabled(): Promise { return new Promise((resolve, reject) => { @@ -185,7 +184,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when a reduce transparency is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isReduceTransparencyEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isReduceTransparencyEnabled */ isReduceTransparencyEnabled(): Promise { if (Platform.OS === 'android') { @@ -210,7 +209,7 @@ const AccessibilityInfo = { * Returns a promise which resolves to a boolean. * The result is `true` when a screen reader is enabled and `false` otherwise. * - * See https://reactnative.dev/docs/accessibilityinfo.html#isScreenReaderEnabled + * See https://reactnative.dev/docs/accessibilityinfo#isScreenReaderEnabled */ isScreenReaderEnabled(): Promise { return new Promise((resolve, reject) => { @@ -292,7 +291,7 @@ const AccessibilityInfo = { * - `success`: A boolean indicating whether the announcement was * successfully made. * - * See https://reactnative.dev/docs/accessibilityinfo.html#addeventlistener + * See https://reactnative.dev/docs/accessibilityinfo#addeventlistener */ addEventListener>( eventName: K, @@ -307,7 +306,7 @@ const AccessibilityInfo = { /** * Set accessibility focus to a React component. * - * See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus + * See https://reactnative.dev/docs/accessibilityinfo#setaccessibilityfocus */ setAccessibilityFocus(reactTag: number): void { legacySendAccessibilityEvent(reactTag, 'focus'); @@ -316,7 +315,7 @@ const AccessibilityInfo = { /** * Send a named accessibility event to a HostComponent. */ - sendAccessibilityEvent_unstable( + sendAccessibilityEvent( handle: ElementRef>, eventType: AccessibilityEventTypes, ) { @@ -331,7 +330,7 @@ const AccessibilityInfo = { /** * Post a string to be announced by the screen reader. * - * See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility + * See https://reactnative.dev/docs/accessibilityinfo#announceforaccessibility */ announceForAccessibility(announcement: string): void { if (Platform.OS === 'android') { @@ -342,28 +341,33 @@ const AccessibilityInfo = { }, /** - * @deprecated Use `remove` on the EventSubscription from `addEventListener`. + * Post a string to be announced by the screen reader. + * - `announcement`: The string announced by the screen reader. + * - `options`: An object that configures the reading options. + * - `queue`: The announcement will be queued behind existing announcements. iOS only. */ - removeEventListener>( - eventName: K, - handler: (...$ElementType) => void, + announceForAccessibilityWithOptions( + announcement: string, + options: {queue?: boolean}, ): void { - // NOTE: This will report a deprecation notice via `console.error`. - const deviceEventName = EventNames.get(eventName); - if (deviceEventName != null) { - // $FlowIgnore[incompatible-cast] - (RCTDeviceEventEmitter: EventEmitter<$FlowFixMe>).removeListener( - 'deviceEventName', - // $FlowFixMe[invalid-tuple-arity] - handler, - ); + if (Platform.OS === 'android') { + NativeAccessibilityInfoAndroid?.announceForAccessibility(announcement); + } else { + if (NativeAccessibilityManagerIOS?.announceForAccessibilityWithOptions) { + NativeAccessibilityManagerIOS?.announceForAccessibilityWithOptions( + announcement, + options, + ); + } else { + NativeAccessibilityManagerIOS?.announceForAccessibility(announcement); + } } }, /** * Get the recommended timeout for changes to the UI needed by this user. * - * See https://reactnative.dev/docs/accessibilityinfo.html#getrecommendedtimeoutmillis + * See https://reactnative.dev/docs/accessibilityinfo#getrecommendedtimeoutmillis */ getRecommendedTimeoutMillis(originalTimeout: number): Promise { if (Platform.OS === 'android') { diff --git a/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js b/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js index c9eecfde41ce53..beee9e28517569 100644 --- a/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +++ b/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js b/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js index 9ee2403e372b91..d4c400ac3e99c3 100644 --- a/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +++ b/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -52,6 +52,10 @@ export interface Spec extends TurboModule { |}) => void; +setAccessibilityFocus: (reactTag: number) => void; +announceForAccessibility: (announcement: string) => void; + +announceForAccessibilityWithOptions?: ( + announcement: string, + options: {queue?: boolean}, + ) => void; } export default (TurboModuleRegistry.get('AccessibilityManager'): ?Spec); diff --git a/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js b/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js index 3bb1c554950d50..09556be26a4644 100644 --- a/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js +++ b/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js b/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js index 950336d1101c44..17091e354ff569 100644 --- a/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js +++ b/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 9100cf6483de2a..eb8b733e15a2cd 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js b/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js index 3475cebeddeabd..548069e885d653 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,21 +22,21 @@ type NativeProps = $ReadOnly<{| /** * Whether the indicator should hide when not animating (true by default). * - * See https://reactnative.dev/docs/activityindicator.html#hideswhenstopped + * See https://reactnative.dev/docs/activityindicator#hideswhenstopped */ hidesWhenStopped?: WithDefault, /** * Whether to show the indicator (true, the default) or hide it (false). * - * See https://reactnative.dev/docs/activityindicator.html#animating + * See https://reactnative.dev/docs/activityindicator#animating */ animating?: WithDefault, /** * The foreground color of the spinner (default is gray). * - * See https://reactnative.dev/docs/activityindicator.html#color + * See https://reactnative.dev/docs/activityindicator#color */ color?: ?ColorValue, @@ -44,7 +44,7 @@ type NativeProps = $ReadOnly<{| * Size of the indicator (default is 'small'). * Passing a number to the size prop is only supported on Android. * - * See https://reactnative.dev/docs/activityindicator.html#size + * See https://reactnative.dev/docs/activityindicator#size */ size?: WithDefault<'small' | 'large', 'small'>, |}>; diff --git a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js index 2b0f76c663664c..91cb7bd6e29291 100644 --- a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js +++ b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index 5e11ecc9632ee5..89ec384fe2c1b7 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -146,6 +146,7 @@ type ButtonProps = $ReadOnly<{| onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, accessibilityState?: ?AccessibilityState, accessibilityHint?: ?string, + accessibilityLanguage?: ?Stringish, |}>; /** @@ -277,6 +278,7 @@ class Button extends React.Component { accessible, accessibilityActions, accessibilityHint, + accessibilityLanguage, onAccessibilityAction, } = this.props; const buttonStyles = [styles.button]; @@ -320,6 +322,7 @@ class Button extends React.Component { onAccessibilityAction={onAccessibilityAction} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} + accessibilityLanguage={accessibilityLanguage} accessibilityRole="button" accessibilityState={accessibilityState} hasTVPreferredFocus={hasTVPreferredFocus} diff --git a/Libraries/Components/Clipboard/Clipboard.js b/Libraries/Components/Clipboard/Clipboard.js index 970aa93d494bde..d387a229139ec7 100644 --- a/Libraries/Components/Clipboard/Clipboard.js +++ b/Libraries/Components/Clipboard/Clipboard.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Clipboard/NativeClipboard.js b/Libraries/Components/Clipboard/NativeClipboard.js index 6e33b2edce76f5..9e4ee4733f47d0 100644 --- a/Libraries/Components/Clipboard/NativeClipboard.js +++ b/Libraries/Components/Clipboard/NativeClipboard.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DatePicker/DatePickerIOS.android.js b/Libraries/Components/DatePicker/DatePickerIOS.android.js index a3531c770b42b1..e97edf657c2058 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.android.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 337ed8a77c7da4..91d5d0d6f53ac1 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js index e577f3ee37b4d9..c7ae082d19b783 100644 --- a/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +++ b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js b/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js index 79579b82ee5933..4fdcf8f8ca2727 100644 --- a/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js +++ b/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js b/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js index c8c157a2f8ecfa..91241706eb3ac1 100644 --- a/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +++ b/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,6 +11,11 @@ import type {TurboModule} from '../../TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry'; +/** + * This file backs native modules that are used internally at Meta + * and this JS spec was intentionally left here. In the meanwhile this + * file should not be deleted. + */ export interface Spec extends TurboModule { +open: (options: Object) => Promise; } diff --git a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js index 7efb3491e0e337..c0c1bf05375a80 100644 --- a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +++ b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -92,12 +92,12 @@ type NativeProps = $ReadOnly<{| /** * Function called whenever the navigation view has been opened. */ - onDrawerOpen?: ?DirectEventHandler, + onDrawerOpen?: ?DirectEventHandler, /** * Function called whenever the navigation view has been closed. */ - onDrawerClose?: ?DirectEventHandler, + onDrawerClose?: ?DirectEventHandler, /** * Make the drawer take the entire screen and draw the background of the diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 2e82e12dce7e81..dd035b56a8aaa2 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -232,6 +232,8 @@ class DrawerLayoutAndroid extends React.Component { ); } + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ _onDrawerSlide = event => { if (this.props.onDrawerSlide) { this.props.onDrawerSlide(event); @@ -253,6 +255,8 @@ class DrawerLayoutAndroid extends React.Component { } }; + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ _onDrawerStateChanged = event => { if (this.props.onDrawerStateChanged) { this.props.onDrawerStateChanged( diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js index d5fd5cf83f7560..3e519526096176 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js index c05331065cbae1..bc1b173de0a343 100644 --- a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js +++ b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index dc2309eba37f25..e7a7881742aa89 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -141,17 +141,6 @@ class Keyboard { return this._emitter.addListener(eventType, listener); } - /** - * @deprecated Use `remove` on the EventSubscription from `addListener`. - */ - removeListener>( - eventType: K, - listener: (...$ElementType) => mixed, - ): void { - // NOTE: This will report a deprecation notice via `console.error`. - this._emitter.removeListener(eventType, listener); - } - /** * Removes all listeners for a specific event type. * diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 3de920aa843a5e..4536402c5104f6 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -87,7 +87,7 @@ class KeyboardAvoidingView extends React.Component { _onKeyboardChange = (event: ?KeyboardEvent) => { this._keyboardEvent = event; - this._updateBottomIfNecesarry(); + this._updateBottomIfNecessary(); }; _onLayout = (event: ViewLayoutEvent) => { @@ -99,11 +99,15 @@ class KeyboardAvoidingView extends React.Component { } if (wasFrameNull) { - this._updateBottomIfNecesarry(); + this._updateBottomIfNecessary(); + } + + if (this.props.onLayout) { + this.props.onLayout(event); } }; - _updateBottomIfNecesarry = () => { + _updateBottomIfNecessary = () => { if (this._keyboardEvent == null) { this.setState({bottom: 0}); return; @@ -157,6 +161,7 @@ class KeyboardAvoidingView extends React.Component { // eslint-disable-next-line no-unused-vars keyboardVerticalOffset = 0, style, + onLayout, ...props } = this.props; const bottomHeight = enabled === true ? this.state.bottom : 0; diff --git a/Libraries/Components/Keyboard/NativeKeyboardObserver.js b/Libraries/Components/Keyboard/NativeKeyboardObserver.js index 7868dd9fb0941a..2dfa7500e27a82 100644 --- a/Libraries/Components/Keyboard/NativeKeyboardObserver.js +++ b/Libraries/Components/Keyboard/NativeKeyboardObserver.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js index c0ce474cdea44c..3094781e2cc201 100644 --- a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js +++ b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/MaskedView/MaskedViewIOS.android.js b/Libraries/Components/MaskedView/MaskedViewIOS.android.js index 016bfad57b6350..d9faa8e64e6bb4 100644 --- a/Libraries/Components/MaskedView/MaskedViewIOS.android.js +++ b/Libraries/Components/MaskedView/MaskedViewIOS.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js b/Libraries/Components/MaskedView/MaskedViewIOS.ios.js index eb69fc4233affc..9ae245ab6f3547 100644 --- a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js +++ b/Libraries/Components/MaskedView/MaskedViewIOS.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js b/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js index bae3709175a53e..73448de16c112c 100644 --- a/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js +++ b/Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js b/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js index 3c758c71878cac..0abfd11da6540a 100644 --- a/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js +++ b/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index 6f1e6001cfec11..aab4f21d33ed89 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,7 +22,7 @@ import type { } from '../View/ViewAccessibility'; import {PressabilityDebugView} from '../../Pressability/PressabilityDebug'; import usePressability from '../../Pressability/usePressability'; -import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect'; +import {type RectOrSize} from '../../StyleSheet/Rect'; import type { LayoutEvent, MouseEvent, @@ -43,6 +43,7 @@ type Props = $ReadOnly<{| accessibilityActions?: ?$ReadOnlyArray, accessibilityElementsHidden?: ?boolean, accessibilityHint?: ?Stringish, + accessibilityLanguage?: ?Stringish, accessibilityIgnoresInvertColors?: ?boolean, accessibilityLabel?: ?Stringish, accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), @@ -169,6 +170,8 @@ type Props = $ReadOnly<{| * Component used to build display components that should respond to whether the * component is currently pressed or not. */ +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ function Pressable(props: Props, forwardedRef): React.Node { const { accessible, @@ -181,6 +184,7 @@ function Pressable(props: Props, forwardedRef): React.Node { delayLongPress, disabled, focusable, + hitSlop, onHoverIn, onHoverOut, onLongPress, @@ -201,8 +205,6 @@ function Pressable(props: Props, forwardedRef): React.Node { const [pressed, setPressed] = usePressState(testOnly_pressed === true); - const hitSlop = normalizeRect(props.hitSlop); - const accessibilityState = disabled != null ? {...props.accessibilityState, disabled} diff --git a/Libraries/Components/Pressable/__tests__/Pressable-test.js b/Libraries/Components/Pressable/__tests__/Pressable-test.js index 46909623347aa1..09bb7ac8f336ca 100644 --- a/Libraries/Components/Pressable/__tests__/Pressable-test.js +++ b/Libraries/Components/Pressable/__tests__/Pressable-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Pressable/useAndroidRippleForView.js b/Libraries/Components/Pressable/useAndroidRippleForView.js index 18ee3d5c6a4623..e9682d7027a148 100644 --- a/Libraries/Components/Pressable/useAndroidRippleForView.js +++ b/Libraries/Components/Pressable/useAndroidRippleForView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index eb3db6f488df56..cae4e4dc7dfd33 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js index d5fd5cf83f7560..3e519526096176 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js index 5b2fb1a222f99f..625542b05baa9d 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js index 127a0d7149fc54..6d5a06d5bfe411 100644 --- a/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js +++ b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js index d642a6545ab5bb..4150bbf200849d 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js index de2068068dd4f9..2712055e649241 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js b/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js index c0c0b56bfef280..cd833d0cf38037 100644 --- a/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +++ b/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js b/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js index c6c0309d7dbe55..1509c91f8ff7fa 100644 --- a/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js +++ b/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js index 2e27a8af7c3cf9..0ef1fdc208c455 100644 --- a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index fa4791f2ab620c..0ebd98469e0aad 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index d04e01b53f6182..f62a893b489fca 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js b/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js index 4d54baa8f52ba8..80c6126641d693 100644 --- a/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +++ b/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js b/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js index 5365e35f8fce53..8cf1333d136097 100644 --- a/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +++ b/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,7 +9,6 @@ */ import type {ViewProps} from '../View/ViewPropTypes'; -import type {WithDefault} from '../../Types/CodegenTypes'; import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; @@ -17,8 +16,7 @@ import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; type NativeProps = $ReadOnly<{| ...ViewProps, - // Props - emulateUnlessSupported?: WithDefault, + // No props |}>; export default (codegenNativeComponent('SafeAreaView', { diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.js b/Libraries/Components/SafeAreaView/SafeAreaView.js index b71aac24e62bf2..1cb0004a38a7df 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,18 +12,9 @@ import Platform from '../../Utilities/Platform'; import * as React from 'react'; import View from '../View/View'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {ViewProps} from '../View/ViewPropTypes'; -type Props = $ReadOnly<{| - ...ViewProps, - emulateUnlessSupported?: boolean, -|}>; - -let exported: React.AbstractComponent< - Props, - React.ElementRef>, ->; +let exported: React.AbstractComponent>; /** * Renders nested content and automatically applies paddings reflect the portion @@ -35,27 +26,9 @@ let exported: React.AbstractComponent< * sensor housing area on iPhone X). */ if (Platform.OS === 'android') { - exported = React.forwardRef>>( - function SafeAreaView(props, forwardedRef) { - const {emulateUnlessSupported, ...localProps} = props; - return ; - }, - ); + exported = View; } else { - const RCTSafeAreaViewNativeComponent = - require('./RCTSafeAreaViewNativeComponent').default; - - exported = React.forwardRef>>( - function SafeAreaView(props, forwardedRef) { - return ( - - ); - }, - ); + exported = require('./RCTSafeAreaViewNativeComponent').default; } export default exported; diff --git a/Libraries/Components/SafeAreaView/__tests__/SafeAreaView-test.js b/Libraries/Components/SafeAreaView/__tests__/SafeAreaView-test.js index 4b7edf60fee47e..5c119842150907 100644 --- a/Libraries/Components/SafeAreaView/__tests__/SafeAreaView-test.js +++ b/Libraries/Components/SafeAreaView/__tests__/SafeAreaView-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap b/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap index b23f900172c9f6..a7fc900fbc99c2 100644 --- a/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap +++ b/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap @@ -1,9 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` should render as expected: should deep render when mocked (please verify output manually) 1`] = ` - + Hello World! @@ -13,9 +11,7 @@ exports[` should render as expected: should deep render when moc `; exports[` should render as expected: should deep render when not mocked (please verify output manually) 1`] = ` - + Hello World! @@ -25,21 +21,21 @@ exports[` should render as expected: should deep render when not `; exports[` should render as expected: should shallow render as when mocked 1`] = ` - + Hello World! - + `; exports[` should render as expected: should shallow render as when not mocked 1`] = ` - + Hello World! - + `; diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js index 71210f989d7e20..63f6e660d53dac 100644 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,8 @@ import type {ViewProps} from '../View/ViewPropTypes'; type NativeProps = $ReadOnly<{| ...ViewProps, + + removeClippedSubviews?: ?boolean, |}>; type NativeType = HostComponent; diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js index 343b63d4b4c9f6..7b2ce2060d2bcc 100644 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,34 +9,55 @@ */ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'AndroidHorizontalScrollView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: { + decelerationRate: true, + disableIntervalMomentum: true, + endFillColor: {process: require('../../StyleSheet/processColor')}, + fadingEdgeLength: true, + nestedScrollEnabled: true, + overScrollMode: true, + pagingEnabled: true, + persistentScrollbar: true, + scrollEnabled: true, + scrollPerfTag: true, + sendMomentumEvents: true, + showsHorizontalScrollIndicator: true, + snapToAlignment: true, + snapToEnd: true, + snapToInterval: true, + snapToStart: true, + snapToOffsets: true, + contentOffset: true, + borderBottomLeftRadius: true, + borderBottomRightRadius: true, + borderRadius: true, + borderStyle: true, + borderRightColor: {process: require('../../StyleSheet/processColor')}, + borderColor: {process: require('../../StyleSheet/processColor')}, + borderBottomColor: {process: require('../../StyleSheet/processColor')}, + borderTopLeftRadius: true, + borderTopColor: {process: require('../../StyleSheet/processColor')}, + removeClippedSubviews: true, + borderTopRightRadius: true, + borderLeftColor: {process: require('../../StyleSheet/processColor')}, + pointerEvents: true, + }, +}; + const AndroidHorizontalScrollViewNativeComponent: HostComponent = - NativeComponentRegistry.get('AndroidHorizontalScrollView', () => ({ - uiViewClassName: 'AndroidHorizontalScrollView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: { - decelerationRate: true, - disableIntervalMomentum: true, - endFillColor: {process: require('../../StyleSheet/processColor')}, - fadingEdgeLength: true, - nestedScrollEnabled: true, - overScrollMode: true, - pagingEnabled: true, - persistentScrollbar: true, - scrollEnabled: true, - scrollPerfTag: true, - sendMomentumEvents: true, - showsHorizontalScrollIndicator: true, - snapToAlignment: true, - snapToEnd: true, - snapToInterval: true, - snapToStart: true, - snapToOffsets: true, - contentOffset: true, - }, - })); + NativeComponentRegistry.get( + 'AndroidHorizontalScrollView', + () => __INTERNAL_VIEW_CONFIG, + ); export default AndroidHorizontalScrollViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js index afd3557ecd1ccf..09038e84ff0e60 100644 --- a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +++ b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,16 +8,24 @@ * @flow */ -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; import type {ViewProps as Props} from '../View/ViewPropTypes'; +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'RCTScrollContentView', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: {}, +}; + const ScrollContentViewNativeComponent: HostComponent = - NativeComponentRegistry.get('RCTScrollContentView', () => ({ - uiViewClassName: 'RCTScrollContentView', - bubblingEventTypes: {}, - directEventTypes: {}, - validAttributes: {}, - })); + NativeComponentRegistry.get( + 'RCTScrollContentView', + () => __INTERNAL_VIEW_CONFIG, + ); export default ScrollContentViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 87bec5b7629ff0..b268c65c2b5f5c 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -161,6 +161,7 @@ export type ScrollViewImperativeMethods = $ReadOnly<{| >, |}>; +export type DecelerationRateType = 'fast' | 'normal' | number; export type ScrollResponderType = ScrollViewImperativeMethods; type IOSProps = $ReadOnly<{| @@ -171,6 +172,12 @@ type IOSProps = $ReadOnly<{| * @platform ios */ automaticallyAdjustContentInsets?: ?boolean, + /** + * Controls whether the ScrollView should automatically adjust its `contentInset` + * and `scrollViewInsets` when the Keyboard changes its size. The default value is false. + * @platform ios + */ + automaticallyAdjustKeyboardInsets?: ?boolean, /** * Controls whether iOS should automatically adjust the scroll indicator * insets. The default value is true. Available on iOS 13 and later. @@ -183,12 +190,6 @@ type IOSProps = $ReadOnly<{| * @platform ios */ contentInset?: ?EdgeInsetsProp, - /** - * Used to manually set the starting scroll offset. - * The default value is `{x: 0, y: 0}`. - * @platform ios - */ - contentOffset?: ?PointProp, /** * When true, the scroll view bounces when it reaches the end of the * content if the content is larger then the scroll view along the axis of @@ -450,6 +451,11 @@ export type Props = $ReadOnly<{| * ``` */ contentContainerStyle?: ?ViewStyleProp, + /** + * Used to manually set the starting scroll offset. + * The default value is `{x: 0, y: 0}`. + */ + contentOffset?: ?PointProp, /** * When true, the scroll view stops on the next index (in relation to scroll * position at release) regardless of how fast the gesture is. This can be @@ -467,7 +473,7 @@ export type Props = $ReadOnly<{| * - `'normal'`: 0.998 on iOS, 0.985 on Android (the default) * - `'fast'`: 0.99 on iOS, 0.9 on Android */ - decelerationRate?: ?('fast' | 'normal' | number), + decelerationRate?: ?DecelerationRateType, /** * When true, the scroll view's children are arranged horizontally in a row * instead of vertically in a column. The default value is false. @@ -668,7 +674,7 @@ type State = {| const IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16; -type ScrollViewComponentStatics = $ReadOnly<{| +export type ScrollViewComponentStatics = $ReadOnly<{| Context: typeof ScrollViewContext, |}>; @@ -688,7 +694,7 @@ type ScrollViewComponentStatics = $ReadOnly<{| * view from becoming the responder. * * - * `` vs [``](https://reactnative.dev/docs/flatlist.html) - which one to use? + * `` vs [``](https://reactnative.dev/docs/flatlist) - which one to use? * * `ScrollView` simply renders all its react child components at once. That * makes it very easy to understand and use. @@ -1101,7 +1107,7 @@ class ScrollView extends React.Component { } }; - _getKeyForIndex(index, childArray) { + _getKeyForIndex(index: $FlowFixMe, childArray: $FlowFixMe) { const child = childArray[index]; return child && child.key; } @@ -1134,7 +1140,7 @@ class ScrollView extends React.Component { } } - _onStickyHeaderLayout(index, event, key) { + _onStickyHeaderLayout(index: $FlowFixMe, event: $FlowFixMe, key: $FlowFixMe) { const {stickyHeaderIndices} = this.props; if (!stickyHeaderIndices) { return; @@ -1512,6 +1518,7 @@ class ScrollView extends React.Component { keyboardNeverPersistTaps && this._keyboardIsDismissible() && e.target != null && + // $FlowFixMe[incompatible-call] !TextInputState.isTextInput(e.target) ) { return true; @@ -1815,7 +1822,9 @@ const styles = StyleSheet.create({ }, }); -function Wrapper(props, ref) { +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function Wrapper(props, ref: (mixed => mixed) | {current: mixed, ...}) { return ; } Wrapper.displayName = 'ScrollView'; diff --git a/Libraries/Components/ScrollView/ScrollViewCommands.js b/Libraries/Components/ScrollView/ScrollViewCommands.js index 4c1d8158ed4937..a18c4b089216fa 100644 --- a/Libraries/Components/ScrollView/ScrollViewCommands.js +++ b/Libraries/Components/ScrollView/ScrollViewCommands.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ScrollView/ScrollViewContext.js b/Libraries/Components/ScrollView/ScrollViewContext.js index 0b5e9ac40de003..4c194ad54941e5 100644 --- a/Libraries/Components/ScrollView/ScrollViewContext.js +++ b/Libraries/Components/ScrollView/ScrollViewContext.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js index ab6a5d3634b727..675ee113fd797c 100644 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,76 +9,155 @@ */ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; +import {ConditionallyIgnoredEventHandlers} from '../../NativeComponent/ViewConfigIgnore'; +import Platform from '../../Utilities/Platform'; + +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = + Platform.OS === 'android' + ? { + uiViewClassName: 'RCTScrollView', + bubblingEventTypes: {}, + directEventTypes: { + topMomentumScrollBegin: { + registrationName: 'onMomentumScrollBegin', + }, + topMomentumScrollEnd: { + registrationName: 'onMomentumScrollEnd', + }, + topScroll: { + registrationName: 'onScroll', + }, + topScrollBeginDrag: { + registrationName: 'onScrollBeginDrag', + }, + topScrollEndDrag: { + registrationName: 'onScrollEndDrag', + }, + }, + validAttributes: { + contentOffset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + decelerationRate: true, + disableIntervalMomentum: true, + pagingEnabled: true, + scrollEnabled: true, + showsVerticalScrollIndicator: true, + snapToAlignment: true, + snapToEnd: true, + snapToInterval: true, + snapToOffsets: true, + snapToStart: true, + borderBottomLeftRadius: true, + borderBottomRightRadius: true, + sendMomentumEvents: true, + borderRadius: true, + nestedScrollEnabled: true, + borderStyle: true, + borderRightColor: {process: require('../../StyleSheet/processColor')}, + borderColor: {process: require('../../StyleSheet/processColor')}, + borderBottomColor: { + process: require('../../StyleSheet/processColor'), + }, + persistentScrollbar: true, + endFillColor: {process: require('../../StyleSheet/processColor')}, + fadingEdgeLength: true, + overScrollMode: true, + borderTopLeftRadius: true, + scrollPerfTag: true, + borderTopColor: {process: require('../../StyleSheet/processColor')}, + removeClippedSubviews: true, + borderTopRightRadius: true, + borderLeftColor: {process: require('../../StyleSheet/processColor')}, + pointerEvents: true, + }, + } + : { + uiViewClassName: 'RCTScrollView', + bubblingEventTypes: {}, + directEventTypes: { + topMomentumScrollBegin: { + registrationName: 'onMomentumScrollBegin', + }, + topMomentumScrollEnd: { + registrationName: 'onMomentumScrollEnd', + }, + topScroll: { + registrationName: 'onScroll', + }, + topScrollBeginDrag: { + registrationName: 'onScrollBeginDrag', + }, + topScrollEndDrag: { + registrationName: 'onScrollEndDrag', + }, + topScrollToTop: { + registrationName: 'onScrollToTop', + }, + }, + validAttributes: { + alwaysBounceHorizontal: true, + alwaysBounceVertical: true, + automaticallyAdjustContentInsets: true, + automaticallyAdjustKeyboardInsets: true, + automaticallyAdjustsScrollIndicatorInsets: true, + bounces: true, + bouncesZoom: true, + canCancelContentTouches: true, + centerContent: true, + contentInset: { + diff: require('../../Utilities/differ/insetsDiffer'), + }, + contentOffset: { + diff: require('../../Utilities/differ/pointsDiffer'), + }, + contentInsetAdjustmentBehavior: true, + decelerationRate: true, + directionalLockEnabled: true, + disableIntervalMomentum: true, + indicatorStyle: true, + inverted: true, + keyboardDismissMode: true, + maintainVisibleContentPosition: true, + maximumZoomScale: true, + minimumZoomScale: true, + pagingEnabled: true, + pinchGestureEnabled: true, + scrollEnabled: true, + scrollEventThrottle: true, + scrollIndicatorInsets: { + diff: require('../../Utilities/differ/insetsDiffer'), + }, + scrollToOverflowEnabled: true, + scrollsToTop: true, + showsHorizontalScrollIndicator: true, + showsVerticalScrollIndicator: true, + snapToAlignment: true, + snapToEnd: true, + snapToInterval: true, + snapToOffsets: true, + snapToStart: true, + zoomScale: true, + ...ConditionallyIgnoredEventHandlers({ + onScrollBeginDrag: true, + onMomentumScrollEnd: true, + onScrollEndDrag: true, + onMomentumScrollBegin: true, + onScrollToTop: true, + onScroll: true, + }), + }, + }; const ScrollViewNativeComponent: HostComponent = - NativeComponentRegistry.get('RCTScrollView', () => ({ - uiViewClassName: 'RCTScrollView', - bubblingEventTypes: {}, - directEventTypes: { - topScrollToTop: { - registrationName: 'onScrollToTop', - }, - }, - validAttributes: { - alwaysBounceHorizontal: true, - alwaysBounceVertical: true, - automaticallyAdjustContentInsets: true, - automaticallyAdjustsScrollIndicatorInsets: true, - bounces: true, - bouncesZoom: true, - canCancelContentTouches: true, - centerContent: true, - contentInset: { - diff: require('../../Utilities/differ/pointsDiffer'), - }, - contentOffset: { - diff: require('../../Utilities/differ/pointsDiffer'), - }, - contentInsetAdjustmentBehavior: true, - decelerationRate: true, - directionalLockEnabled: true, - disableIntervalMomentum: true, - endFillColor: { - process: require('../../StyleSheet/processColor'), - }, - fadingEdgeLength: true, - indicatorStyle: true, - inverted: true, - keyboardDismissMode: true, - maintainVisibleContentPosition: true, - maximumZoomScale: true, - minimumZoomScale: true, - nestedScrollEnabled: true, - onMomentumScrollBegin: true, - onMomentumScrollEnd: true, - onScroll: true, - onScrollBeginDrag: true, - onScrollEndDrag: true, - onScrollToTop: true, - overScrollMode: true, - pagingEnabled: true, - persistentScrollbar: true, - pinchGestureEnabled: true, - scrollEnabled: true, - scrollEventThrottle: true, - scrollIndicatorInsets: { - diff: require('../../Utilities/differ/pointsDiffer'), - }, - scrollPerfTag: true, - scrollToOverflowEnabled: true, - scrollsToTop: true, - sendMomentumEvents: true, - showsHorizontalScrollIndicator: true, - showsVerticalScrollIndicator: true, - snapToAlignment: true, - snapToEnd: true, - snapToInterval: true, - snapToOffsets: true, - snapToStart: true, - zoomScale: true, - }, - })); + NativeComponentRegistry.get( + 'RCTScrollView', + () => __INTERNAL_VIEW_CONFIG, + ); export default ScrollViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js index 24e0c70f442787..956614947220ad 100644 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,6 +21,7 @@ export type ScrollViewNativeProps = $ReadOnly<{ alwaysBounceHorizontal?: ?boolean, alwaysBounceVertical?: ?boolean, automaticallyAdjustContentInsets?: ?boolean, + automaticallyAdjustKeyboardInsets?: ?boolean, automaticallyAdjustsScrollIndicatorInsets?: ?boolean, bounces?: ?boolean, bouncesZoom?: ?boolean, diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index e56412b600e71a..f6ca3ac8e1e6f4 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -90,7 +90,7 @@ class ScrollViewStickyHeader extends React.Component { } updateTranslateListener( - translateY: AnimatedImplementation.Interpolation, + translateY: AnimatedNode, isFabric: boolean, offset: AnimatedDiffClamp | null, ) { @@ -170,11 +170,15 @@ class ScrollViewStickyHeader extends React.Component { this.props.onLayout(event); const child = React.Children.only(this.props.children); - if (child.props.onLayout) { + if (child.props.onCellLayout) { + child.props.onCellLayout(event, child.props.cellKey, child.props.index); + } else if (child.props.onLayout) { child.props.onLayout(event); } }; + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ _setComponentRef = ref => { this._ref = ref; }; @@ -272,11 +276,11 @@ class ScrollViewStickyHeader extends React.Component { .interpolate({ extrapolateLeft: 'clamp', inputRange: [layoutY, layoutY + 1], - outputRange: ([0, 1]: Array), + outputRange: [0, 1], }) .interpolate({ inputRange: [0, 1], - outputRange: ([0, -1]: Array), + outputRange: [0, -1], }), -this.state.layoutHeight, 0, diff --git a/Libraries/Components/ScrollView/ScrollViewViewConfig.js b/Libraries/Components/ScrollView/ScrollViewViewConfig.js index 5b276d54fa0fe0..9fd5b6f6114f82 100644 --- a/Libraries/Components/ScrollView/ScrollViewViewConfig.js +++ b/Libraries/Components/ScrollView/ScrollViewViewConfig.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,6 +24,7 @@ const ScrollViewViewConfig = { alwaysBounceHorizontal: true, alwaysBounceVertical: true, automaticallyAdjustContentInsets: true, + automaticallyAdjustKeyboardInsets: true, automaticallyAdjustsScrollIndicatorInsets: true, bounces: true, bouncesZoom: true, diff --git a/Libraries/Components/ScrollView/__tests__/ScrollView-test.js b/Libraries/Components/ScrollView/__tests__/ScrollView-test.js index 6800bb2a681931..656017185ddefe 100644 --- a/Libraries/Components/ScrollView/__tests__/ScrollView-test.js +++ b/Libraries/Components/ScrollView/__tests__/ScrollView-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ScrollView/processDecelerationRate.js b/Libraries/Components/ScrollView/processDecelerationRate.js index b3d9542b6e55aa..72a5a0637d912c 100644 --- a/Libraries/Components/ScrollView/processDecelerationRate.js +++ b/Libraries/Components/ScrollView/processDecelerationRate.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js deleted file mode 100644 index a00ff34c34a0ac..00000000000000 --- a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import type {ViewProps} from '../View/ViewPropTypes'; -import type { - BubblingEventHandler, - WithDefault, - Int32, -} from '../../Types/CodegenTypes'; -import type {ColorValue} from '../../StyleSheet/StyleSheet'; - -export type OnChangeEvent = $ReadOnly<{| - value: Int32, - selectedSegmentIndex: Int32, -|}>; - -type NativeProps = $ReadOnly<{| - ...ViewProps, - - // Props - values?: $ReadOnlyArray, - selectedIndex?: WithDefault, - enabled?: WithDefault, - tintColor?: ?ColorValue, - textColor?: ?ColorValue, - backgroundColor?: ?ColorValue, - momentary?: WithDefault, - - // Events - onChange?: ?BubblingEventHandler, -|}>; - -export default (codegenNativeComponent( - 'RCTSegmentedControl', -): HostComponent); diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js deleted file mode 100644 index a4cbc5e98425b2..00000000000000 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -'use strict'; -import * as React from 'react'; -import StyleSheet from '../../StyleSheet/StyleSheet'; -import Text from '../../Text/Text'; -import View from '../View/View'; - -class DummySegmentedControlIOS extends React.Component { - render() { - return ( - - - SegmentedControlIOS is not supported on this platform! - - - ); - } -} - -const styles = StyleSheet.create({ - dummy: { - width: 120, - height: 50, - backgroundColor: '#ffbcbc', - borderWidth: 1, - borderColor: 'red', - alignItems: 'center', - justifyContent: 'center', - }, - text: { - color: '#333333', - margin: 5, - fontSize: 10, - }, -}); - -module.exports = DummySegmentedControlIOS; diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js deleted file mode 100644 index 1812a01018a36a..00000000000000 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -import * as React from 'react'; -import StyleSheet from '../../StyleSheet/StyleSheet'; -import type {OnChangeEvent} from './RCTSegmentedControlNativeComponent'; -import type {ViewProps} from '../View/ViewPropTypes'; -import RCTSegmentedControlNativeComponent from './RCTSegmentedControlNativeComponent'; -import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; - -type SegmentedControlIOSProps = $ReadOnly<{| - ...ViewProps, - /** - * The labels for the control's segment buttons, in order. - * - * The default value is an empty array. - */ - values?: $ReadOnlyArray, - /** - * The index in `props.values` of the segment to be (pre)selected. - */ - selectedIndex?: ?number, - /** - * If false the user won't be able to interact with the control. - * - * The default value is true. - */ - enabled?: boolean, - /** - * Accent color of the control. - */ - tintColor?: ?string, - /** - * If true, then selecting a segment won't persist visually. - * The `onValueChange` callback will still work as expected. - */ - momentary?: ?boolean, - /** - * Callback that is called when the user taps a segment - */ - onChange?: ?(event: SyntheticEvent) => void, - /** - * Callback that is called when the user taps a segment; - * passes the segment's value as an argument - */ - onValueChange?: ?(value: number) => mixed, -|}>; - -type Props = $ReadOnly<{| - ...SegmentedControlIOSProps, - forwardedRef: ?React.Ref, -|}>; - -/** - * Use `SegmentedControlIOS` to render a UISegmentedControl iOS. - * - * #### Programmatically changing selected index - * - * The selected index can be changed on the fly by assigning the - * selectedIndex prop to a state variable, then changing that variable. - * Note that the state variable would need to be updated as the user - * selects a value and changes the index, as shown in the example below. - * - * ```` - * { - * this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex}); - * }} - * /> - * ```` - */ - -class SegmentedControlIOS extends React.Component { - _onChange = (event: SyntheticEvent) => { - this.props.onChange && this.props.onChange(event); - this.props.onValueChange && - this.props.onValueChange(event.nativeEvent.value); - }; - - render() { - const {enabled, forwardedRef, onValueChange, style, values, ...props} = - this.props; - return ( - - ); - } -} - -const styles = StyleSheet.create({ - segmentedControl: { - height: 28, - }, -}); - -const SegmentedControlIOSWithRef = React.forwardRef( - ( - props: SegmentedControlIOSProps, - forwardedRef: ?React.Ref, - ) => { - return ; - }, -); - -/* $FlowFixMe[cannot-resolve-name] (>=0.89.0 site=react_native_ios_fb) This - * comment suppresses an error found when Flow v0.89 was deployed. To see the - * error, delete this comment and run Flow. */ -module.exports = (SegmentedControlIOSWithRef: NativeSegmentedControlIOS); diff --git a/Libraries/Components/SegmentedControlIOS/__tests__/SegmentedContolIOS-test.js b/Libraries/Components/SegmentedControlIOS/__tests__/SegmentedContolIOS-test.js deleted file mode 100644 index 605864bf697b88..00000000000000 --- a/Libraries/Components/SegmentedControlIOS/__tests__/SegmentedContolIOS-test.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @emails oncall+react_native - */ - -'use strict'; - -const React = require('react'); -const ReactTestRenderer = require('react-test-renderer'); - -const SegmentedControlIOS = require('../SegmentedControlIOS.ios'); - -describe('SegmentedControlIOS', () => { - it('renders the segmented control', () => { - const component = ReactTestRenderer.create(); - expect(component).not.toBeNull(); - }); - it('renders the segmented control with enabled default value', () => { - const component = ReactTestRenderer.create(); - expect(component.toTree().rendered.props.enabled).toBe(true); - expect(component).toMatchSnapshot(); - }); - it('renders the segmented control with enabled', () => { - const component = ReactTestRenderer.create( - , - ); - expect(component.toTree().rendered.props.enabled).toBe(true); - expect(component).toMatchSnapshot(); - }); - it('renders the segmented control with enabled set to false', () => { - const component = ReactTestRenderer.create( - , - ); - expect(component.toTree().rendered.props.enabled).toBe(false); - expect(component).toMatchSnapshot(); - }); - it('renders the segmented control with values default value', () => { - const component = ReactTestRenderer.create(); - expect(component.toTree().rendered.props.values).toEqual([]); - expect(component).toMatchSnapshot(); - }); - it('renders the segmented control with values', () => { - const values = ['One', 'Two']; - const component = ReactTestRenderer.create( - , - ); - expect(component.toTree().rendered.props.values).toBe(values); - expect(component).toMatchSnapshot(); - }); -}); diff --git a/Libraries/Components/SegmentedControlIOS/__tests__/__snapshots__/SegmentedContolIOS-test.js.snap b/Libraries/Components/SegmentedControlIOS/__tests__/__snapshots__/SegmentedContolIOS-test.js.snap deleted file mode 100644 index 30195d27c7f857..00000000000000 --- a/Libraries/Components/SegmentedControlIOS/__tests__/__snapshots__/SegmentedContolIOS-test.js.snap +++ /dev/null @@ -1,86 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`SegmentedControlIOS renders the segmented control with enabled 1`] = ` - -`; - -exports[`SegmentedControlIOS renders the segmented control with enabled default value 1`] = ` - -`; - -exports[`SegmentedControlIOS renders the segmented control with enabled set to false 1`] = ` - -`; - -exports[`SegmentedControlIOS renders the segmented control with values 1`] = ` - -`; - -exports[`SegmentedControlIOS renders the segmented control with values default value 1`] = ` - -`; diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index c4cf2074b23807..c3aee2d2d3dc89 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -228,7 +228,6 @@ const Slider = ( } : null; - const onChangeEvent = onValueChangeEvent; const onSlidingCompleteEvent = onSlidingComplete ? (event: Event) => { onSlidingComplete(event.nativeEvent.value); @@ -250,7 +249,6 @@ const Slider = ( disabled={disabled} maximumValue={maximumValue} minimumValue={minimumValue} - onChange={onChangeEvent} onResponderTerminationRequest={() => false} onSlidingComplete={onSlidingCompleteEvent} onStartShouldSetResponder={() => true} diff --git a/Libraries/Components/Slider/SliderNativeComponent.js b/Libraries/Components/Slider/SliderNativeComponent.js index 18868e9a003de7..9846c1a9ded0df 100644 --- a/Libraries/Components/Slider/SliderNativeComponent.js +++ b/Libraries/Components/Slider/SliderNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,9 +47,8 @@ type NativeProps = $ReadOnly<{| value?: WithDefault, // Events - onChange?: ?BubblingEventHandler, - onValueChange?: ?BubblingEventHandler, - onSlidingComplete?: ?DirectEventHandler, + onValueChange?: ?BubblingEventHandler, + onSlidingComplete?: ?DirectEventHandler, |}>; export default (codegenNativeComponent('Slider', { diff --git a/Libraries/Components/Sound/NativeSoundManager.js b/Libraries/Components/Sound/NativeSoundManager.js index fcf14489741db9..1abf8c82bb3d92 100644 --- a/Libraries/Components/Sound/NativeSoundManager.js +++ b/Libraries/Components/Sound/NativeSoundManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Sound/SoundManager.js b/Libraries/Components/Sound/SoundManager.js index 542642917859b4..ff1a2cfaba47d7 100644 --- a/Libraries/Components/Sound/SoundManager.js +++ b/Libraries/Components/Sound/SoundManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/StaticRenderer.js b/Libraries/Components/StaticRenderer.js index 292c8660cc5490..666dbd1cd34709 100644 --- a/Libraries/Components/StaticRenderer.js +++ b/Libraries/Components/StaticRenderer.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js index fb7647c8b4c157..4e13d10ba7b43b 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js b/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js index 4765b603a86543..6218a70bc5b5d1 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 49c96f77e07335..e07389c97231f0 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -112,14 +112,17 @@ function mergePropsStack( propsStack: Array, defaultValues: Object, ): Object { - return propsStack.reduce((prev, cur) => { - for (const prop in cur) { - if (cur[prop] != null) { - prev[prop] = cur[prop]; + return propsStack.reduce( + (prev, cur) => { + for (const prop in cur) { + if (cur[prop] != null) { + prev[prop] = cur[prop]; + } } - } - return prev; - }, Object.assign({}, defaultValues)); + return prev; + }, + {...defaultValues}, + ); } /** @@ -471,7 +474,12 @@ class StatusBar extends React.Component { if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) { NativeStatusBarManagerAndroid.setHidden(mergedProps.hidden.value); } - if (!oldProps || oldProps.translucent !== mergedProps.translucent) { + // Activities are not translucent by default, so always set if true. + if ( + !oldProps || + oldProps.translucent !== mergedProps.translucent || + mergedProps.translucent + ) { NativeStatusBarManagerAndroid.setTranslucent(mergedProps.translucent); } } diff --git a/Libraries/Components/StatusBar/__tests__/StatusBar-test.js b/Libraries/Components/StatusBar/__tests__/StatusBar-test.js index a75d4fc1b0d31c..976af8aa6985a9 100644 --- a/Libraries/Components/StatusBar/__tests__/StatusBar-test.js +++ b/Libraries/Components/StatusBar/__tests__/StatusBar-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Switch/AndroidSwitchNativeComponent.js b/Libraries/Components/Switch/AndroidSwitchNativeComponent.js index 7d7b8dd36820c3..200c5230d6603a 100644 --- a/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +++ b/Libraries/Components/Switch/AndroidSwitchNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index abb7f00b761df7..a87a4a3fe940ed 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -170,7 +170,8 @@ const SwitchWithForwardedRef: React.AbstractComponent< // that the update should be ignored and we should stick with the value // that we have in JS. const jsValue = value === true; - const shouldUpdateNativeSwitch = native.value !== jsValue; + const shouldUpdateNativeSwitch = + native.value != null && native.value !== jsValue; if ( shouldUpdateNativeSwitch && nativeSwitchRef.current?.setNativeProps != null @@ -184,8 +185,18 @@ const SwitchWithForwardedRef: React.AbstractComponent< }, [value, native]); if (Platform.OS === 'android') { + const {accessibilityState} = restProps; + const _disabled = + disabled != null ? disabled : accessibilityState?.disabled; + + const _accessibilityState = + _disabled !== accessibilityState?.disabled + ? {...accessibilityState, disabled: _disabled} + : accessibilityState; + const platformProps = { - enabled: disabled !== true, + accessibilityState: _accessibilityState, + enabled: _disabled !== true, on: value === true, style, thumbTintColor: thumbColor, diff --git a/Libraries/Components/Switch/SwitchNativeComponent.js b/Libraries/Components/Switch/SwitchNativeComponent.js index 7f4715de180865..5187656915de29 100644 --- a/Libraries/Components/Switch/SwitchNativeComponent.js +++ b/Libraries/Components/Switch/SwitchNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index 26dfb420637695..e896a77f810f16 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,7 +17,10 @@ import type { Int32, WithDefault, } from '../../Types/CodegenTypes'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import type { TextStyleProp, ViewStyleProp, @@ -25,7 +28,6 @@ import type { } from '../../StyleSheet/StyleSheet'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; -import AndroidTextInputViewConfig from './AndroidTextInputViewConfig'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; export type KeyboardType = @@ -594,9 +596,125 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'AndroidTextInput', + bubblingEventTypes: { + topBlur: { + phasedRegistrationNames: { + bubbled: 'onBlur', + captured: 'onBlurCapture', + }, + }, + topEndEditing: { + phasedRegistrationNames: { + bubbled: 'onEndEditing', + captured: 'onEndEditingCapture', + }, + }, + topFocus: { + phasedRegistrationNames: { + bubbled: 'onFocus', + captured: 'onFocusCapture', + }, + }, + topKeyPress: { + phasedRegistrationNames: { + bubbled: 'onKeyPress', + captured: 'onKeyPressCapture', + }, + }, + topSubmitEditing: { + phasedRegistrationNames: { + bubbled: 'onSubmitEditing', + captured: 'onSubmitEditingCapture', + }, + }, + topTextInput: { + phasedRegistrationNames: { + bubbled: 'onTextInput', + captured: 'onTextInputCapture', + }, + }, + }, + directEventTypes: { + topScroll: { + registrationName: 'onScroll', + }, + }, + validAttributes: { + maxFontSizeMultiplier: true, + adjustsFontSizeToFit: true, + minimumFontScale: true, + autoFocus: true, + placeholder: true, + inlineImagePadding: true, + contextMenuHidden: true, + textShadowColor: {process: require('../../StyleSheet/processColor')}, + maxLength: true, + selectTextOnFocus: true, + textShadowRadius: true, + underlineColorAndroid: { + process: require('../../StyleSheet/processColor'), + }, + textDecorationLine: true, + blurOnSubmit: true, + textAlignVertical: true, + fontStyle: true, + textShadowOffset: true, + selectionColor: {process: require('../../StyleSheet/processColor')}, + selection: true, + placeholderTextColor: {process: require('../../StyleSheet/processColor')}, + importantForAutofill: true, + lineHeight: true, + textTransform: true, + returnKeyType: true, + keyboardType: true, + multiline: true, + color: {process: require('../../StyleSheet/processColor')}, + autoComplete: true, + numberOfLines: true, + letterSpacing: true, + returnKeyLabel: true, + fontSize: true, + onKeyPress: true, + cursorColor: {process: require('../../StyleSheet/processColor')}, + text: true, + showSoftInputOnFocus: true, + textAlign: true, + autoCapitalize: true, + autoCorrect: true, + caretHidden: true, + secureTextEntry: true, + textBreakStrategy: true, + onScroll: true, + onContentSizeChange: true, + disableFullscreenUI: true, + includeFontPadding: true, + fontWeight: true, + fontFamily: true, + allowFontScaling: true, + onSelectionChange: true, + mostRecentEventCount: true, + inlineImageLeft: true, + editable: true, + fontVariant: true, + borderBottomRightRadius: true, + borderBottomColor: {process: require('../../StyleSheet/processColor')}, + borderRadius: true, + borderRightColor: {process: require('../../StyleSheet/processColor')}, + borderColor: {process: require('../../StyleSheet/processColor')}, + borderTopRightRadius: true, + borderStyle: true, + borderBottomLeftRadius: true, + borderLeftColor: {process: require('../../StyleSheet/processColor')}, + borderTopLeftRadius: true, + borderTopColor: {process: require('../../StyleSheet/processColor')}, + }, +}; + let AndroidTextInputNativeComponent = NativeComponentRegistry.get( 'AndroidTextInput', - () => AndroidTextInputViewConfig, + () => __INTERNAL_VIEW_CONFIG, ); // flowlint-next-line unclear-type:off diff --git a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js deleted file mode 100644 index e659a3de64ef97..00000000000000 --- a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -import type {PartialViewConfig} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; - -const AndroidTextInputViewConfig = { - uiViewClassName: 'AndroidTextInput', - bubblingEventTypes: { - topBlur: { - phasedRegistrationNames: { - bubbled: 'onBlur', - captured: 'onBlurCapture', - }, - }, - topEndEditing: { - phasedRegistrationNames: { - bubbled: 'onEndEditing', - captured: 'onEndEditingCapture', - }, - }, - topFocus: { - phasedRegistrationNames: { - bubbled: 'onFocus', - captured: 'onFocusCapture', - }, - }, - topKeyPress: { - phasedRegistrationNames: { - bubbled: 'onKeyPress', - captured: 'onKeyPressCapture', - }, - }, - topSubmitEditing: { - phasedRegistrationNames: { - bubbled: 'onSubmitEditing', - captured: 'onSubmitEditingCapture', - }, - }, - topTextInput: { - phasedRegistrationNames: { - bubbled: 'onTextInput', - captured: 'onTextInputCapture', - }, - }, - }, - directEventTypes: {}, - validAttributes: { - maxFontSizeMultiplier: true, - adjustsFontSizeToFit: true, - minimumFontScale: true, - autoFocus: true, - placeholder: true, - inlineImagePadding: true, - contextMenuHidden: true, - textShadowColor: {process: require('../../StyleSheet/processColor')}, - maxLength: true, - selectTextOnFocus: true, - textShadowRadius: true, - underlineColorAndroid: {process: require('../../StyleSheet/processColor')}, - textDecorationLine: true, - blurOnSubmit: true, - textAlignVertical: true, - fontStyle: true, - textShadowOffset: true, - selectionColor: {process: require('../../StyleSheet/processColor')}, - selection: true, - placeholderTextColor: {process: require('../../StyleSheet/processColor')}, - importantForAutofill: true, - lineHeight: true, - textTransform: true, - returnKeyType: true, - keyboardType: true, - multiline: true, - color: {process: require('../../StyleSheet/processColor')}, - autoCompleteType: true, - autoComplete: true, - numberOfLines: true, - letterSpacing: true, - returnKeyLabel: true, - fontSize: true, - onKeyPress: true, - cursorColor: {process: require('../../StyleSheet/processColor')}, - text: true, - showSoftInputOnFocus: true, - textAlign: true, - autoCapitalize: true, - autoCorrect: true, - caretHidden: true, - secureTextEntry: true, - textBreakStrategy: true, - onScroll: true, - onContentSizeChange: true, - disableFullscreenUI: true, - includeFontPadding: true, - fontWeight: true, - fontFamily: true, - allowFontScaling: true, - onSelectionChange: true, - mostRecentEventCount: true, - inlineImageLeft: true, - editable: true, - fontVariant: true, - }, -}; - -module.exports = (AndroidTextInputViewConfig: PartialViewConfig); diff --git a/Libraries/Components/TextInput/InputAccessoryView.js b/Libraries/Components/TextInput/InputAccessoryView.js index eb83a9ca0e7b8e..598155f2a3d61c 100644 --- a/Libraries/Components/TextInput/InputAccessoryView.js +++ b/Libraries/Components/TextInput/InputAccessoryView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -88,22 +88,23 @@ type Props = $ReadOnly<{| class InputAccessoryView extends React.Component { render(): React.Node { - if (Platform.OS !== 'ios') { - console.warn(' is only supported on iOS.'); - } + if (Platform.OS === 'ios') { + if (React.Children.count(this.props.children) === 0) { + return null; + } - if (React.Children.count(this.props.children) === 0) { + return ( + + {this.props.children} + + ); + } else { + console.warn(' is only supported on iOS.'); return null; } - - return ( - - {this.props.children} - - ); } } diff --git a/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js b/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js index 1a37cd95e75c67..f9e7508501c6bc 100644 --- a/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +++ b/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js b/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js index 59dd16ece0ab7a..9c42d59cacb989 100644 --- a/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,7 +8,10 @@ * @format */ -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; import RCTTextInputViewConfig from './RCTTextInputViewConfig'; @@ -22,10 +25,19 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'RCTMultilineTextInputView', + ...RCTTextInputViewConfig, + validAttributes: { + ...RCTTextInputViewConfig.validAttributes, + dataDetectorTypes: true, + }, +}; + const MultilineTextInputNativeComponent: HostComponent = NativeComponentRegistry.get( 'RCTMultilineTextInputView', - () => RCTTextInputViewConfig, + () => __INTERNAL_VIEW_CONFIG, ); // flowlint-next-line unclear-type:off diff --git a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js index 043451a1c8f35c..dfc01c34c541cd 100644 --- a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,7 +8,10 @@ * @format */ -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; import RCTTextInputViewConfig from './RCTTextInputViewConfig'; @@ -22,10 +25,15 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'RCTSinglelineTextInputView', + ...RCTTextInputViewConfig, +}; + const SinglelineTextInputNativeComponent: HostComponent = NativeComponentRegistry.get( 'RCTSinglelineTextInputView', - () => RCTTextInputViewConfig, + () => __INTERNAL_VIEW_CONFIG, ); // flowlint-next-line unclear-type:off diff --git a/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/Libraries/Components/TextInput/RCTTextInputViewConfig.js index ef910892b236e2..52134db4419f14 100644 --- a/Libraries/Components/TextInput/RCTTextInputViewConfig.js +++ b/Libraries/Components/TextInput/RCTTextInputViewConfig.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,9 +9,14 @@ */ import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; +import {ConditionallyIgnoredEventHandlers} from '../../NativeComponent/ViewConfigIgnore'; + +type PartialViewConfigWithoutName = $Rest< + PartialViewConfig, + {uiViewClassName: string}, +>; const RCTTextInputViewConfig = { - uiViewClassName: 'RCTSinglelineTextInputView', bubblingEventTypes: { topBlur: { phasedRegistrationNames: { @@ -25,6 +30,12 @@ const RCTTextInputViewConfig = { captured: 'onChangeCapture', }, }, + topContentSizeChange: { + phasedRegistrationNames: { + captured: 'onContentSizeChangeCapture', + bubbled: 'onContentSizeChange', + }, + }, topEndEditing: { phasedRegistrationNames: { bubbled: 'onEndEditing', @@ -69,7 +80,23 @@ const RCTTextInputViewConfig = { }, }, }, - directEventTypes: {}, + directEventTypes: { + topTextInput: { + registrationName: 'onTextInput', + }, + topKeyPressSync: { + registrationName: 'onKeyPressSync', + }, + topScroll: { + registrationName: 'onScroll', + }, + topSelectionChange: { + registrationName: 'onSelectionChange', + }, + topChangeSync: { + registrationName: 'onChangeSync', + }, + }, validAttributes: { fontSize: true, fontWeight: true, @@ -97,23 +124,18 @@ const RCTTextInputViewConfig = { caretHidden: true, enablesReturnKeyAutomatically: true, placeholderTextColor: {process: require('../../StyleSheet/processColor')}, - onSelectionChange: true, clearButtonMode: true, - onContentSizeChange: true, keyboardType: true, selection: true, returnKeyType: true, blurOnSubmit: true, mostRecentEventCount: true, - onChange: true, scrollEnabled: true, selectionColor: {process: require('../../StyleSheet/processColor')}, contextMenuHidden: true, secureTextEntry: true, - onTextInput: true, placeholder: true, autoCorrect: true, - onScroll: true, multiline: true, textContentType: true, maxLength: true, @@ -124,7 +146,18 @@ const RCTTextInputViewConfig = { selectTextOnFocus: true, text: true, clearTextOnFocus: true, + showSoftInputOnFocus: true, + autoFocus: true, + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + onSelectionChange: true, + onContentSizeChange: true, + onScroll: true, + onChangeSync: true, + onKeyPressSync: true, + onTextInput: true, + }), }, }; -module.exports = (RCTTextInputViewConfig: PartialViewConfig); +module.exports = (RCTTextInputViewConfig: PartialViewConfigWithoutName); diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 53642621c58d75..8fa117192fa032 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -392,6 +392,14 @@ type AndroidProps = $ReadOnly<{| | 'off' ), + /** + * When provided it will set the color of the cursor (or "caret") in the component. + * Unlike the behavior of `selectionColor` the cursor color will be set independently + * from the color of the text selection box. + * @platform android + */ + cursorColor?: ?ColorValue, + /** * When `false`, if there is a small amount of space available around a text input * (e.g. landscape orientation on a phone), the OS may choose to have the user edit @@ -598,12 +606,33 @@ export type Props = $ReadOnly<{| */ onChange?: ?(e: ChangeEvent) => mixed, + /** + * DANGER: this API is not stable and will change in the future. + * + * Callback will be called on the main thread and may result in dropped frames. + * Callback that is called when the text input's text changes. + * + * @platform ios + */ + unstable_onChangeSync?: ?(e: ChangeEvent) => mixed, + /** * Callback that is called when the text input's text changes. * Changed text is passed as an argument to the callback handler. */ onChangeText?: ?(text: string) => mixed, + /** + * DANGER: this API is not stable and will change in the future. + * + * Callback will be called on the main thread and may result in dropped frames. + * Callback that is called when the text input's text changes. + * Changed text is passed as an argument to the callback handler. + * + * @platform ios + */ + unstable_onChangeTextSync?: ?(text: string) => mixed, + /** * Callback that is called when the text input's content size changes. * This will be called with @@ -632,6 +661,21 @@ export type Props = $ReadOnly<{| */ onKeyPress?: ?(e: KeyPressEvent) => mixed, + /** + * DANGER: this API is not stable and will change in the future. + * + * Callback will be called on the main thread and may result in dropped frames. + * + * Callback that is called when a key is pressed. + * This will be called with `{ nativeEvent: { key: keyValue } }` + * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and + * the typed-in character otherwise including `' '` for space. + * Fires before `onChange` callbacks. + * + * @platform ios + */ + unstable_onKeyPressSync?: ?(e: KeyPressEvent) => mixed, + /** * Called when a touch is engaged. */ @@ -766,6 +810,7 @@ type ImperativeMethods = $ReadOnly<{| clear: () => void, isFocused: () => boolean, getNativeRef: () => ?React.ElementRef>, + setSelection: (start: number, end: number) => void, |}>; const emptyFunctionThatReturnsTrue = () => true; @@ -939,7 +984,7 @@ function InternalTextInput(props: Props): React.Node { // that the update should be ignored and we should stick with the value // that we have in JS. useLayoutEffect(() => { - const nativeUpdate = {}; + const nativeUpdate: {text?: string, selection?: Selection} = {}; if (lastNativeText !== props.value && typeof props.value === 'string') { nativeUpdate.text = props.value; @@ -1009,6 +1054,18 @@ function InternalTextInput(props: Props): React.Node { } } + function setSelection(start: number, end: number): void { + if (inputRef.current != null) { + viewCommands.setTextAndSelection( + inputRef.current, + mostRecentEventCount, + null, + start, + end, + ); + } + } + // TODO: Fix this returning true on null === null, when no input is focused function isFocused(): boolean { return TextInputState.currentlyFocusedInput() === inputRef.current; @@ -1049,6 +1106,7 @@ function InternalTextInput(props: Props): React.Node { ref.clear = clear; ref.isFocused = isFocused; ref.getNativeRef = getNativeRef; + ref.setSelection = setSelection; } }, }); @@ -1072,6 +1130,26 @@ function InternalTextInput(props: Props): React.Node { setMostRecentEventCount(event.nativeEvent.eventCount); }; + const _onChangeSync = (event: ChangeEvent) => { + const currentText = event.nativeEvent.text; + props.unstable_onChangeSync && props.unstable_onChangeSync(event); + props.unstable_onChangeTextSync && + props.unstable_onChangeTextSync(currentText); + + if (inputRef.current == null) { + // calling `props.onChange` or `props.onChangeText` + // may clean up the input itself. Exits here. + return; + } + + setLastNativeText(currentText); + // This must happen last, after we call setLastNativeText. + // Different ordering can cause bugs when editing AndroidTextInputs + // with multiple Fragments. + // We must update this so that controlled input updates work. + setMostRecentEventCount(event.nativeEvent.eventCount); + }; + const _onSelectionChange = (event: SelectionChangeEvent) => { props.onSelectionChange && props.onSelectionChange(event); @@ -1155,9 +1233,13 @@ function InternalTextInput(props: Props): React.Node { const style = props.multiline === true - ? [styles.multilineInput, props.style] + ? StyleSheet.flatten([styles.multilineInput, props.style]) : props.style; + const useOnChangeSync = + (props.unstable_onChangeSync || props.unstable_onChangeTextSync) && + !(props.onChange || props.onChangeText); + textInput = ( { inputRef = React.createRef(null); onChangeListener = jest.fn(); onChangeTextListener = jest.fn(); - const renderTree = ReactTestRenderer.create( - - {({setState, state}) => ( - { - onChangeTextListener(text); - setState({text}); - }} - onChange={event => { - onChangeListener(event); - }} - /> - )} - , - ); + function TextInputWrapper() { + const [state, setState] = React.useState({text: initialValue}); + + return ( + { + onChangeTextListener(text); + setState({text}); + }} + onChange={event => { + onChangeListener(event); + }} + /> + ); + } + const renderTree = ReactTestRenderer.create(); input = renderTree.root.findByType(TextInput); }); it('has expected instance functions', () => { @@ -71,7 +70,9 @@ describe('TextInput tests', () => { it('calls onChange callbacks', () => { expect(input.props.value).toBe(initialValue); const message = 'This is a test message'; - enter(input, message); + ReactTestRenderer.act(() => { + enter(input, message); + }); expect(input.props.value).toBe(message); expect(onChangeTextListener).toHaveBeenCalledWith(message); expect(onChangeListener).toHaveBeenCalledWith({ @@ -79,9 +80,26 @@ describe('TextInput tests', () => { }); }); - it('should have support being focused and unfocused', () => { + function createTextInput(extraProps) { const textInputRef = React.createRef(null); - ReactTestRenderer.create(); + ReactTestRenderer.create( + , + ); + return textInputRef; + } + + it('focus() should not do anything if the TextInput is not editable', () => { + const textInputRef = createTextInput({editable: false}); + // currentProps is the property actually containing props at runtime + textInputRef.current.currentProps = textInputRef.current.props; + expect(textInputRef.current.isFocused()).toBe(false); + + TextInput.State.focusTextInput(textInputRef.current); + expect(textInputRef.current.isFocused()).toBe(false); + }); + + it('should have support for being focused and blurred', () => { + const textInputRef = createTextInput(); expect(textInputRef.current.isFocused()).toBe(false); ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => { diff --git a/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap index ea9693e96244c5..874fae2b158a92 100644 --- a/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap +++ b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap @@ -10,6 +10,7 @@ exports[`TextInput tests should render as expected: should deep render when mock mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} + onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -38,6 +39,7 @@ exports[`TextInput tests should render as expected: should deep render when not mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} + onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} diff --git a/Libraries/Components/ToastAndroid/NativeToastAndroid.js b/Libraries/Components/ToastAndroid/NativeToastAndroid.js index 7325c47d484d52..b35757b25d43b4 100644 --- a/Libraries/Components/ToastAndroid/NativeToastAndroid.js +++ b/Libraries/Components/ToastAndroid/NativeToastAndroid.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.android.js b/Libraries/Components/ToastAndroid/ToastAndroid.android.js index b29ec4ede71d6b..81e03fd8f30feb 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.android.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js index 01fa7998ae6b18..d6e98fc61d97e2 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/BoundingDimensions.js b/Libraries/Components/Touchable/BoundingDimensions.js index 5aa45dba22b3ca..87d9279bc68637 100644 --- a/Libraries/Components/Touchable/BoundingDimensions.js +++ b/Libraries/Components/Touchable/BoundingDimensions.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/PooledClass.js b/Libraries/Components/Touchable/PooledClass.js index 90874da32a5088..67847c1ba0c095 100644 --- a/Libraries/Components/Touchable/PooledClass.js +++ b/Libraries/Components/Touchable/PooledClass.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,9 @@ import invariant from 'invariant'; * the Class itself, not an instance. If any others are needed, simply add them * here, or in their own files. */ -const oneArgumentPooler = function (copyFieldsFrom) { +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ +const oneArgumentPooler = function (copyFieldsFrom: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -29,7 +31,9 @@ const oneArgumentPooler = function (copyFieldsFrom) { } }; -const twoArgumentPooler = function (a1, a2) { +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ +const twoArgumentPooler = function (a1: any, a2: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -40,7 +44,9 @@ const twoArgumentPooler = function (a1, a2) { } }; -const threeArgumentPooler = function (a1, a2, a3) { +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ +const threeArgumentPooler = function (a1: any, a2: any, a3: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -51,7 +57,9 @@ const threeArgumentPooler = function (a1, a2, a3) { } }; -const fourArgumentPooler = function (a1, a2, a3, a4) { +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ +const fourArgumentPooler = function (a1: any, a2: any, a3: any, a4: any) { const Klass = this; // eslint-disable-line consistent-this if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -62,6 +70,10 @@ const fourArgumentPooler = function (a1, a2, a3, a4) { } }; +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ const standardReleaser = function (instance) { const Klass = this; // eslint-disable-line consistent-this invariant( diff --git a/Libraries/Components/Touchable/Position.js b/Libraries/Components/Touchable/Position.js index dd06e5288d1ea3..adbbd170c0d0c5 100644 --- a/Libraries/Components/Touchable/Position.js +++ b/Libraries/Components/Touchable/Position.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 972bc11ed91c4d..ea448b3efb50c1 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,7 +21,18 @@ import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {PressEvent} from '../../Types/CoreEventTypes'; -const extractSingleTouch = nativeEvent => { +const extractSingleTouch = (nativeEvent: { + +changedTouches: $ReadOnlyArray, + +force?: number, + +identifier: number, + +locationX: number, + +locationY: number, + +pageX: number, + +pageY: number, + +target: ?number, + +timestamp: number, + +touches: $ReadOnlyArray, +}) => { const touches = nativeEvent.touches; const changedTouches = nativeEvent.changedTouches; const hasTouches = touches && touches.length > 0; @@ -370,6 +381,8 @@ const TouchableMixin = { /** * Clear all timeouts on unmount */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ componentWillUnmount: function () { this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout); this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); @@ -395,6 +408,8 @@ const TouchableMixin = { /** * Must return true if embedded in a native platform scroll view. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderTerminationRequest: function (): any { return !this.props.rejectResponderTermination; }, @@ -402,6 +417,8 @@ const TouchableMixin = { /** * Must return true to start the process of `Touchable`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleStartShouldSetResponder: function (): any { return !this.props.disabled; }, @@ -418,6 +435,8 @@ const TouchableMixin = { * @param {SyntheticEvent} e Synthetic event from event system. * */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderGrant: function (e: PressEvent) { const dispatchID = e.currentTarget; // Since e is used in a callback invoked on another event loop @@ -459,6 +478,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderRelease` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderRelease: function (e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_RELEASE, e); @@ -467,6 +488,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderTerminate` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderTerminate: function (e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_TERMINATED, e); @@ -475,6 +498,8 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderMove` event. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleResponderMove: function (e: PressEvent) { // Measurement may not have returned yet. if (!this.state.touchable.positionOnActivate) { @@ -560,6 +585,8 @@ const TouchableMixin = { * element that was blurred just prior to this. This can be overridden when * using `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleFocus: function (e: Event) { this.props.onFocus && this.props.onFocus(e); }, @@ -572,6 +599,8 @@ const TouchableMixin = { * This can be overridden when using * `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ touchableHandleBlur: function (e: Event) { this.props.onBlur && this.props.onBlur(e); }, @@ -652,6 +681,8 @@ const TouchableMixin = { * @sideeffects * @private */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _remeasureMetricsOnActivation: function () { const responderID = this.state.touchable.responderID; if (responderID == null) { @@ -665,6 +696,8 @@ const TouchableMixin = { } }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleQueryLayout: function ( l: number, t: number, @@ -691,11 +724,15 @@ const TouchableMixin = { ); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleDelay: function (e: PressEvent) { this.touchableDelayTimeout = null; this._receiveSignal(Signals.DELAY, e); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _handleLongDelay: function (e: PressEvent) { this.longPressDelayTimeout = null; const curState = this.state.touchable.touchState; @@ -715,6 +752,8 @@ const TouchableMixin = { * @throws Error if invalid state transition or unrecognized signal. * @sideeffects */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _receiveSignal: function (signal: Signal, e: PressEvent) { const responderID = this.state.touchable.responderID; const curState = this.state.touchable.touchState; @@ -754,6 +793,8 @@ const TouchableMixin = { } }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _cancelLongPressDelayTimeout: function () { this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); this.longPressDelayTimeout = null; @@ -766,6 +807,8 @@ const TouchableMixin = { ); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _savePressInLocation: function (e: PressEvent) { const touch = extractSingleTouch(e.nativeEvent); const pageX = touch && touch.pageX; @@ -797,6 +840,8 @@ const TouchableMixin = { * @param {Event} e Native event. * @sideeffects */ + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _performSideEffectsForTransition: function ( curState: State, nextState: State, @@ -858,11 +903,15 @@ const TouchableMixin = { this.touchableDelayTimeout = null; }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _startHighlight: function (e: PressEvent) { this._savePressInLocation(e); this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e); }, + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ _endHighlight: function (e: PressEvent) { if (this.touchableHandleActivePressOut) { if ( diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index 0a61b9a01fb91b..f77ab0f5738fcf 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -137,6 +137,7 @@ class TouchableBounce extends React.Component { accessible={this.props.accessible !== false} accessibilityLabel={this.props.accessibilityLabel} accessibilityHint={this.props.accessibilityHint} + accessibilityLanguage={this.props.accessibilityLanguage} accessibilityRole={this.props.accessibilityRole} accessibilityState={this.props.accessibilityState} accessibilityActions={this.props.accessibilityActions} diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 1c306d8e12d5f1..d41513b189b55d 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -296,6 +296,7 @@ class TouchableHighlight extends React.Component { accessible={this.props.accessible !== false} accessibilityLabel={this.props.accessibilityLabel} accessibilityHint={this.props.accessibilityHint} + accessibilityLanguage={this.props.accessibilityLanguage} accessibilityRole={this.props.accessibilityRole} accessibilityState={accessibilityState} accessibilityValue={this.props.accessibilityValue} diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 78a6abb90b48ab..8fff2f302397f2 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -271,6 +271,7 @@ class TouchableNativeFeedback extends React.Component { ), accessible: this.props.accessible !== false, accessibilityHint: this.props.accessibilityHint, + accessibilityLanguage: this.props.accessibilityLanguage, accessibilityLabel: this.props.accessibilityLabel, accessibilityRole: this.props.accessibilityRole, accessibilityState: accessibilityState, @@ -311,11 +312,15 @@ class TouchableNativeFeedback extends React.Component { const getBackgroundProp = Platform.OS === 'android' - ? (background, useForeground) => + ? /* $FlowFixMe[missing-local-annot] The type annotation(s) required by + * Flow's LTI update could not be added via codemod */ + (background, useForeground: boolean) => useForeground && TouchableNativeFeedback.canUseNativeForeground() ? {nativeForegroundAndroid: background} : {nativeBackgroundAndroid: background} - : (background, useForeground) => null; + : /* $FlowFixMe[missing-local-annot] The type annotation(s) required by + * Flow's LTI update could not be added via codemod */ + (background, useForeground: boolean) => null; TouchableNativeFeedback.displayName = 'TouchableNativeFeedback'; diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 4ce0692c35826c..67e18c06d54c83 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -188,7 +188,6 @@ class TouchableOpacity extends React.Component { Animated.timing(this.state.anim, { toValue, duration, - // $FlowFixMe[method-unbinding] easing: Easing.inOut(Easing.quad), useNativeDriver: true, }).start(); @@ -226,6 +225,7 @@ class TouchableOpacity extends React.Component { accessible={this.props.accessible !== false} accessibilityLabel={this.props.accessibilityLabel} accessibilityHint={this.props.accessibilityHint} + accessibilityLanguage={this.props.accessibilityLanguage} accessibilityRole={this.props.accessibilityRole} accessibilityState={accessibilityState} accessibilityActions={this.props.accessibilityActions} @@ -261,7 +261,12 @@ class TouchableOpacity extends React.Component { componentDidUpdate(prevProps: Props, prevState: State) { this.state.pressability.configure(this._createPressabilityConfig()); - if (this.props.disabled !== prevProps.disabled) { + if ( + this.props.disabled !== prevProps.disabled || + (flattenStyle(prevProps.style)?.opacity !== + flattenStyle(this.props.style)?.opacity) !== + undefined + ) { this._opacityInactive(250); } } diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index db4aaa4d599f98..2b3bd4b930e14b 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,6 +33,7 @@ type Props = $ReadOnly<{| accessibilityActions?: ?$ReadOnlyArray, accessibilityElementsHidden?: ?boolean, accessibilityHint?: ?Stringish, + accessibilityLanguage?: ?Stringish, accessibilityIgnoresInvertColors?: ?boolean, accessibilityLabel?: ?Stringish, accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), @@ -72,6 +73,7 @@ const PASSTHROUGH_PROPS = [ 'accessibilityActions', 'accessibilityElementsHidden', 'accessibilityHint', + 'accessibilityLanguage', 'accessibilityIgnoresInvertColors', 'accessibilityLabel', 'accessibilityLiveRegion', diff --git a/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js b/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js index f25f4150dedf31..d1ae224b220613 100644 --- a/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js +++ b/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js b/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js index 237b1a22745cb9..dca7e508cc647a 100644 --- a/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js +++ b/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js b/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js index f38211b67aeb46..30aa9b656aa24b 100644 --- a/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js +++ b/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js b/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js index 0648d372d3883d..bbf3483ec8b033 100644 --- a/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js +++ b/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js b/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js index 2a2969905bc65d..89e2d42f2e166f 100644 --- a/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +++ b/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/UnimplementedViews/UnimplementedView.js b/Libraries/Components/UnimplementedViews/UnimplementedView.js index 4bbb41060ff32f..24a6e3a51c4e22 100644 --- a/Libraries/Components/UnimplementedViews/UnimplementedView.js +++ b/Libraries/Components/UnimplementedViews/UnimplementedView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/View/ReactNativeStyleAttributes.js b/Libraries/Components/View/ReactNativeStyleAttributes.js index 9f87352219ef2b..7736e5026db90c 100644 --- a/Libraries/Components/View/ReactNativeStyleAttributes.js +++ b/Libraries/Components/View/ReactNativeStyleAttributes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -85,14 +85,7 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = { /** * Transform */ - decomposedMatrix: true, // @deprecated - rotation: true, // @deprecated - scaleX: true, // @deprecated - scaleY: true, // @deprecated transform: {process: processTransform}, - transformMatrix: true, // @deprecated - translateX: true, // @deprecated - translateY: true, // @deprecated /** * View diff --git a/Libraries/Components/View/ReactNativeViewAttributes.js b/Libraries/Components/View/ReactNativeViewAttributes.js index da38aeef79085a..f4ea0d2c1f5219 100644 --- a/Libraries/Components/View/ReactNativeViewAttributes.js +++ b/Libraries/Components/View/ReactNativeViewAttributes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,6 +21,7 @@ const UIView = { accessibilityState: true, accessibilityValue: true, accessibilityHint: true, + accessibilityLanguage: true, importantForAccessibility: true, nativeID: true, testID: true, diff --git a/Libraries/Components/View/ReactNativeViewViewConfig.js b/Libraries/Components/View/ReactNativeViewViewConfig.js deleted file mode 100644 index 6406b6ec7f2c0e..00000000000000 --- a/Libraries/Components/View/ReactNativeViewViewConfig.js +++ /dev/null @@ -1,360 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -import type {ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; -import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid'; -import {Platform} from 'react-native'; - -const ReactNativeViewConfig: ViewConfig = { - uiViewClassName: 'RCTView', - baseModuleName: null, - Manager: 'ViewManager', - Commands: {}, - Constants: {}, - bubblingEventTypes: { - ...ReactNativeViewViewConfigAndroid.bubblingEventTypes, - topBlur: { - phasedRegistrationNames: { - bubbled: 'onBlur', - captured: 'onBlurCapture', - }, - }, - topChange: { - phasedRegistrationNames: { - bubbled: 'onChange', - captured: 'onChangeCapture', - }, - }, - topEndEditing: { - phasedRegistrationNames: { - bubbled: 'onEndEditing', - captured: 'onEndEditingCapture', - }, - }, - topFocus: { - phasedRegistrationNames: { - bubbled: 'onFocus', - captured: 'onFocusCapture', - }, - }, - topKeyPress: { - phasedRegistrationNames: { - bubbled: 'onKeyPress', - captured: 'onKeyPressCapture', - }, - }, - topPress: { - phasedRegistrationNames: { - bubbled: 'onPress', - captured: 'onPressCapture', - }, - }, - topSubmitEditing: { - phasedRegistrationNames: { - bubbled: 'onSubmitEditing', - captured: 'onSubmitEditingCapture', - }, - }, - topTouchCancel: { - phasedRegistrationNames: { - bubbled: 'onTouchCancel', - captured: 'onTouchCancelCapture', - }, - }, - topTouchEnd: { - phasedRegistrationNames: { - bubbled: 'onTouchEnd', - captured: 'onTouchEndCapture', - }, - }, - topTouchMove: { - phasedRegistrationNames: { - bubbled: 'onTouchMove', - captured: 'onTouchMoveCapture', - }, - }, - topTouchStart: { - phasedRegistrationNames: { - bubbled: 'onTouchStart', - captured: 'onTouchStartCapture', - }, - }, - }, - directEventTypes: { - ...ReactNativeViewViewConfigAndroid.directEventTypes, - topAccessibilityAction: { - registrationName: 'onAccessibilityAction', - }, - topAccessibilityEscape: { - registrationName: 'onAccessibilityEscape', - }, - topAccessibilityTap: { - registrationName: 'onAccessibilityTap', - }, - topLayout: { - registrationName: 'onLayout', - }, - topMagicTap: { - registrationName: 'onMagicTap', - }, - topPointerEnter: { - registrationName: 'pointerenter', - }, - topPointerLeave: { - registrationName: 'pointerleave', - }, - topPointerMove: { - registrationName: 'pointermove', - }, - // Events for react-native-gesture-handler (T45765076) - // Remove once this library can handle JS View Configs - onGestureHandlerEvent: { - registrationName: 'onGestureHandlerEvent', - }, - onGestureHandlerStateChange: { - registrationName: 'onGestureHandlerStateChange', - }, - }, - validAttributes: { - ...ReactNativeViewViewConfigAndroid.validAttributes, - accessibilityActions: true, - accessibilityElementsHidden: true, - accessibilityHint: true, - accessibilityIgnoresInvertColors: true, - accessibilityLabel: true, - accessibilityLiveRegion: true, - accessibilityRole: true, - accessibilityState: true, - accessibilityValue: true, - accessibilityViewIsModal: true, - accessible: true, - alignContent: true, - alignItems: true, - alignSelf: true, - aspectRatio: true, - backfaceVisibility: true, - backgroundColor: {process: require('../../StyleSheet/processColor')}, - borderBottomColor: {process: require('../../StyleSheet/processColor')}, - borderBottomEndRadius: true, - borderBottomLeftRadius: true, - borderBottomRightRadius: true, - borderBottomStartRadius: true, - borderBottomWidth: true, - borderColor: {process: require('../../StyleSheet/processColor')}, - borderEndColor: {process: require('../../StyleSheet/processColor')}, - borderEndWidth: true, - borderLeftColor: {process: require('../../StyleSheet/processColor')}, - borderLeftWidth: true, - borderRadius: true, - borderRightColor: {process: require('../../StyleSheet/processColor')}, - borderRightWidth: true, - borderStartColor: {process: require('../../StyleSheet/processColor')}, - borderStartWidth: true, - borderStyle: true, - borderTopColor: {process: require('../../StyleSheet/processColor')}, - borderTopEndRadius: true, - borderTopLeftRadius: true, - borderTopRightRadius: true, - borderTopStartRadius: true, - borderTopWidth: true, - borderWidth: true, - bottom: true, - clickable: true, - collapsable: true, - direction: true, - display: true, - elevation: true, - end: true, - flex: true, - flexBasis: true, - flexDirection: true, - flexGrow: true, - flexShrink: true, - flexWrap: true, - height: true, - hitSlop: {diff: require('../../Utilities/differ/insetsDiffer')}, - importantForAccessibility: true, - justifyContent: true, - left: true, - margin: true, - marginBottom: true, - marginEnd: true, - marginHorizontal: true, - marginLeft: true, - marginRight: true, - marginStart: true, - marginTop: true, - marginVertical: true, - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true, - nativeID: true, - needsOffscreenAlphaCompositing: true, - onAccessibilityAction: true, - onAccessibilityEscape: true, - onAccessibilityTap: true, - pointerenter: true, - pointerleave: true, - pointermove: true, - onLayout: true, - onMagicTap: true, - opacity: true, - overflow: true, - padding: true, - paddingBottom: true, - paddingEnd: true, - paddingHorizontal: true, - paddingLeft: true, - paddingRight: true, - paddingStart: true, - paddingTop: true, - paddingVertical: true, - pointerEvents: true, - position: true, - removeClippedSubviews: true, - renderToHardwareTextureAndroid: true, - right: true, - rotation: true, - scaleX: true, - scaleY: true, - shadowColor: {process: require('../../StyleSheet/processColor')}, - shadowOffset: {diff: require('../../Utilities/differ/sizesDiffer')}, - shadowOpacity: true, - shadowRadius: true, - shouldRasterizeIOS: true, - start: true, - style: { - alignContent: true, - alignItems: true, - alignSelf: true, - aspectRatio: true, - backfaceVisibility: true, - backgroundColor: {process: require('../../StyleSheet/processColor')}, - borderBottomColor: {process: require('../../StyleSheet/processColor')}, - borderBottomEndRadius: true, - borderBottomLeftRadius: true, - borderBottomRightRadius: true, - borderBottomStartRadius: true, - borderBottomWidth: true, - borderColor: {process: require('../../StyleSheet/processColor')}, - borderEndColor: {process: require('../../StyleSheet/processColor')}, - borderEndWidth: true, - borderLeftColor: {process: require('../../StyleSheet/processColor')}, - borderLeftWidth: true, - borderRadius: true, - borderRightColor: {process: require('../../StyleSheet/processColor')}, - borderRightWidth: true, - borderStartColor: {process: require('../../StyleSheet/processColor')}, - borderStartWidth: true, - borderStyle: true, - borderTopColor: {process: require('../../StyleSheet/processColor')}, - borderTopEndRadius: true, - borderTopLeftRadius: true, - borderTopRightRadius: true, - borderTopStartRadius: true, - borderTopWidth: true, - borderWidth: true, - bottom: true, - color: {process: require('../../StyleSheet/processColor')}, - decomposedMatrix: true, - direction: true, - display: true, - elevation: true, - end: true, - flex: true, - flexBasis: true, - flexDirection: true, - flexGrow: true, - flexShrink: true, - flexWrap: true, - fontFamily: true, - fontSize: true, - fontStyle: true, - fontVariant: true, - fontWeight: true, - height: true, - includeFontPadding: true, - justifyContent: true, - left: true, - letterSpacing: true, - lineHeight: true, - margin: true, - marginBottom: true, - marginEnd: true, - marginHorizontal: true, - marginLeft: true, - marginRight: true, - marginStart: true, - marginTop: true, - marginVertical: true, - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true, - opacity: true, - overflow: true, - overlayColor: {process: require('../../StyleSheet/processColor')}, - padding: true, - paddingBottom: true, - paddingEnd: true, - paddingHorizontal: true, - paddingLeft: true, - paddingRight: true, - paddingStart: true, - paddingTop: true, - paddingVertical: true, - position: true, - resizeMode: true, - right: true, - rotation: true, - scaleX: true, - scaleY: true, - shadowColor: {process: require('../../StyleSheet/processColor')}, - shadowOffset: {diff: require('../../Utilities/differ/sizesDiffer')}, - shadowOpacity: true, - shadowRadius: true, - start: true, - textAlign: true, - textAlignVertical: true, - textDecorationColor: {process: require('../../StyleSheet/processColor')}, - textDecorationLine: true, - textDecorationStyle: true, - textShadowColor: {process: require('../../StyleSheet/processColor')}, - textShadowOffset: true, - textShadowRadius: true, - textTransform: true, - tintColor: {process: require('../../StyleSheet/processColor')}, - top: true, - transform: - Platform.OS === 'ios' - ? {diff: require('../../Utilities/differ/matricesDiffer')} - : {process: require('../../StyleSheet/processTransform')}, - transformMatrix: true, - translateX: true, - translateY: true, - width: true, - writingDirection: true, - zIndex: true, - }, - testID: true, - top: true, - transform: - Platform.OS === 'ios' - ? {diff: require('../../Utilities/differ/matricesDiffer')} - : {process: require('../../StyleSheet/processTransform')}, - translateX: true, - translateY: true, - width: true, - zIndex: true, - }, -}; - -module.exports = ReactNativeViewConfig; diff --git a/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js b/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js deleted file mode 100644 index ad2542dfa2844c..00000000000000 --- a/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -const ReactNativeViewViewConfigAndroid = { - uiViewClassName: 'RCTView', - bubblingEventTypes: { - topSelect: { - phasedRegistrationNames: { - bubbled: 'onSelect', - captured: 'onSelectCapture', - }, - }, - topAssetDidLoad: { - phasedRegistrationNames: { - bubbled: 'onAssetDidLoad', - captured: 'onAssetDidLoadCapture', - }, - }, - }, - directEventTypes: { - topClick: { - registrationName: 'onClick', - }, - topContentSizeChange: { - registrationName: 'onContentSizeChange', - }, - topLoadingError: { - registrationName: 'onLoadingError', - }, - topLoadingFinish: { - registrationName: 'onLoadingFinish', - }, - topLoadingStart: { - registrationName: 'onLoadingStart', - }, - topMessage: { - registrationName: 'onMessage', - }, - topMomentumScrollBegin: { - registrationName: 'onMomentumScrollBegin', - }, - topMomentumScrollEnd: { - registrationName: 'onMomentumScrollEnd', - }, - topScroll: { - registrationName: 'onScroll', - }, - topScrollBeginDrag: { - registrationName: 'onScrollBeginDrag', - }, - topScrollEndDrag: { - registrationName: 'onScrollEndDrag', - }, - topSelectionChange: { - registrationName: 'onSelectionChange', - }, - onAssetDidLoad: { - registrationName: 'onAssetDidLoad', - }, - }, - validAttributes: { - hasTVPreferredFocus: true, - focusable: true, - nativeBackgroundAndroid: true, - nativeForegroundAndroid: true, - nextFocusDown: true, - nextFocusForward: true, - nextFocusLeft: true, - nextFocusRight: true, - nextFocusUp: true, - }, -}; - -module.exports = ReactNativeViewViewConfigAndroid; diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 5bf6f7407d40b3..0379a7ce912f97 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/View/ViewAccessibility.js b/Libraries/Components/View/ViewAccessibility.js index 66ba513789f942..51343752c55e4e 100644 --- a/Libraries/Components/View/ViewAccessibility.js +++ b/Libraries/Components/View/ViewAccessibility.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/View/ViewNativeComponent.js b/Libraries/Components/View/ViewNativeComponent.js index a38c2a0a3b6e5a..bba9f3971e6ef8 100644 --- a/Libraries/Components/View/ViewNativeComponent.js +++ b/Libraries/Components/View/ViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,19 +9,79 @@ */ import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes'; -import Platform from '../../Utilities/Platform'; +import type { + HostComponent, + PartialViewConfig, +} from '../../Renderer/shims/ReactNativeTypes'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; -import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid'; import {type ViewProps as Props} from './ViewPropTypes'; +import Platform from '../../Utilities/Platform'; + import * as React from 'react'; +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = + Platform.OS === 'android' + ? { + uiViewClassName: 'RCTView', + validAttributes: { + // ReactClippingViewManager @ReactProps + removeClippedSubviews: true, + + // ReactViewManager @ReactProps + accessible: true, + hasTVPreferredFocus: true, + nextFocusDown: true, + nextFocusForward: true, + nextFocusLeft: true, + nextFocusRight: true, + nextFocusUp: true, + + borderRadius: true, + borderTopLeftRadius: true, + borderTopRightRadius: true, + borderBottomRightRadius: true, + borderBottomLeftRadius: true, + borderTopStartRadius: true, + borderTopEndRadius: true, + borderBottomStartRadius: true, + borderBottomEndRadius: true, + + borderStyle: true, + hitSlop: true, + pointerEvents: true, + nativeBackgroundAndroid: true, + nativeForegroundAndroid: true, + needsOffscreenAlphaCompositing: true, + + borderWidth: true, + borderLeftWidth: true, + borderRightWidth: true, + borderTopWidth: true, + borderBottomWidth: true, + borderStartWidth: true, + borderEndWidth: true, + + borderColor: {process: require('../../StyleSheet/processColor')}, + borderLeftColor: {process: require('../../StyleSheet/processColor')}, + borderRightColor: {process: require('../../StyleSheet/processColor')}, + borderTopColor: {process: require('../../StyleSheet/processColor')}, + borderBottomColor: { + process: require('../../StyleSheet/processColor'), + }, + borderStartColor: {process: require('../../StyleSheet/processColor')}, + borderEndColor: {process: require('../../StyleSheet/processColor')}, + + focusable: true, + overflow: true, + backfaceVisibility: true, + }, + } + : { + uiViewClassName: 'RCTView', + }; + const ViewNativeComponent: HostComponent = - NativeComponentRegistry.get('RCTView', () => - Platform.OS === 'android' - ? ReactNativeViewViewConfigAndroid - : {uiViewClassName: 'RCTView'}, - ); + NativeComponentRegistry.get('RCTView', () => __INTERNAL_VIEW_CONFIG); interface NativeCommands { +hotspotUpdate: ( diff --git a/Libraries/Components/View/ViewPropTypes.js b/Libraries/Components/View/ViewPropTypes.js index 497d94cff18b5a..37821e934bb66c 100644 --- a/Libraries/Components/View/ViewPropTypes.js +++ b/Libraries/Components/View/ViewPropTypes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,11 +14,12 @@ import type { BlurEvent, FocusEvent, MouseEvent, + PointerEvent, PressEvent, Layout, LayoutEvent, } from '../../Types/CoreEventTypes'; -import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; +import type {EdgeInsetsOrSizeProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {Node} from 'react'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type { @@ -32,9 +33,11 @@ import type { export type ViewLayout = Layout; export type ViewLayoutEvent = LayoutEvent; -type BubblingEventProps = $ReadOnly<{| +type FocusEventProps = $ReadOnly<{| onBlur?: ?(event: BlurEvent) => mixed, + onBlurCapture?: ?(event: BlurEvent) => mixed, onFocus?: ?(event: FocusEvent) => mixed, + onFocusCapture?: ?(event: FocusEvent) => mixed, |}>; type DirectEventProps = $ReadOnly<{| @@ -49,7 +52,7 @@ type DirectEventProps = $ReadOnly<{| * When `accessible` is true, the system will try to invoke this function * when the user performs accessibility tap gesture. * - * See https://reactnative.dev/docs/view.html#onaccessibilitytap + * See https://reactnative.dev/docs/view#onaccessibilitytap */ onAccessibilityTap?: ?() => mixed, @@ -62,7 +65,7 @@ type DirectEventProps = $ReadOnly<{| * the new layout may not yet be reflected on the screen at the time the * event is received, especially if a layout animation is in progress. * - * See https://reactnative.dev/docs/view.html#onlayout + * See https://reactnative.dev/docs/view#onlayout */ onLayout?: ?(event: LayoutEvent) => mixed, @@ -70,7 +73,7 @@ type DirectEventProps = $ReadOnly<{| * When `accessible` is `true`, the system will invoke this function when the * user performs the magic tap gesture. * - * See https://reactnative.dev/docs/view.html#onmagictap + * See https://reactnative.dev/docs/view#onmagictap */ onMagicTap?: ?() => mixed, @@ -78,14 +81,30 @@ type DirectEventProps = $ReadOnly<{| * When `accessible` is `true`, the system will invoke this function when the * user performs the escape gesture. * - * See https://reactnative.dev/docs/view.html#onaccessibilityescape + * See https://reactnative.dev/docs/view#onaccessibilityescape */ onAccessibilityEscape?: ?() => mixed, |}>; type MouseEventProps = $ReadOnly<{| - onMouseEnter?: (event: MouseEvent) => void, - onMouseLeave?: (event: MouseEvent) => void, + onMouseEnter?: ?(event: MouseEvent) => void, + onMouseLeave?: ?(event: MouseEvent) => void, +|}>; + +// Experimental/Work in Progress Pointer Event Callbacks (not yet ready for use) +type PointerEventProps = $ReadOnly<{| + onPointerEnter?: ?(event: PointerEvent) => void, + onPointerEnterCapture?: ?(event: PointerEvent) => void, + onPointerLeave?: ?(event: PointerEvent) => void, + onPointerLeaveCapture?: ?(event: PointerEvent) => void, + onPointerMove?: ?(event: PointerEvent) => void, + onPointerMoveCapture?: ?(event: PointerEvent) => void, + onPointerCancel?: ?(e: PointerEvent) => void, + onPointerCancelCapture?: ?(e: PointerEvent) => void, + onPointerDown?: ?(e: PointerEvent) => void, + onPointerDownCapture?: ?(e: PointerEvent) => void, + onPointerUp?: ?(e: PointerEvent) => void, + onPointerUpCapture?: ?(e: PointerEvent) => void, |}>; type TouchEventProps = $ReadOnly<{| @@ -112,7 +131,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onMoveShouldSetResponder: (event) => [true | false]`, where * `event` is a synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onmoveshouldsetresponder + * See https://reactnative.dev/docs/view#onmoveshouldsetresponder */ onMoveShouldSetResponder?: ?(e: PressEvent) => boolean, @@ -123,7 +142,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`, * where `event` is a synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onMoveShouldsetrespondercapture + * See https://reactnative.dev/docs/view#onMoveShouldsetrespondercapture */ onMoveShouldSetResponderCapture?: ?(e: PressEvent) => boolean, @@ -137,7 +156,7 @@ type GestureResponderEventProps = $ReadOnly<{| * PanResponder includes a note `// TODO: t7467124 investigate if this can be removed` that * should help fixing this return type. * - * See https://reactnative.dev/docs/view.html#onrespondergrant + * See https://reactnative.dev/docs/view#onrespondergrant */ onResponderGrant?: ?(e: PressEvent) => void | boolean, @@ -147,7 +166,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onResponderMove: (event) => {}`, where `event` is a synthetic * touch event as described above. * - * See https://reactnative.dev/docs/view.html#onrespondermove + * See https://reactnative.dev/docs/view#onrespondermove */ onResponderMove?: ?(e: PressEvent) => void, @@ -158,7 +177,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onResponderReject: (event) => {}`, where `event` is a * synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onresponderreject + * See https://reactnative.dev/docs/view#onresponderreject */ onResponderReject?: ?(e: PressEvent) => void, @@ -168,7 +187,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onResponderRelease: (event) => {}`, where `event` is a * synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onresponderrelease + * See https://reactnative.dev/docs/view#onresponderrelease */ onResponderRelease?: ?(e: PressEvent) => void, @@ -184,7 +203,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onResponderTerminate: (event) => {}`, where `event` is a * synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onresponderterminate + * See https://reactnative.dev/docs/view#onresponderterminate */ onResponderTerminate?: ?(e: PressEvent) => void, @@ -195,7 +214,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onResponderTerminationRequest: (event) => {}`, where `event` * is a synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onresponderterminationrequest + * See https://reactnative.dev/docs/view#onresponderterminationrequest */ onResponderTerminationRequest?: ?(e: PressEvent) => boolean, @@ -205,7 +224,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onStartShouldSetResponder: (event) => [true | false]`, where * `event` is a synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onstartshouldsetresponder + * See https://reactnative.dev/docs/view#onstartshouldsetresponder */ onStartShouldSetResponder?: ?(e: PressEvent) => boolean, @@ -216,7 +235,7 @@ type GestureResponderEventProps = $ReadOnly<{| * `View.props.onStartShouldSetResponderCapture: (event) => [true | false]`, * where `event` is a synthetic touch event as described above. * - * See https://reactnative.dev/docs/view.html#onstartshouldsetrespondercapture + * See https://reactnative.dev/docs/view#onstartshouldsetrespondercapture */ onStartShouldSetResponderCapture?: ?(e: PressEvent) => boolean, |}>; @@ -245,7 +264,7 @@ type AndroidViewProps = $ReadOnly<{| * * @platform android * - * See https://reactnative.dev/docs/view.html#rendertohardwaretextureandroid + * See https://reactnative.dev/docs/view#rendertohardwaretextureandroid */ renderToHardwareTextureAndroid?: ?boolean, @@ -255,7 +274,7 @@ type AndroidViewProps = $ReadOnly<{| * * @platform android * - * See https://reactnative.dev/docs/view.html#needsoffscreenalphacompositing + * See https://reactnative.dev/docs/view#needsoffscreenalphacompositing */ needsOffscreenAlphaCompositing?: ?boolean, @@ -265,7 +284,7 @@ type AndroidViewProps = $ReadOnly<{| * * @platform android * - * See https://reactnative.dev/docs/view.html#accessibilityliveregion + * See https://reactnative.dev/docs/view#accessibilityliveregion */ accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), @@ -276,7 +295,7 @@ type AndroidViewProps = $ReadOnly<{| * * @platform android * - * See https://reactnative.dev/docs/view.html#importantforaccessibility + * See https://reactnative.dev/docs/view#importantforaccessibility */ importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), @@ -352,7 +371,7 @@ type IOSViewProps = $ReadOnly<{| * * @platform ios * - * See https://reactnative.dev/docs/view.html#accessibilityviewismodal + * See https://reactnative.dev/docs/view#accessibilityviewismodal */ accessibilityViewIsModal?: ?boolean, @@ -362,7 +381,7 @@ type IOSViewProps = $ReadOnly<{| * * @platform ios * - * See https://reactnative.dev/docs/view.html#accessibilityElementsHidden + * See https://reactnative.dev/docs/view#accessibilityElementsHidden */ accessibilityElementsHidden?: ?boolean, @@ -371,16 +390,17 @@ type IOSViewProps = $ReadOnly<{| * * @platform ios * - * See https://reactnative.dev/docs/view.html#shouldrasterizeios + * See https://reactnative.dev/docs/view#shouldrasterizeios */ shouldRasterizeIOS?: ?boolean, |}>; export type ViewProps = $ReadOnly<{| - ...BubblingEventProps, + ...FocusEventProps, ...DirectEventProps, ...GestureResponderEventProps, ...MouseEventProps, + ...PointerEventProps, ...TouchEventProps, ...AndroidViewProps, ...IOSViewProps, @@ -392,7 +412,7 @@ export type ViewProps = $ReadOnly<{| * When `true`, indicates that the view is an accessibility element. * By default, all the touchable elements are accessible. * - * See https://reactnative.dev/docs/view.html#accessible + * See https://reactnative.dev/docs/view#accessible */ accessible?: ?boolean, @@ -401,7 +421,7 @@ export type ViewProps = $ReadOnly<{| * with the element. By default, the label is constructed by traversing all * the children and accumulating all the `Text` nodes separated by space. * - * See https://reactnative.dev/docs/view.html#accessibilitylabel + * See https://reactnative.dev/docs/view#accessibilitylabel */ accessibilityLabel?: ?Stringish, @@ -411,10 +431,19 @@ export type ViewProps = $ReadOnly<{| * accessibility label. * * - * See https://reactnative.dev/docs/view.html#accessibilityHint + * See https://reactnative.dev/docs/view#accessibilityHint */ accessibilityHint?: ?Stringish, + /** + * Indicates to the accessibility services that the UI component is in + * a specific language. The provided string should be formatted following + * the BCP 47 specification (https://www.rfc-editor.org/info/bcp47). + * + * @platform ios + */ + accessibilityLanguage?: ?Stringish, + /** * Indicates to accessibility services to treat UI component like a specific role. */ @@ -432,6 +461,13 @@ export type ViewProps = $ReadOnly<{| */ accessibilityActions?: ?$ReadOnlyArray, + /** + * Specifies the nativeID of the associated label text. When the assistive technology focuses on the component with this props, the text is read aloud. + * + * @platform android + */ + accessibilityLabelledBy?: ?string | ?Array, + /** * Views that are only used to layout their children or otherwise don't draw * anything may be automatically removed from the native hierarchy as an @@ -441,7 +477,7 @@ export type ViewProps = $ReadOnly<{| * @platform android * In Fabric, this prop is used in ios as well. * - * See https://reactnative.dev/docs/view.html#collapsable + * See https://reactnative.dev/docs/view#collapsable */ collapsable?: ?boolean, @@ -450,7 +486,7 @@ export type ViewProps = $ReadOnly<{| * * > This disables the 'layout-only view removal' optimization for this view! * - * See https://reactnative.dev/docs/view.html#testid + * See https://reactnative.dev/docs/view#testid */ testID?: ?string, @@ -459,7 +495,7 @@ export type ViewProps = $ReadOnly<{| * * > This disables the 'layout-only view removal' optimization for this view! * - * See https://reactnative.dev/docs/view.html#nativeid + * See https://reactnative.dev/docs/view#nativeid */ nativeID?: ?string, @@ -472,14 +508,14 @@ export type ViewProps = $ReadOnly<{| * > of sibling views always takes precedence if a touch hits two overlapping * > views. * - * See https://reactnative.dev/docs/view.html#hitslop + * See https://reactnative.dev/docs/view#hitslop */ - hitSlop?: ?EdgeInsetsProp, + hitSlop?: ?EdgeInsetsOrSizeProp, /** * Controls whether the `View` can be the target of touch events. * - * See https://reactnative.dev/docs/view.html#pointerevents + * See https://reactnative.dev/docs/view#pointerevents */ pointerEvents?: ?('auto' | 'box-none' | 'box-only' | 'none'), @@ -491,7 +527,7 @@ export type ViewProps = $ReadOnly<{| * subviews must also have `overflow: hidden`, as should the containing view * (or one of its superviews). * - * See https://reactnative.dev/docs/view.html#removeclippedsubviews + * See https://reactnative.dev/docs/view#removeclippedsubviews */ removeClippedSubviews?: ?boolean, |}>; diff --git a/Libraries/Components/__tests__/Button-test.js b/Libraries/Components/__tests__/Button-test.js index f81f9bc63d229e..d2f976371aa9d8 100644 --- a/Libraries/Components/__tests__/Button-test.js +++ b/Libraries/Components/__tests__/Button-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/__tests__/Slider-test.js b/Libraries/Components/__tests__/Slider-test.js index 5e3a9f47f86b77..876627fa038d35 100644 --- a/Libraries/Components/__tests__/Slider-test.js +++ b/Libraries/Components/__tests__/Slider-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Components/__tests__/__snapshots__/Slider-test.js.snap b/Libraries/Components/__tests__/__snapshots__/Slider-test.js.snap index 63c3e3507a55c7..244045f0057b20 100644 --- a/Libraries/Components/__tests__/__snapshots__/Slider-test.js.snap +++ b/Libraries/Components/__tests__/__snapshots__/Slider-test.js.snap @@ -6,7 +6,6 @@ exports[` should render as expected 1`] = ` enabled={true} maximumValue={1} minimumValue={0} - onChange={null} onResponderTerminationRequest={[Function]} onSlidingComplete={null} onStartShouldSetResponder={[Function]} @@ -27,7 +26,6 @@ exports[` should set disabled as false 1`] = ` enabled={true} maximumValue={1} minimumValue={0} - onChange={null} onResponderTerminationRequest={[Function]} onSlidingComplete={null} onStartShouldSetResponder={[Function]} @@ -53,7 +51,6 @@ exports[` should set disabled as false 2`] = ` enabled={true} maximumValue={1} minimumValue={0} - onChange={null} onResponderTerminationRequest={[Function]} onSlidingComplete={null} onStartShouldSetResponder={[Function]} @@ -79,7 +76,6 @@ exports[` should set disabled as true 1`] = ` enabled={false} maximumValue={1} minimumValue={0} - onChange={null} onResponderTerminationRequest={[Function]} onSlidingComplete={null} onStartShouldSetResponder={[Function]} @@ -105,7 +101,6 @@ exports[` should set disabled as true 2`] = ` enabled={false} maximumValue={1} minimumValue={0} - onChange={null} onResponderTerminationRequest={[Function]} onSlidingComplete={null} onStartShouldSetResponder={[Function]} diff --git a/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js b/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js index ce7117bd268c8c..020af845708bd0 100644 --- a/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js +++ b/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js b/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js index 8b24b97294659a..f821fc1c91ca99 100644 --- a/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js +++ b/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/getDevServer.js b/Libraries/Core/Devtools/getDevServer.js index d820a9ee5dcad8..a4d886be74c7ab 100644 --- a/Libraries/Core/Devtools/getDevServer.js +++ b/Libraries/Core/Devtools/getDevServer.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/openFileInEditor.js b/Libraries/Core/Devtools/openFileInEditor.js index 66dca4721b9c52..2f4e8b127d279b 100644 --- a/Libraries/Core/Devtools/openFileInEditor.js +++ b/Libraries/Core/Devtools/openFileInEditor.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/openURLInBrowser.js b/Libraries/Core/Devtools/openURLInBrowser.js index d4b00663aaf051..986fa5d1f3f4fb 100644 --- a/Libraries/Core/Devtools/openURLInBrowser.js +++ b/Libraries/Core/Devtools/openURLInBrowser.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/parseErrorStack.js b/Libraries/Core/Devtools/parseErrorStack.js index 185ddcb7e75332..e0039c85d6f148 100644 --- a/Libraries/Core/Devtools/parseErrorStack.js +++ b/Libraries/Core/Devtools/parseErrorStack.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Devtools/parseHermesStack.js b/Libraries/Core/Devtools/parseHermesStack.js index e9cdfd091cb2f8..6670cfde25632d 100644 --- a/Libraries/Core/Devtools/parseHermesStack.js +++ b/Libraries/Core/Devtools/parseHermesStack.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -100,7 +100,7 @@ function parseLine(line: string): ?HermesStackEntry { module.exports = function parseHermesStack(stack: string): HermesParsedStack { const lines = stack.split(/\n/); - let entries = []; + let entries: Array = []; let lastMessageLine = -1; for (let i = 0; i < lines.length; ++i) { const line = lines[i]; diff --git a/Libraries/Core/Devtools/symbolicateStackTrace.js b/Libraries/Core/Devtools/symbolicateStackTrace.js index cfb266c7339cdd..32ad1c7636fe9d 100644 --- a/Libraries/Core/Devtools/symbolicateStackTrace.js +++ b/Libraries/Core/Devtools/symbolicateStackTrace.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index 4c17ddb4db1a60..9d9e46098cbb54 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -1,11 +1,11 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. * * @format - * @flow strict-local + * @flow strict */ 'use strict'; @@ -144,6 +144,8 @@ function handleException(e: mixed, isFatal: boolean) { } } +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ function reactConsoleErrorHandler(...args) { // bubble up to any original handlers console._errorOriginal(...args); diff --git a/Libraries/Core/ExtendedError.js b/Libraries/Core/ExtendedError.js index e6b9a6510317ad..ced640c5046ab0 100644 --- a/Libraries/Core/ExtendedError.js +++ b/Libraries/Core/ExtendedError.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/InitializeCore.js b/Libraries/Core/InitializeCore.js index e788cfc286abcc..ee7b99f743182d 100644 --- a/Libraries/Core/InitializeCore.js +++ b/Libraries/Core/InitializeCore.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/NativeExceptionsManager.js b/Libraries/Core/NativeExceptionsManager.js index b79e331917ea3a..566428ab2c23cd 100644 --- a/Libraries/Core/NativeExceptionsManager.js +++ b/Libraries/Core/NativeExceptionsManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/RawEventEmitter.js b/Libraries/Core/RawEventEmitter.js new file mode 100644 index 00000000000000..cd330469cd745f --- /dev/null +++ b/Libraries/Core/RawEventEmitter.js @@ -0,0 +1,38 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import EventEmitter from '../vendor/emitter/EventEmitter'; +import type {IEventEmitter} from '../vendor/emitter/EventEmitter'; + +export type RawEventEmitterEvent = $ReadOnly<{| + eventName: string, + // We expect, but do not/cannot require, that nativeEvent is an object + // with the properties: key, elementType (string), type (string), tag (numeric), + // and a stateNode of the native element/Fiber the event was emitted to. + nativeEvent: {[string]: mixed}, +|}>; + +type RawEventDefinitions = { + [eventChannel: string]: [RawEventEmitterEvent], +}; + +const RawEventEmitter: IEventEmitter = + new EventEmitter(); + +// See the React renderer / react repo for how this is used. +// Raw events are emitted here when they are received in JS +// and before any event Plugins process them or before components +// have a chance to respond to them. This allows you to implement +// app-specific perf monitoring, which is unimplemented by default, +// making this entire RawEventEmitter do nothing by default until +// *you* add listeners for your own app. +// Besides perf monitoring and maybe debugging, this RawEventEmitter +// should not be used. +export default RawEventEmitter; diff --git a/Libraries/Core/ReactFiberErrorDialog.js b/Libraries/Core/ReactFiberErrorDialog.js index 28ce55d57565d5..cb1132b1f88ff4 100644 --- a/Libraries/Core/ReactFiberErrorDialog.js +++ b/Libraries/Core/ReactFiberErrorDialog.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/ReactNativeVersion.js b/Libraries/Core/ReactNativeVersion.js index 67ca7cd62bcfca..eefc716eaa9b51 100644 --- a/Libraries/Core/ReactNativeVersion.js +++ b/Libraries/Core/ReactNativeVersion.js @@ -1,11 +1,11 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. * * @format - * @generated by scripts/bump-oss-version.js + * @generated by scripts/set-rn-version.js * @flow strict */ diff --git a/Libraries/Core/ReactNativeVersionCheck.js b/Libraries/Core/ReactNativeVersionCheck.js index 41ea4a16723f8c..6b4c0973e5719b 100644 --- a/Libraries/Core/ReactNativeVersionCheck.js +++ b/Libraries/Core/ReactNativeVersionCheck.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -41,6 +41,7 @@ exports.checkVersions = function checkVersions(): void { function _formatVersion( version: | {major: number, minor: number, patch: number, prerelease: ?number} + | {major: number, minor: number, patch: number, prerelease: ?string} | $TEMPORARY$object<{ major: number, minor: number, diff --git a/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js b/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js index e90abdf3aead8b..32efa714cc6055 100644 --- a/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +++ b/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index 9522d52077e3a2..2ef47d88c0a6be 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -42,7 +42,7 @@ let requestIdleCallbacks: Array = []; const requestIdleCallbackTimeouts: {[number]: number, ...} = {}; let GUID = 1; -let errors: ?Array = null; +const errors: Array = []; let hasEmittedTimeDriftWarning = false; @@ -130,11 +130,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) { } } catch (e) { // Don't rethrow so that we can run all timers. - if (!errors) { - errors = [e]; - } else { - errors.push(e); - } + errors.push(e); } if (__DEV__) { @@ -278,7 +274,7 @@ const JSTimers = { const timeout = options && options.timeout; const id = _allocateCallback( timeout != null - ? deadline => { + ? (deadline: any) => { const timeoutId = requestIdleCallbackTimeouts[id]; if (timeoutId) { JSTimers.clearTimeout(timeoutId); @@ -356,28 +352,25 @@ const JSTimers = { 'Cannot call `callTimers` with an empty list of IDs.', ); - errors = (null: ?Array); + errors.length = 0; for (let i = 0; i < timersToCall.length; i++) { _callTimer(timersToCall[i], 0); } - if (errors) { - // $FlowFixMe[incompatible-use] - const errorCount = errors.length; + const errorCount = errors.length; + if (errorCount > 0) { if (errorCount > 1) { // Throw all the other errors in a setTimeout, which will throw each // error one at a time for (let ii = 1; ii < errorCount; ii++) { JSTimers.setTimeout( - (error => { + ((error: Error) => { throw error; - // $FlowFixMe[incompatible-use] }).bind(null, errors[ii]), 0, ); } } - // $FlowFixMe[incompatible-use] throw errors[0]; } }, @@ -390,7 +383,7 @@ const JSTimers = { return; } - errors = (null: ?Array); + errors.length = 0; if (requestIdleCallbacks.length > 0) { const passIdleCallbacks = requestIdleCallbacks; requestIdleCallbacks = []; @@ -404,13 +397,11 @@ const JSTimers = { setSendIdleEvents(false); } - if (errors) { - errors.forEach(error => - JSTimers.setTimeout(() => { - throw error; - }, 0), - ); - } + errors.forEach(error => + JSTimers.setTimeout(() => { + throw error; + }, 0), + ); }, /** @@ -418,15 +409,13 @@ const JSTimers = { * before we hand control back to native. */ callReactNativeMicrotasks() { - errors = (null: ?Array); + errors.length = 0; while (_callReactNativeMicrotasksPass()) {} - if (errors) { - errors.forEach(error => - JSTimers.setTimeout(() => { - throw error; - }, 0), - ); - } + errors.forEach(error => + JSTimers.setTimeout(() => { + throw error; + }, 0), + ); }, /** diff --git a/Libraries/Core/Timers/NativeTiming.js b/Libraries/Core/Timers/NativeTiming.js index cc487a52a3181b..fa9b14d6f3387a 100644 --- a/Libraries/Core/Timers/NativeTiming.js +++ b/Libraries/Core/Timers/NativeTiming.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Timers/__tests__/JSTimers-test.js b/Libraries/Core/Timers/__tests__/JSTimers-test.js index d5f2dabf8f90f7..cd33eea7195974 100644 --- a/Libraries/Core/Timers/__tests__/JSTimers-test.js +++ b/Libraries/Core/Timers/__tests__/JSTimers-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Timers/immediateShim.js b/Libraries/Core/Timers/immediateShim.js index 6eef9f58f1d843..43915d6df16bd1 100644 --- a/Libraries/Core/Timers/immediateShim.js +++ b/Libraries/Core/Timers/immediateShim.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/Timers/queueMicrotask.js b/Libraries/Core/Timers/queueMicrotask.js index a131696dcf64af..7c33d9f30036b9 100644 --- a/Libraries/Core/Timers/queueMicrotask.js +++ b/Libraries/Core/Timers/queueMicrotask.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/__mocks__/ErrorUtils.js b/Libraries/Core/__mocks__/ErrorUtils.js index 8505e23dc562fc..6fd3ce67b408ec 100644 --- a/Libraries/Core/__mocks__/ErrorUtils.js +++ b/Libraries/Core/__mocks__/ErrorUtils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/__tests__/ExceptionsManager-test.js b/Libraries/Core/__tests__/ExceptionsManager-test.js index d85927d1231498..11047221e4bd04 100644 --- a/Libraries/Core/__tests__/ExceptionsManager-test.js +++ b/Libraries/Core/__tests__/ExceptionsManager-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js b/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js index dbb5920a7a2826..fde28ee223cb9d 100644 --- a/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js +++ b/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/checkNativeVersion.js b/Libraries/Core/checkNativeVersion.js index b70a69bcba834b..789dd15015e969 100644 --- a/Libraries/Core/checkNativeVersion.js +++ b/Libraries/Core/checkNativeVersion.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/polyfillPromise.js b/Libraries/Core/polyfillPromise.js index f83fea90248b9d..857ea8bdb50cba 100644 --- a/Libraries/Core/polyfillPromise.js +++ b/Libraries/Core/polyfillPromise.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpAlert.js b/Libraries/Core/setUpAlert.js index 7d37fef72bb3ba..85bf358c5bc48f 100644 --- a/Libraries/Core/setUpAlert.js +++ b/Libraries/Core/setUpAlert.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpBatchedBridge.js b/Libraries/Core/setUpBatchedBridge.js index b6d1ad38462198..17ba06eb818b92 100644 --- a/Libraries/Core/setUpBatchedBridge.js +++ b/Libraries/Core/setUpBatchedBridge.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,12 +27,16 @@ if (global.RN$Bridgeless === true && global.RN$registerCallableModule) { | $TEMPORARY$string<'RCTNativeAppEventEmitter'> | $TEMPORARY$string<'SamplingProfiler'> | $TEMPORARY$string<'Systrace'>, + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by + * Flow's LTI update could not be added via codemod */ factory, ) => BatchedBridge.registerLazyCallableModule(moduleName, factory); } registerModule('Systrace', () => require('../Performance/Systrace')); -registerModule('JSTimers', () => require('./Timers/JSTimers')); +if (!(global.RN$Bridgeless === true)) { + registerModule('JSTimers', () => require('./Timers/JSTimers')); +} registerModule('HeapCapture', () => require('../HeapCapture/HeapCapture')); registerModule('SamplingProfiler', () => require('../Performance/SamplingProfiler'), diff --git a/Libraries/Core/setUpDeveloperTools.js b/Libraries/Core/setUpDeveloperTools.js index 4c4a6a6cb81b22..9d1a342ada662d 100644 --- a/Libraries/Core/setUpDeveloperTools.js +++ b/Libraries/Core/setUpDeveloperTools.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpErrorHandling.js b/Libraries/Core/setUpErrorHandling.js index 70620c8a91f8a4..32846d42f83506 100644 --- a/Libraries/Core/setUpErrorHandling.js +++ b/Libraries/Core/setUpErrorHandling.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpGlobals.js b/Libraries/Core/setUpGlobals.js index a571ba52b12016..4d740807dd156d 100644 --- a/Libraries/Core/setUpGlobals.js +++ b/Libraries/Core/setUpGlobals.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpNavigator.js b/Libraries/Core/setUpNavigator.js index 48cdd45cb1d9e1..1dbe429aaea2a8 100644 --- a/Libraries/Core/setUpNavigator.js +++ b/Libraries/Core/setUpNavigator.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpPerformance.js b/Libraries/Core/setUpPerformance.js index c253b76f43086e..6d59a8657d6ee8 100644 --- a/Libraries/Core/setUpPerformance.js +++ b/Libraries/Core/setUpPerformance.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,7 +11,7 @@ 'use strict'; if (!global.performance) { - global.performance = {}; + global.performance = ({}: {now?: () => number}); } /** diff --git a/Libraries/Core/setUpReactDevTools.js b/Libraries/Core/setUpReactDevTools.js index 099f12242bc56e..46955da62035f5 100644 --- a/Libraries/Core/setUpReactDevTools.js +++ b/Libraries/Core/setUpReactDevTools.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -58,12 +58,13 @@ if (__DEV__) { isWebSocketOpen = true; }); - const viewConfig = require('../Components/View/ReactNativeViewViewConfig'); + const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes'); + reactDevTools.connectToDevTools({ isAppActive, resolveRNStyle: require('../StyleSheet/flattenStyle'), nativeStyleEditorValidAttributes: Object.keys( - viewConfig.validAttributes.style, + ReactNativeStyleAttributes, ), websocket: ws, }); diff --git a/Libraries/Core/setUpReactRefresh.js b/Libraries/Core/setUpReactRefresh.js index ccc67ca22398b5..80ecfa16e04333 100644 --- a/Libraries/Core/setUpReactRefresh.js +++ b/Libraries/Core/setUpReactRefresh.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpRegeneratorRuntime.js b/Libraries/Core/setUpRegeneratorRuntime.js index 5cac97ec57968e..d5a7dda07b5b29 100644 --- a/Libraries/Core/setUpRegeneratorRuntime.js +++ b/Libraries/Core/setUpRegeneratorRuntime.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpSegmentFetcher.js b/Libraries/Core/setUpSegmentFetcher.js index 49ae1c6f33b031..05ec6c1f4e8ff3 100644 --- a/Libraries/Core/setUpSegmentFetcher.js +++ b/Libraries/Core/setUpSegmentFetcher.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpSystrace.js b/Libraries/Core/setUpSystrace.js index 610324b440ea6f..17a2d7bb2eb85e 100644 --- a/Libraries/Core/setUpSystrace.js +++ b/Libraries/Core/setUpSystrace.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpTimers.js b/Libraries/Core/setUpTimers.js index 7efe8982e19ba5..901de90f750e4a 100644 --- a/Libraries/Core/setUpTimers.js +++ b/Libraries/Core/setUpTimers.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Core/setUpXHR.js b/Libraries/Core/setUpXHR.js index 413fcd7e1f5385..a31f22dcb84eda 100644 --- a/Libraries/Core/setUpXHR.js +++ b/Libraries/Core/setUpXHR.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js deleted file mode 100644 index 7265fa60aee3c7..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -'use strict'; - -const normalizeColor = require('../StyleSheet/normalizeColor'); - -const colorPropType = function ( - isRequired, - props, - propName, - componentName, - location, - propFullName, -) { - const color = props[propName]; - if (color === undefined || color === null) { - if (isRequired) { - return new Error( - 'Required ' + - location + - ' `' + - (propFullName || propName) + - '` was not specified in `' + - componentName + - '`.', - ); - } - return; - } - - if (typeof color === 'number') { - // Developers should not use a number, but we are using the prop type - // both for user provided colors and for transformed ones. This isn't ideal - // and should be fixed but will do for now... - return; - } - - if (normalizeColor(color) === null) { - return new Error( - 'Invalid ' + - location + - ' `' + - (propFullName || propName) + - '` supplied to `' + - componentName + - '`: ' + - color + - '\n' + - `Valid color formats are - - '#f0f' (#rgb) - - '#f0fc' (#rgba) - - '#ff00ff' (#rrggbb) - - '#ff00ff00' (#rrggbbaa) - - 'rgb(255, 255, 255)' - - 'rgba(255, 255, 255, 1.0)' - - 'hsl(360, 100%, 100%)' - - 'hsla(360, 100%, 100%, 1.0)' - - 'transparent' - - 'red' - - 0xff00ff00 (0xrrggbbaa) -`, - ); - } -}; - -const ColorPropType = colorPropType.bind(null, false /* isRequired */); -ColorPropType.isRequired = colorPropType.bind(null, true /* isRequired */); - -module.exports = ColorPropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js deleted file mode 100644 index 6cf238d42e0d4e..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict - */ - -'use strict'; - -const PropTypes = require('prop-types'); - -const DeprecatedEdgeInsetsPropType: React$PropType$Primitive<{ - bottom?: number, - left?: number, - right?: number, - top?: number, - ... -}> = PropTypes.shape({ - top: PropTypes.number, - left: PropTypes.number, - bottom: PropTypes.number, - right: PropTypes.number, -}); - -module.exports = DeprecatedEdgeInsetsPropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.android.js b/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.android.js deleted file mode 100644 index 7df9fbf644cdba..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.android.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedImageStylePropTypes = require('./DeprecatedImageStylePropTypes'); -const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); -const DeprecatedViewPropTypes = require('./DeprecatedViewPropTypes'); -const PropTypes = require('prop-types'); - -const DeprecatedImagePropType = { - ...DeprecatedViewPropTypes, - style: (DeprecatedStyleSheetPropType( - DeprecatedImageStylePropTypes, - ): ReactPropsCheckType), - /** - * See https://reactnative.dev/docs/image.html#source - */ - source: (PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - headers: PropTypes.objectOf(PropTypes.string), - }), - // Opaque type returned by require('./image.jpg') - PropTypes.number, - // Multiple sources - PropTypes.arrayOf( - PropTypes.shape({ - uri: PropTypes.string, - width: PropTypes.number, - height: PropTypes.number, - headers: PropTypes.objectOf(PropTypes.string), - }), - ), - ]): React$PropType$Primitive< - | { - headers?: {[string]: string, ...}, - uri?: string, - ... - } - | number - | Array<{ - headers?: {[string]: string, ...}, - height?: number, - uri?: string, - width?: number, - ... - }>, - >), - /** - * blurRadius: the blur radius of the blur filter added to the image - * - * See https://reactnative.dev/docs/image.html#blurradius - */ - blurRadius: PropTypes.number, - /** - * See https://reactnative.dev/docs/image.html#defaultsource - */ - defaultSource: PropTypes.number, - /** - * See https://reactnative.dev/docs/image.html#loadingindicatorsource - */ - loadingIndicatorSource: (PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - }), - // Opaque type returned by require('./image.jpg') - PropTypes.number, - ]): React$PropType$Primitive<{uri?: string, ...} | number>), - progressiveRenderingEnabled: PropTypes.bool, - fadeDuration: PropTypes.number, - /** - * Analytics Tag used by this Image - */ - internal_analyticTag: PropTypes.string, - /** - * Invoked on load start - */ - onLoadStart: PropTypes.func, - /** - * Invoked on load error - */ - onError: PropTypes.func, - /** - * Invoked when load completes successfully - */ - onLoad: PropTypes.func, - /** - * Invoked when load either succeeds or fails - */ - onLoadEnd: PropTypes.func, - /** - * Used to locate this view in end-to-end tests. - */ - testID: PropTypes.string, - /** - * 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`. - * - * See https://reactnative.dev/docs/image.html#resizemethod - */ - resizeMethod: (PropTypes.oneOf([ - 'auto', - 'resize', - 'scale', - ]): React$PropType$Primitive<'auto' | 'resize' | 'scale'>), - /** - * Determines how to resize the image when the frame doesn't match the raw - * image dimensions. - * - * See https://reactnative.dev/docs/image.html#resizemode - */ - resizeMode: (PropTypes.oneOf([ - 'cover', - 'contain', - 'stretch', - 'repeat', - 'center', - ]): React$PropType$Primitive< - 'cover' | 'contain' | 'stretch' | 'repeat' | 'center', - >), -}; - -module.exports = DeprecatedImagePropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.ios.js b/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.ios.js deleted file mode 100644 index e01cc42fb2698e..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.ios.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedEdgeInsetsPropType = require('./DeprecatedEdgeInsetsPropType'); -const DeprecatedImageSourcePropType = require('./DeprecatedImageSourcePropType'); -const DeprecatedImageStylePropTypes = require('./DeprecatedImageStylePropTypes'); -const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); -const PropTypes = require('prop-types'); - -module.exports = { - style: (DeprecatedStyleSheetPropType( - DeprecatedImageStylePropTypes, - ): ReactPropsCheckType), - source: DeprecatedImageSourcePropType, - defaultSource: (PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - width: PropTypes.number, - height: PropTypes.number, - scale: PropTypes.number, - }), - PropTypes.number, - ]): React$PropType$Primitive< - | { - height?: number, - scale?: number, - uri?: string, - width?: number, - ... - } - | number, - >), - - accessible: PropTypes.bool, - - accessibilityLabel: PropTypes.node, - - blurRadius: PropTypes.number, - - capInsets: DeprecatedEdgeInsetsPropType, - - resizeMethod: (PropTypes.oneOf([ - 'auto', - 'resize', - 'scale', - ]): React$PropType$Primitive<'auto' | 'resize' | 'scale'>), - - resizeMode: (PropTypes.oneOf([ - 'cover', - 'contain', - 'stretch', - 'repeat', - 'center', - ]): React$PropType$Primitive< - 'cover' | 'contain' | 'stretch' | 'repeat' | 'center', - >), - - testID: PropTypes.string, - - onLayout: PropTypes.func, - - onLoadStart: PropTypes.func, - - onProgress: PropTypes.func, - - onError: PropTypes.func, - - onPartialLoad: PropTypes.func, - - onLoad: PropTypes.func, - - onLoadEnd: PropTypes.func, -}; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImageSourcePropType.js b/Libraries/DeprecatedPropTypes/DeprecatedImageSourcePropType.js deleted file mode 100644 index ea00c1b45c6797..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedImageSourcePropType.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @no-flow - * @format - */ - -'use strict'; - -const PropTypes = require('prop-types'); - -const ImageURISourcePropType = PropTypes.shape({ - uri: PropTypes.string, - bundle: PropTypes.string, - method: PropTypes.string, - headers: PropTypes.objectOf(PropTypes.string), - body: PropTypes.string, - cache: PropTypes.oneOf([ - 'default', - 'reload', - 'force-cache', - 'only-if-cached', - ]), - width: PropTypes.number, - height: PropTypes.number, - scale: PropTypes.number, -}); - -const ImageSourcePropType = PropTypes.oneOfType([ - ImageURISourcePropType, - // Opaque type returned by require('./image.jpg') - PropTypes.number, - // Multiple sources - PropTypes.arrayOf(ImageURISourcePropType), -]); - -module.exports = ImageSourcePropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js deleted file mode 100644 index ea6224c81b90ae..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const DeprecatedLayoutPropTypes = require('./DeprecatedLayoutPropTypes'); -const DeprecatedShadowPropTypesIOS = require('./DeprecatedShadowPropTypesIOS'); -const DeprecatedTransformPropTypes = require('./DeprecatedTransformPropTypes'); -const ReactPropTypes = require('prop-types'); - -const ImageStylePropTypes = { - ...DeprecatedLayoutPropTypes, - ...DeprecatedShadowPropTypesIOS, - ...DeprecatedTransformPropTypes, - resizeMode: (ReactPropTypes.oneOf([ - 'center', - 'contain', - 'cover', - 'repeat', - 'stretch', - ]): React$PropType$Primitive< - 'center' | 'contain' | 'cover' | 'repeat' | 'stretch', - >), - backfaceVisibility: (ReactPropTypes.oneOf([ - 'visible', - 'hidden', - ]): React$PropType$Primitive<'visible' | 'hidden'>), - backgroundColor: DeprecatedColorPropType, - borderColor: DeprecatedColorPropType, - borderWidth: ReactPropTypes.number, - borderRadius: ReactPropTypes.number, - overflow: (ReactPropTypes.oneOf([ - 'visible', - 'hidden', - ]): React$PropType$Primitive<'visible' | 'hidden'>), - - /** - * Changes the color of all the non-transparent pixels to the tintColor. - */ - tintColor: DeprecatedColorPropType, - opacity: ReactPropTypes.number, - /** - * When the image has rounded corners, specifying an overlayColor will - * cause the remaining space in the corners to be filled with a solid color. - * This is useful in cases which are not supported by the Android - * implementation of rounded corners: - * - Certain resize modes, such as 'contain' - * - Animated GIFs - * - * A typical way to use this prop is with images displayed on a solid - * background and setting the `overlayColor` to the same color - * as the background. - * - * For details of how this works under the hood, see - * http://frescolib.org/docs/rounded-corners-and-circles.html - * - * @platform android - */ - overlayColor: ReactPropTypes.string, - - // Android-Specific styles - borderTopLeftRadius: ReactPropTypes.number, - borderTopRightRadius: ReactPropTypes.number, - borderBottomLeftRadius: ReactPropTypes.number, - borderBottomRightRadius: ReactPropTypes.number, -}; - -module.exports = ImageStylePropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js deleted file mode 100644 index 4d4488a9171f1a..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js +++ /dev/null @@ -1,233 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict - */ - -'use strict'; - -const ReactPropTypes = require('prop-types'); - -const LayoutPropTypes = { - display: (ReactPropTypes.oneOf(['none', 'flex']): React$PropType$Primitive< - 'none' | 'flex', - >), - width: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - height: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - start: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - end: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - top: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - left: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - right: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - bottom: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - minWidth: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - maxWidth: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - minHeight: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - maxHeight: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - margin: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginVertical: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginHorizontal: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginTop: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginBottom: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginLeft: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginRight: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginStart: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - marginEnd: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - padding: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingVertical: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingHorizontal: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingTop: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingBottom: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingLeft: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingRight: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingStart: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - paddingEnd: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - borderWidth: ReactPropTypes.number, - borderTopWidth: ReactPropTypes.number, - borderStartWidth: ReactPropTypes.number, - borderEndWidth: ReactPropTypes.number, - borderRightWidth: ReactPropTypes.number, - borderBottomWidth: ReactPropTypes.number, - borderLeftWidth: ReactPropTypes.number, - position: (ReactPropTypes.oneOf([ - 'absolute', - 'relative', - ]): React$PropType$Primitive<'absolute' | 'relative'>), - flexDirection: (ReactPropTypes.oneOf([ - 'row', - 'row-reverse', - 'column', - 'column-reverse', - ]): React$PropType$Primitive< - 'row' | 'row-reverse' | 'column' | 'column-reverse', - >), - flexWrap: (ReactPropTypes.oneOf([ - 'wrap', - 'nowrap', - 'wrap-reverse', - ]): React$PropType$Primitive<'wrap' | 'nowrap' | 'wrap-reverse'>), - justifyContent: (ReactPropTypes.oneOf([ - 'flex-start', - 'flex-end', - 'center', - 'space-between', - 'space-around', - 'space-evenly', - ]): React$PropType$Primitive< - | 'flex-start' - | 'flex-end' - | 'center' - | 'space-between' - | 'space-around' - | 'space-evenly', - >), - alignItems: (ReactPropTypes.oneOf([ - 'flex-start', - 'flex-end', - 'center', - 'stretch', - 'baseline', - ]): React$PropType$Primitive< - 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline', - >), - alignSelf: (ReactPropTypes.oneOf([ - 'auto', - 'flex-start', - 'flex-end', - 'center', - 'stretch', - 'baseline', - ]): React$PropType$Primitive< - 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline', - >), - alignContent: (ReactPropTypes.oneOf([ - 'flex-start', - 'flex-end', - 'center', - 'stretch', - 'space-between', - 'space-around', - ]): React$PropType$Primitive< - | 'flex-start' - | 'flex-end' - | 'center' - | 'stretch' - | 'space-between' - | 'space-around', - >), - overflow: (ReactPropTypes.oneOf([ - 'visible', - 'hidden', - 'scroll', - ]): React$PropType$Primitive<'visible' | 'hidden' | 'scroll'>), - flex: ReactPropTypes.number, - flexGrow: ReactPropTypes.number, - flexShrink: ReactPropTypes.number, - flexBasis: (ReactPropTypes.oneOfType([ - ReactPropTypes.number, - ReactPropTypes.string, - ]): React$PropType$Primitive), - aspectRatio: ReactPropTypes.number, - zIndex: ReactPropTypes.number, - direction: (ReactPropTypes.oneOf([ - 'inherit', - 'ltr', - 'rtl', - ]): React$PropType$Primitive<'inherit' | 'ltr' | 'rtl'>), -}; - -module.exports = LayoutPropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js deleted file mode 100644 index ef60608bd0e25d..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict - */ - -'use strict'; - -const PropTypes = require('prop-types'); - -const PointPropType: React$PropType$Primitive<{ - x?: number, - y?: number, - ... -}> = PropTypes.shape({ - x: PropTypes.number, - y: PropTypes.number, -}); - -module.exports = PointPropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js b/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js deleted file mode 100644 index d8e468359e2d76..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const ReactPropTypes = require('prop-types'); - -const DeprecatedShadowPropTypesIOS = { - shadowColor: DeprecatedColorPropType, - shadowOffset: (ReactPropTypes.shape({ - width: ReactPropTypes.number, - height: ReactPropTypes.number, - }): React$PropType$Primitive<{ - height?: number, - width?: number, - ... - }>), - shadowOpacity: ReactPropTypes.number, - shadowRadius: ReactPropTypes.number, -}; - -module.exports = DeprecatedShadowPropTypesIOS; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js deleted file mode 100644 index ac336be274ac51..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -'use strict'; - -const deprecatedCreateStrictShapeTypeChecker = require('./deprecatedCreateStrictShapeTypeChecker'); -const flattenStyle = require('../StyleSheet/flattenStyle'); - -function DeprecatedStyleSheetPropType(shape: { - [key: string]: ReactPropsCheckType, - ... -}): ReactPropsCheckType { - const shapePropType = deprecatedCreateStrictShapeTypeChecker(shape); - return function (props, propName, componentName, location?, ...rest) { - let newProps = props; - if (props[propName]) { - // Just make a dummy prop object with only the flattened style - newProps = {}; - newProps[propName] = flattenStyle(props[propName]); - } - return shapePropType(newProps, propName, componentName, location, ...rest); - }; -} - -module.exports = DeprecatedStyleSheetPropType; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js deleted file mode 100644 index 193865a2aa32ce..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js +++ /dev/null @@ -1,693 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const DeprecatedTextPropTypes = require('./DeprecatedTextPropTypes'); -const DeprecatedViewPropTypes = require('./DeprecatedViewPropTypes'); -const PropTypes = require('prop-types'); - -const DataDetectorTypes = [ - 'phoneNumber', - 'link', - 'address', - 'calendarEvent', - 'none', - 'all', -]; - -module.exports = { - ...DeprecatedViewPropTypes, - /** - * Can tell `TextInput` to automatically capitalize certain characters. - * - * - `characters`: all characters. - * - `words`: first letter of each word. - * - `sentences`: first letter of each sentence (*default*). - * - `none`: don't auto capitalize anything. - */ - autoCapitalize: (PropTypes.oneOf([ - 'none', - 'sentences', - 'words', - 'characters', - ]): React$PropType$Primitive<'none' | 'sentences' | 'words' | 'characters'>), - /** - * Specifies autocomplete hints for the system, so it can provide autofill. On Android, the system will always attempt to offer autofill by using heuristics to identify the type of content. - * To disable autocomplete, set `autoComplete` to `off`. - * - * *Android Only* - * - * Possible values for `autoComplete` are: - * - * - `birthdate-day` - * - `birthdate-full` - * - `birthdate-month` - * - `birthdate-year` - * - `cc-csc` - * - `cc-exp` - * - `cc-exp-day` - * - `cc-exp-month` - * - `cc-exp-year` - * - `cc-number` - * - `email` - * - `gender` - * - `name` - * - `name-family` - * - `name-given` - * - `name-middle` - * - `name-middle-initial` - * - `name-prefix` - * - `name-suffix` - * - `password` - * - `password-new` - * - `postal-address` - * - `postal-address-country` - * - `postal-address-extended` - * - `postal-address-extended-postal-code` - * - `postal-address-locality` - * - `postal-address-region` - * - `postal-code` - * - `street-address` - * - `sms-otp` - * - `tel` - * - `tel-country-code` - * - `tel-national` - * - `tel-device` - * - `username` - * - `username-new` - * - `off` - * - * @platform android - */ - autoComplete: (PropTypes.oneOf([ - 'birthdate-day', - 'birthdate-full', - 'birthdate-month', - 'birthdate-year', - 'cc-csc', - 'cc-exp', - 'cc-exp-day', - 'cc-exp-month', - 'cc-exp-year', - 'cc-number', - 'email', - 'gender', - 'name', - 'name-family', - 'name-given', - 'name-middle', - 'name-middle-initial', - 'name-prefix', - 'name-suffix', - 'password', - 'password-new', - 'postal-address', - 'postal-address-country', - 'postal-address-extended', - 'postal-address-extended-postal-code', - 'postal-address-locality', - 'postal-address-region', - 'postal-code', - 'street-address', - 'sms-otp', - 'tel', - 'tel-country-code', - 'tel-national', - 'tel-device', - 'username', - 'username-new', - 'off', - ]): React$PropType$Primitive< - | 'birthdate-day' - | 'birthdate-full' - | 'birthdate-month' - | 'birthdate-year' - | 'cc-csc' - | 'cc-exp' - | 'cc-exp-day' - | 'cc-exp-month' - | 'cc-exp-year' - | 'cc-number' - | 'email' - | 'gender' - | 'name' - | 'name-family' - | 'name-given' - | 'name-middle' - | 'name-middle-initial' - | 'name-prefix' - | 'name-suffix' - | 'password' - | 'password-new' - | 'postal-address' - | 'postal-address-country' - | 'postal-address-extended' - | 'postal-address-extended-postal-code' - | 'postal-address-locality' - | 'postal-address-region' - | 'postal-code' - | 'street-address' - | 'sms-otp' - | 'tel' - | 'tel-country-code' - | 'tel-national' - | 'tel-device' - | 'username' - | 'username-new' - | 'off', - >), - /** - * If `false`, disables auto-correct. The default value is `true`. - */ - autoCorrect: PropTypes.bool, - /** - * If `false`, disables spell-check style (i.e. red underlines). - * The default value is inherited from `autoCorrect`. - * @platform ios - */ - spellCheck: PropTypes.bool, - /** - * If `true`, focuses the input on `componentDidMount`. - * The default value is `false`. - */ - autoFocus: PropTypes.bool, - /** - * Specifies whether fonts should scale to respect Text Size accessibility settings. The - * default is `true`. - */ - allowFontScaling: PropTypes.bool, - /** - * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled. - * Possible values: - * `null/undefined` (default): inherit from the parent node or the global default (0) - * `0`: no max, ignore parent/global default - * `>= 1`: sets the maxFontSizeMultiplier of this node to this value - */ - maxFontSizeMultiplier: PropTypes.number, - /** - * If `false`, text is not editable. The default value is `true`. - */ - editable: PropTypes.bool, - /** - * Determines which keyboard to open, e.g.`numeric`. - * - * The following values work across platforms: - * - * - `default` - * - `numeric` - * - `number-pad` - * - `decimal-pad` - * - `email-address` - * - `phone-pad` - * - `url` - * - * *iOS Only* - * - * The following values work on iOS only: - * - * - `ascii-capable` - * - `numbers-and-punctuation` - * - `name-phone-pad` - * - `twitter` - * - `web-search` - * - `ascii-capable-number-pad` - * - * *Android Only* - * - * The following values work on Android only: - * - * - `visible-password` - */ - keyboardType: (PropTypes.oneOf([ - // Cross-platform - 'default', - 'email-address', - 'numeric', - 'phone-pad', - 'number-pad', - 'url', - // iOS-only - 'ascii-capable', - 'numbers-and-punctuation', - 'name-phone-pad', - 'decimal-pad', - 'twitter', - 'web-search', - // iOS 10+ only - 'ascii-capable-number-pad', - // Android-only - 'visible-password', - ]): React$PropType$Primitive< - | 'default' - | 'email-address' - | 'numeric' - | 'phone-pad' - | 'number-pad' - | 'ascii-capable' - | 'numbers-and-punctuation' - | 'url' - | 'name-phone-pad' - | 'decimal-pad' - | 'twitter' - | 'web-search' - | 'ascii-capable-number-pad' - | 'visible-password', - >), - /** - * Determines the color of the keyboard. - * @platform ios - */ - keyboardAppearance: (PropTypes.oneOf([ - 'default', - 'light', - 'dark', - ]): React$PropType$Primitive<'default' | 'light' | 'dark'>), - /** - * Determines how the return key should look. On Android you can also use - * `returnKeyLabel`. - * - * *Cross platform* - * - * The following values work across platforms: - * - * - `done` - * - `go` - * - `next` - * - `search` - * - `send` - * - * *Android Only* - * - * The following values work on Android only: - * - * - `none` - * - `previous` - * - * *iOS Only* - * - * The following values work on iOS only: - * - * - `default` - * - `emergency-call` - * - `google` - * - `join` - * - `route` - * - `yahoo` - */ - returnKeyType: (PropTypes.oneOf([ - // Cross-platform - 'done', - 'go', - 'next', - 'search', - 'send', - // Android-only - 'none', - 'previous', - // iOS-only - 'default', - 'emergency-call', - 'google', - 'join', - 'route', - 'yahoo', - ]): React$PropType$Primitive< - | 'done' - | 'go' - | 'next' - | 'search' - | 'send' - | 'none' - | 'previous' - | 'default' - | 'emergency-call' - | 'google' - | 'join' - | 'route' - | 'yahoo', - >), - /** - * Sets the return key to the label. Use it instead of `returnKeyType`. - * @platform android - */ - returnKeyLabel: PropTypes.string, - /** - * Limits the maximum number of characters that can be entered. Use this - * instead of implementing the logic in JS to avoid flicker. - */ - maxLength: PropTypes.number, - /** - * Sets the number of lines for a `TextInput`. Use it with multiline set to - * `true` to be able to fill the lines. - * @platform android - */ - numberOfLines: PropTypes.number, - /** - * When `false`, if there is a small amount of space available around a text input - * (e.g. landscape orientation on a phone), the OS may choose to have the user edit - * the text inside of a full screen text input mode. When `true`, this feature is - * disabled and users will always edit the text directly inside of the text input. - * Defaults to `false`. - * @platform android - */ - disableFullscreenUI: PropTypes.bool, - /** - * If `true`, the keyboard disables the return key when there is no text and - * automatically enables it when there is text. The default value is `false`. - * @platform ios - */ - enablesReturnKeyAutomatically: PropTypes.bool, - /** - * If `true`, the text input can be multiple lines. - * The default value is `false`. - */ - multiline: PropTypes.bool, - /** - * Set text break strategy on Android API Level 23+, possible values are `simple`, `highQuality`, `balanced` - * The default value is `simple`. - * @platform android - */ - textBreakStrategy: (PropTypes.oneOf([ - 'simple', - 'highQuality', - 'balanced', - ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), - /** - * Callback that is called when the text input is blurred. - */ - onBlur: PropTypes.func, - /** - * Callback that is called when the text input is focused. - */ - onFocus: PropTypes.func, - /** - * Callback that is called when the text input's text changes. - */ - onChange: PropTypes.func, - /** - * Callback that is called when the text input's text changes. - * Changed text is passed as an argument to the callback handler. - */ - onChangeText: PropTypes.func, - /** - * Callback that is called when the text input's content size changes. - * This will be called with - * `{ nativeEvent: { contentSize: { width, height } } }`. - * - * Only called for multiline text inputs. - */ - onContentSizeChange: PropTypes.func, - onTextInput: PropTypes.func, - /** - * Callback that is called when text input ends. - */ - onEndEditing: PropTypes.func, - /** - * Callback that is called when the text input selection is changed. - * This will be called with - * `{ nativeEvent: { selection: { start, end } } }`. - */ - onSelectionChange: PropTypes.func, - /** - * Callback that is called when the text input's submit button is pressed. - * Invalid if `multiline={true}` is specified. - */ - onSubmitEditing: PropTypes.func, - /** - * Callback that is called when a key is pressed. - * This will be called with `{ nativeEvent: { key: keyValue } }` - * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and - * the typed-in character otherwise including `' '` for space. - * Fires before `onChange` callbacks. - */ - onKeyPress: PropTypes.func, - /** - * Invoked on mount and layout changes with `{x, y, width, height}`. - */ - onLayout: PropTypes.func, - /** - * Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`. - * May also contain other properties from ScrollEvent but on Android contentSize - * is not provided for performance reasons. - */ - onScroll: PropTypes.func, - /** - * The string that will be rendered before text input has been entered. - */ - placeholder: PropTypes.string, - /** - * The text color of the placeholder string. - */ - placeholderTextColor: DeprecatedColorPropType, - /** - * If `false`, scrolling of the text view will be disabled. - * The default value is `true`. Does only work with 'multiline={true}'. - * @platform ios - */ - scrollEnabled: PropTypes.bool, - /** - * If `true`, the text input obscures the text entered so that sensitive text - * like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'. - */ - secureTextEntry: PropTypes.bool, - /** - * The highlight and cursor color of the text input. - */ - selectionColor: DeprecatedColorPropType, - /** - * The start and end of the text input's selection. Set start and end to - * the same value to position the cursor. - */ - selection: (PropTypes.shape({ - start: PropTypes.number.isRequired, - end: PropTypes.number, - }): React$PropType$Primitive<{ - end?: number, - start: number, - ... - }>), - /** - * The value to show for the text input. `TextInput` is a controlled - * component, which means the native value will be forced to match this - * value prop if provided. For most uses, this works great, but in some - * cases this may cause flickering - one common cause is preventing edits - * by keeping value the same. In addition to simply setting the same value, - * either set `editable={false}`, or set/update `maxLength` to prevent - * unwanted edits without flicker. - */ - value: PropTypes.string, - /** - * Provides an initial value that will change when the user starts typing. - * Useful for simple use-cases where you do not want to deal with listening - * to events and updating the value prop to keep the controlled state in sync. - */ - defaultValue: PropTypes.string, - /** - * When the clear button should appear on the right side of the text view. - * This property is supported only for single-line TextInput component. - * @platform ios - */ - clearButtonMode: (PropTypes.oneOf([ - 'never', - 'while-editing', - 'unless-editing', - 'always', - ]): React$PropType$Primitive< - 'never' | 'while-editing' | 'unless-editing' | 'always', - >), - /** - * If `true`, clears the text field automatically when editing begins. - * @platform ios - */ - clearTextOnFocus: PropTypes.bool, - /** - * If `true`, all text will automatically be selected on focus. - */ - selectTextOnFocus: PropTypes.bool, - /** - * If `true`, the text field will blur when submitted. - * The default value is true for single-line fields and false for - * multiline fields. Note that for multiline fields, setting `blurOnSubmit` - * to `true` means that pressing return will blur the field and trigger the - * `onSubmitEditing` event instead of inserting a newline into the field. - */ - blurOnSubmit: PropTypes.bool, - /** - * Note that not all Text styles are supported, an incomplete list of what is not supported includes: - * - * - `borderLeftWidth` - * - `borderTopWidth` - * - `borderRightWidth` - * - `borderBottomWidth` - * - `borderTopLeftRadius` - * - `borderTopRightRadius` - * - `borderBottomRightRadius` - * - `borderBottomLeftRadius` - * - * see [Issue#7070](https://github.com/facebook/react-native/issues/7070) - * for more detail. - * - * [Styles](docs/style.html) - */ - style: DeprecatedTextPropTypes.style, - /** - * The color of the `TextInput` underline. - * @platform android - */ - underlineColorAndroid: DeprecatedColorPropType, - - /** - * If defined, the provided image resource will be rendered on the left. - * The image resource must be inside `/android/app/src/main/res/drawable` and referenced - * like - * ``` - * - * ``` - * @platform android - */ - inlineImageLeft: PropTypes.string, - - /** - * Padding between the inline image, if any, and the text input itself. - * @platform android - */ - inlineImagePadding: PropTypes.number, - - /** - * If `true`, allows TextInput to pass touch events to the parent component. - * This allows components such as SwipeableListView to be swipeable from the TextInput on iOS, - * as is the case on Android by default. - * If `false`, TextInput always asks to handle the input (except when disabled). - * @platform ios - */ - rejectResponderTermination: PropTypes.bool, - - /** - * Determines the types of data converted to clickable URLs in the text input. - * Only valid if `multiline={true}` and `editable={false}`. - * By default no data types are detected. - * - * You can provide one type or an array of many types. - * - * Possible values for `dataDetectorTypes` are: - * - * - `'phoneNumber'` - * - `'link'` - * - `'address'` - * - `'calendarEvent'` - * - `'none'` - * - `'all'` - * - * @platform ios - */ - dataDetectorTypes: (PropTypes.oneOfType([ - PropTypes.oneOf(DataDetectorTypes), - PropTypes.arrayOf(PropTypes.oneOf(DataDetectorTypes)), - ]): React$PropType$Primitive< - | 'phoneNumber' - | 'link' - | 'address' - | 'calendarEvent' - | 'none' - | 'all' - | Array< - 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'none' | 'all', - >, - >), - /** - * If `true`, caret is hidden. The default value is `false`. - * This property is supported only for single-line TextInput component on iOS. - */ - caretHidden: PropTypes.bool, - /* - * If `true`, contextMenuHidden is hidden. The default value is `false`. - */ - contextMenuHidden: PropTypes.bool, - /** - * An optional identifier which links a custom InputAccessoryView to - * this text input. The InputAccessoryView is rendered above the - * keyboard when this text input is focused. - * @platform ios - */ - inputAccessoryViewID: PropTypes.string, - /** - * Give the keyboard and the system information about the - * expected semantic meaning for the content that users enter. - * @platform ios - */ - textContentType: (PropTypes.oneOf([ - 'none', - 'URL', - 'addressCity', - 'addressCityAndState', - 'addressState', - 'countryName', - 'creditCardNumber', - 'emailAddress', - 'familyName', - 'fullStreetAddress', - 'givenName', - 'jobTitle', - 'location', - 'middleName', - 'name', - 'namePrefix', - 'nameSuffix', - 'nickname', - 'organizationName', - 'postalCode', - 'streetAddressLine1', - 'streetAddressLine2', - 'sublocality', - 'telephoneNumber', - 'username', - 'password', - 'newPassword', - 'oneTimeCode', - ]): React$PropType$Primitive< - | 'none' - | 'URL' - | 'addressCity' - | 'addressCityAndState' - | 'addressState' - | 'countryName' - | 'creditCardNumber' - | 'emailAddress' - | 'familyName' - | 'fullStreetAddress' - | 'givenName' - | 'jobTitle' - | 'location' - | 'middleName' - | 'name' - | 'namePrefix' - | 'nameSuffix' - | 'nickname' - | 'organizationName' - | 'postalCode' - | 'streetAddressLine1' - | 'streetAddressLine2' - | 'sublocality' - | 'telephoneNumber' - | 'username' - | 'password' - | 'newPassword' - | 'oneTimeCode', - >), - /** - * When `false`, it will prevent the soft keyboard from showing when the field is focused. - * Defaults to `true`. - */ - showSoftInputOnFocus: PropTypes.bool, -}; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js deleted file mode 100644 index f14635ab3a8cfe..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const DeprecatedEdgeInsetsPropType = require('./DeprecatedEdgeInsetsPropType'); -const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); -const PropTypes = require('prop-types'); -const DeprecatedTextStylePropTypes = require('./DeprecatedTextStylePropTypes'); - -const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( - DeprecatedTextStylePropTypes, -); - -const DataDetectorTypes = ['phoneNumber', 'link', 'email', 'none', 'all']; - -module.exports = { - /** - * When `numberOfLines` is set, this prop defines how text will be - * truncated. - * - * See https://reactnative.dev/docs/text.html#ellipsizemode - */ - ellipsizeMode: (PropTypes.oneOf([ - 'head', - 'middle', - 'tail', - 'clip', - ]): React$PropType$Primitive<'head' | 'middle' | 'tail' | 'clip'>), - /** - * Used to truncate the text with an ellipsis. - * - * See https://reactnative.dev/docs/text.html#numberoflines - */ - numberOfLines: PropTypes.number, - /** - * Set text break strategy on Android. - * - * See https://reactnative.dev/docs/text.html#textbreakstrategy - */ - textBreakStrategy: (PropTypes.oneOf([ - 'simple', - 'highQuality', - 'balanced', - ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), - /** - * Invoked on mount and layout changes. - * - * See https://reactnative.dev/docs/text.html#onlayout - */ - onLayout: PropTypes.func, - /** - * This function is called on press. - * - * See https://reactnative.dev/docs/text.html#onpress - */ - onPress: PropTypes.func, - /** - * This function is called on long press. - * - * See https://reactnative.dev/docs/text.html#onlongpress - */ - onLongPress: PropTypes.func, - /** - * Defines how far your touch may move off of the button, before - * deactivating the button. - * - * See https://reactnative.dev/docs/text.html#pressretentionoffset - */ - pressRetentionOffset: DeprecatedEdgeInsetsPropType, - /** - * Lets the user select text. - * - * See https://reactnative.dev/docs/text.html#selectable - */ - selectable: PropTypes.bool, - /** - * The highlight color of the text. - * - * See https://reactnative.dev/docs/text.html#selectioncolor - */ - selectionColor: DeprecatedColorPropType, - /** - * When `true`, no visual change is made when text is pressed down. - * - * See https://reactnative.dev/docs/text.html#supperhighlighting - */ - suppressHighlighting: PropTypes.bool, - style: stylePropType, - /** - * Used to locate this view in end-to-end tests. - * - * See https://reactnative.dev/docs/text.html#testid - */ - testID: PropTypes.string, - /** - * Used to locate this view from native code. - * - * See https://reactnative.dev/docs/text.html#nativeid - */ - nativeID: PropTypes.string, - /** - * Whether fonts should scale to respect Text Size accessibility settings. - * - * See https://reactnative.dev/docs/text.html#allowfontscaling - */ - allowFontScaling: PropTypes.bool, - /** - * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled. - * Possible values: - * `null/undefined` (default): inherit from the parent node or the global default (0) - * `0`: no max, ignore parent/global default - * `>= 1`: sets the maxFontSizeMultiplier of this node to this value - */ - maxFontSizeMultiplier: PropTypes.number, - /** - * Indicates whether the view is an accessibility element. - * - * See https://reactnative.dev/docs/text.html#accessible - */ - accessible: PropTypes.bool, - /** - * Whether font should be scaled down automatically. - * - * See https://reactnative.dev/docs/text.html#adjustsfontsizetofit - */ - adjustsFontSizeToFit: PropTypes.bool, - /** - * Smallest possible scale a font can reach. - * - * See https://reactnative.dev/docs/text.html#minimumfontscale - */ - minimumFontScale: PropTypes.number, - /** - * Specifies the disabled state of the text view for testing purposes. - * - * See https://reactnative.dev/docs/text.html#disabled - */ - disabled: PropTypes.bool, - /** - * Determines the types of data converted to clickable URLs in text. - * - * See https://reactnative.dev/docs/text.html#dataDetectorType - */ - dataDetectorType: (PropTypes.oneOf( - DataDetectorTypes, - ): React$PropType$Primitive< - 'phoneNumber' | 'link' | 'email' | 'none' | 'all', - >), -}; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js deleted file mode 100644 index 1c41ff46259ce3..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const DeprecatedViewStylePropTypes = require('./DeprecatedViewStylePropTypes'); -const ReactPropTypes = require('prop-types'); - -const DeprecatedTextStylePropTypes = { - ...DeprecatedViewStylePropTypes, - - color: DeprecatedColorPropType, - fontFamily: ReactPropTypes.string, - fontSize: ReactPropTypes.number, - fontStyle: (ReactPropTypes.oneOf([ - 'normal', - 'italic', - ]): React$PropType$Primitive<'normal' | 'italic'>), - /** - * Specifies font weight. The values 'normal' and 'bold' are supported for - * most fonts. Not all fonts have a variant for each of the numeric values, - * in that case the closest one is chosen. - */ - fontWeight: (ReactPropTypes.oneOf([ - 'normal' /*default*/, - 'bold', - '100', - '200', - '300', - '400', - '500', - '600', - '700', - '800', - '900', - ]): React$PropType$Primitive< - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - >), - fontVariant: (ReactPropTypes.arrayOf( - ReactPropTypes.oneOf([ - 'small-caps', - 'oldstyle-nums', - 'lining-nums', - 'tabular-nums', - 'proportional-nums', - ]), - ): React$PropType$Primitive< - Array< - | 'small-caps' - | 'oldstyle-nums' - | 'lining-nums' - | 'tabular-nums' - | 'proportional-nums', - >, - >), - textShadowOffset: (ReactPropTypes.shape({ - width: ReactPropTypes.number, - height: ReactPropTypes.number, - }): React$PropType$Primitive<{ - height?: number, - width?: number, - ... - }>), - textShadowRadius: ReactPropTypes.number, - textShadowColor: DeprecatedColorPropType, - /** - * @platform ios - */ - letterSpacing: ReactPropTypes.number, - lineHeight: ReactPropTypes.number, - /** - * Specifies text alignment. The value 'justify' is only supported on iOS and - * fallbacks to `left` on Android. - */ - textAlign: (ReactPropTypes.oneOf([ - 'auto' /*default*/, - 'left', - 'right', - 'center', - 'justify', - ]): React$PropType$Primitive< - 'auto' | 'left' | 'right' | 'center' | 'justify', - >), - /** - * @platform android - */ - textAlignVertical: (ReactPropTypes.oneOf([ - 'auto' /*default*/, - 'top', - 'bottom', - 'center', - ]): React$PropType$Primitive<'auto' | 'top' | 'bottom' | 'center'>), - /** - * Set to `false` to remove extra font padding intended to make space for certain ascenders / descenders. - * With some fonts, this padding can make text look slightly misaligned when centered vertically. - * For best results also set `textAlignVertical` to `center`. Default is true. - * @platform android - */ - includeFontPadding: ReactPropTypes.bool, - textDecorationLine: (ReactPropTypes.oneOf([ - 'none' /*default*/, - 'underline', - 'line-through', - 'underline line-through', - ]): React$PropType$Primitive< - 'none' | 'underline' | 'line-through' | 'underline line-through', - >), - /** - * @platform ios - */ - textDecorationStyle: (ReactPropTypes.oneOf([ - 'solid' /*default*/, - 'double', - 'dotted', - 'dashed', - ]): React$PropType$Primitive<'solid' | 'double' | 'dotted' | 'dashed'>), - /** - * @platform ios - */ - textDecorationColor: DeprecatedColorPropType, - textTransform: (ReactPropTypes.oneOf([ - 'none' /*default*/, - 'capitalize', - 'uppercase', - 'lowercase', - ]): React$PropType$Primitive< - 'none' | 'capitalize' | 'uppercase' | 'lowercase', - >), - /** - * @platform ios - */ - writingDirection: (ReactPropTypes.oneOf([ - 'auto' /*default*/, - 'ltr', - 'rtl', - ]): React$PropType$Primitive<'auto' | 'ltr' | 'rtl'>), -}; - -module.exports = DeprecatedTextStylePropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js deleted file mode 100644 index 48c918a415ffbd..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const ReactPropTypes = require('prop-types'); - -const deprecatedPropType = require('../Utilities/deprecatedPropType'); - -const TransformMatrixPropType = function ( - props: Object, - propName: string, - componentName: string, -): ?Error { - if (props[propName]) { - return new Error( - 'The transformMatrix style property is deprecated. ' + - 'Use `transform: [{ matrix: ... }]` instead.', - ); - } -}; - -const DecomposedMatrixPropType = function ( - props: Object, - propName: string, - componentName: string, -): ?Error { - if (props[propName]) { - return new Error( - 'The decomposedMatrix style property is deprecated. ' + - 'Use `transform: [...]` instead.', - ); - } -}; - -const DeprecatedTransformPropTypes = { - transform: (ReactPropTypes.arrayOf( - ReactPropTypes.oneOfType([ - ReactPropTypes.shape({perspective: ReactPropTypes.number}), - ReactPropTypes.shape({rotate: ReactPropTypes.string}), - ReactPropTypes.shape({rotateX: ReactPropTypes.string}), - ReactPropTypes.shape({rotateY: ReactPropTypes.string}), - ReactPropTypes.shape({rotateZ: ReactPropTypes.string}), - ReactPropTypes.shape({scale: ReactPropTypes.number}), - ReactPropTypes.shape({scaleX: ReactPropTypes.number}), - ReactPropTypes.shape({scaleY: ReactPropTypes.number}), - ReactPropTypes.shape({translateX: ReactPropTypes.number}), - ReactPropTypes.shape({translateY: ReactPropTypes.number}), - ReactPropTypes.shape({skewX: ReactPropTypes.string}), - ReactPropTypes.shape({skewY: ReactPropTypes.string}), - ]), - ): React$PropType$Primitive< - Array< - | {perspective?: number, ...} - | {rotate?: string, ...} - | {rotateX?: string, ...} - | {rotateY?: string, ...} - | {rotateZ?: string, ...} - | {scale?: number, ...} - | {scaleX?: number, ...} - | {scaleY?: number, ...} - | {translateX?: number, ...} - | {translateY?: number, ...} - | {skewX?: string, ...} - | {skewY?: string, ...}, - >, - >), - transformMatrix: TransformMatrixPropType, - decomposedMatrix: DecomposedMatrixPropType, - scaleX: (deprecatedPropType( - ReactPropTypes.number, - 'Use the transform prop instead.', - ): ReactPropsCheckType), - scaleY: (deprecatedPropType( - ReactPropTypes.number, - 'Use the transform prop instead.', - ): ReactPropsCheckType), - rotation: (deprecatedPropType( - ReactPropTypes.number, - 'Use the transform prop instead.', - ): ReactPropsCheckType), - translateX: (deprecatedPropType( - ReactPropTypes.number, - 'Use the transform prop instead.', - ): ReactPropsCheckType), - translateY: (deprecatedPropType( - ReactPropTypes.number, - 'Use the transform prop instead.', - ): ReactPropsCheckType), -}; - -module.exports = DeprecatedTransformPropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js b/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js deleted file mode 100644 index 2ba6f3115c98f3..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict - */ - -'use strict'; - -module.exports = { - // This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m - DeprecatedAccessibilityRoles: [ - 'none', - 'button', - 'togglebutton', - 'link', - 'search', - 'image', - 'keyboardkey', - 'text', - 'adjustable', - 'imagebutton', - 'header', - 'summary', - 'alert', - 'checkbox', - 'combobox', - 'menu', - 'menubar', - 'menuitem', - 'progressbar', - 'radio', - 'radiogroup', - 'scrollbar', - 'spinbutton', - 'switch', - 'tab', - 'tablist', - 'timer', - 'list', - 'toolbar', - ], -}; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js deleted file mode 100644 index c008361311a7a2..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js +++ /dev/null @@ -1,408 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -'use strict'; - -const DeprecatedEdgeInsetsPropType = require('./DeprecatedEdgeInsetsPropType'); -const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); -const DeprecatedViewStylePropTypes = require('./DeprecatedViewStylePropTypes'); -const PropTypes = require('prop-types'); - -const {DeprecatedAccessibilityRoles} = require('./DeprecatedViewAccessibility'); - -const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( - DeprecatedViewStylePropTypes, -); - -module.exports = { - /** - * When `true`, indicates that the view is an accessibility element. - * By default, all the touchable elements are accessible. - * - * See https://reactnative.dev/docs/view.html#accessible - */ - accessible: PropTypes.bool, - - /** - * Overrides the text that's read by the screen reader when the user interacts - * with the element. By default, the label is constructed by traversing all - * the children and accumulating all the `Text` nodes separated by space. - * - * See https://reactnative.dev/docs/view.html#accessibilitylabel - */ - accessibilityLabel: PropTypes.node, - - /** - * An accessibility hint helps users understand what will happen when they perform - * an action on the accessibility element when that result is not obvious from the - * accessibility label. - * - * - * See https://reactnative.dev/docs/view.html#accessibilityHint - */ - accessibilityHint: PropTypes.string, - - /** - * Provides an array of custom actions available for accessibility. - * - * @platform ios - */ - accessibilityActions: (PropTypes.arrayOf( - PropTypes.string, - ): React$PropType$Primitive>), - - /** - * Prevents view from being inverted if set to true and color inversion is turned on. - * - * @platform ios - */ - accessibilityIgnoresInvertColors: PropTypes.bool, - - /** - * Indicates to accessibility services to treat UI component like a specific role. - */ - accessibilityRole: (PropTypes.oneOf( - DeprecatedAccessibilityRoles, - ): React$PropType$Primitive< - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar', - >), - - accessibilityState: PropTypes.object, - accessibilityValue: PropTypes.object, - /** - * Indicates to accessibility services whether the user should be notified - * when this view changes. Works for Android API >= 19 only. - * - * @platform android - * - * See https://reactnative.dev/docs/view.html#accessibilityliveregion - */ - accessibilityLiveRegion: (PropTypes.oneOf([ - 'none', - 'polite', - 'assertive', - ]): React$PropType$Primitive<'none' | 'polite' | 'assertive'>), - - /** - * Controls how view is important for accessibility which is if it - * fires accessibility events and if it is reported to accessibility services - * that query the screen. Works for Android only. - * - * @platform android - * - * See https://reactnative.dev/docs/view.html#importantforaccessibility - */ - importantForAccessibility: (PropTypes.oneOf([ - 'auto', - 'yes', - 'no', - 'no-hide-descendants', - ]): React$PropType$Primitive<'auto' | 'yes' | 'no' | 'no-hide-descendants'>), - - /** - * A value indicating whether VoiceOver should ignore the elements - * within views that are siblings of the receiver. - * Default is `false`. - * - * @platform ios - * - * See https://reactnative.dev/docs/view.html#accessibilityviewismodal - */ - accessibilityViewIsModal: PropTypes.bool, - - /** - * A value indicating whether the accessibility elements contained within - * this accessibility element are hidden. - * - * @platform ios - * - * See https://reactnative.dev/docs/view.html#accessibilityElementsHidden - */ - accessibilityElementsHidden: PropTypes.bool, - - /** - * When `accessible` is true, the system will try to invoke this function - * when the user performs an accessibility custom action. - * - * @platform ios - */ - onAccessibilityAction: PropTypes.func, - - /** - * When `accessible` is true, the system will try to invoke this function - * when the user performs accessibility tap gesture. - * - * See https://reactnative.dev/docs/view.html#onaccessibilitytap - */ - onAccessibilityTap: PropTypes.func, - - /** - * When `accessible` is `true`, the system will invoke this function when the - * user performs the magic tap gesture. - * - * See https://reactnative.dev/docs/view.html#onmagictap - */ - onMagicTap: PropTypes.func, - - /** - * Used to locate this view in end-to-end tests. - * - * > This disables the 'layout-only view removal' optimization for this view! - * - * See https://reactnative.dev/docs/view.html#testid - */ - testID: PropTypes.string, - - /** - * Used to locate this view from native classes. - * - * > This disables the 'layout-only view removal' optimization for this view! - * - * See https://reactnative.dev/docs/view.html#nativeid - */ - nativeID: PropTypes.string, - - /** - * For most touch interactions, you'll simply want to wrap your component in - * `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`, - * `ScrollResponder.js` and `ResponderEventPlugin.js` for more discussion. - */ - - /** - * The View is now responding for touch events. This is the time to highlight - * and show the user what is happening. - * - * `View.props.onResponderGrant: (event) => {}`, where `event` is a synthetic - * touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onrespondergrant - */ - onResponderGrant: PropTypes.func, - - /** - * The user is moving their finger. - * - * `View.props.onResponderMove: (event) => {}`, where `event` is a synthetic - * touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onrespondermove - */ - onResponderMove: PropTypes.func, - - /** - * Another responder is already active and will not release it to that `View` - * asking to be the responder. - * - * `View.props.onResponderReject: (event) => {}`, where `event` is a - * synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onresponderreject - */ - onResponderReject: PropTypes.func, - - /** - * Fired at the end of the touch. - * - * `View.props.onResponderRelease: (event) => {}`, where `event` is a - * synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onresponderrelease - */ - onResponderRelease: PropTypes.func, - - /** - * The responder has been taken from the `View`. Might be taken by other - * views after a call to `onResponderTerminationRequest`, or might be taken - * by the OS without asking (e.g., happens with control center/ notification - * center on iOS) - * - * `View.props.onResponderTerminate: (event) => {}`, where `event` is a - * synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onresponderterminate - */ - onResponderTerminate: PropTypes.func, - - /** - * Some other `View` wants to become responder and is asking this `View` to - * release its responder. Returning `true` allows its release. - * - * `View.props.onResponderTerminationRequest: (event) => {}`, where `event` - * is a synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onresponderterminationrequest - */ - onResponderTerminationRequest: PropTypes.func, - - /** - * Does this view want to become responder on the start of a touch? - * - * `View.props.onStartShouldSetResponder: (event) => [true | false]`, where - * `event` is a synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onstartshouldsetresponder - */ - onStartShouldSetResponder: PropTypes.func, - - /** - * If a parent `View` wants to prevent a child `View` from becoming responder - * on a touch start, it should have this handler which returns `true`. - * - * `View.props.onStartShouldSetResponderCapture: (event) => [true | false]`, - * where `event` is a synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onstartshouldsetrespondercapture - */ - onStartShouldSetResponderCapture: PropTypes.func, - - /** - * Does this view want to "claim" touch responsiveness? This is called for - * every touch move on the `View` when it is not the responder. - * - * `View.props.onMoveShouldSetResponder: (event) => [true | false]`, where - * `event` is a synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onmoveshouldsetresponder - */ - onMoveShouldSetResponder: PropTypes.func, - - /** - * If a parent `View` wants to prevent a child `View` from becoming responder - * on a move, it should have this handler which returns `true`. - * - * `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`, - * where `event` is a synthetic touch event as described above. - * - * See https://reactnative.dev/docs/view.html#onMoveShouldsetrespondercapture - */ - onMoveShouldSetResponderCapture: PropTypes.func, - - /** - * This defines how far a touch event can start away from the view. - * Typical interface guidelines recommend touch targets that are at least - * 30 - 40 points/density-independent pixels. - * - * > The touch area never extends past the parent view bounds and the Z-index - * > of sibling views always takes precedence if a touch hits two overlapping - * > views. - * - * See https://reactnative.dev/docs/view.html#hitslop - */ - hitSlop: DeprecatedEdgeInsetsPropType, - - /** - * Invoked on mount and layout changes with: - * - * `{nativeEvent: { layout: {x, y, width, height}}}` - * - * This event is fired immediately once the layout has been calculated, but - * the new layout may not yet be reflected on the screen at the time the - * event is received, especially if a layout animation is in progress. - * - * See https://reactnative.dev/docs/view.html#onlayout - */ - onLayout: PropTypes.func, - - /** - * Controls whether the `View` can be the target of touch events. - * - * See https://reactnative.dev/docs/view.html#pointerevents - */ - pointerEvents: (PropTypes.oneOf([ - 'box-none', - 'none', - 'box-only', - 'auto', - ]): React$PropType$Primitive<'box-none' | 'none' | 'box-only' | 'auto'>), - - /** - * See https://reactnative.dev/docs/style.html - */ - style: stylePropType, - - /** - * This is a special performance property exposed by `RCTView` and is useful - * for scrolling content when there are many subviews, most of which are - * offscreen. For this property to be effective, it must be applied to a - * view that contains many subviews that extend outside its bound. The - * subviews must also have `overflow: hidden`, as should the containing view - * (or one of its superviews). - * - * See https://reactnative.dev/docs/view.html#removeclippedsubviews - */ - removeClippedSubviews: PropTypes.bool, - - /** - * Whether this `View` should render itself (and all of its children) into a - * single hardware texture on the GPU. - * - * @platform android - * - * See https://reactnative.dev/docs/view.html#rendertohardwaretextureandroid - */ - renderToHardwareTextureAndroid: PropTypes.bool, - - /** - * Whether this `View` should be rendered as a bitmap before compositing. - * - * @platform ios - * - * See https://reactnative.dev/docs/view.html#shouldrasterizeios - */ - shouldRasterizeIOS: PropTypes.bool, - - /** - * Views that are only used to layout their children or otherwise don't draw - * anything may be automatically removed from the native hierarchy as an - * optimization. Set this property to `false` to disable this optimization and - * ensure that this `View` exists in the native view hierarchy. - * - * @platform android - * - * See https://reactnative.dev/docs/view.html#collapsable - */ - collapsable: PropTypes.bool, - - /** - * Whether this `View` needs to rendered offscreen and composited with an - * alpha in order to preserve 100% correct colors and blending behavior. - * - * @platform android - * - * See https://reactnative.dev/docs/view.html#needsoffscreenalphacompositing - */ - needsOffscreenAlphaCompositing: PropTypes.bool, -}; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js deleted file mode 100644 index 8b7036bd60761d..00000000000000 --- a/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const DeprecatedColorPropType = require('./DeprecatedColorPropType'); -const DeprecatedLayoutPropTypes = require('./DeprecatedLayoutPropTypes'); -const DeprecatedShadowPropTypesIOS = require('./DeprecatedShadowPropTypesIOS'); -const DeprecatedTransformPropTypes = require('./DeprecatedTransformPropTypes'); -const ReactPropTypes = require('prop-types'); - -/** - * Warning: Some of these properties may not be supported in all releases. - */ -const DeprecatedViewStylePropTypes = { - ...DeprecatedLayoutPropTypes, - ...DeprecatedShadowPropTypesIOS, - ...DeprecatedTransformPropTypes, - backfaceVisibility: (ReactPropTypes.oneOf([ - 'visible', - 'hidden', - ]): React$PropType$Primitive<'visible' | 'hidden'>), - backgroundColor: DeprecatedColorPropType, - borderColor: DeprecatedColorPropType, - borderTopColor: DeprecatedColorPropType, - borderRightColor: DeprecatedColorPropType, - borderBottomColor: DeprecatedColorPropType, - borderLeftColor: DeprecatedColorPropType, - borderStartColor: DeprecatedColorPropType, - borderEndColor: DeprecatedColorPropType, - borderRadius: ReactPropTypes.number, - borderTopLeftRadius: ReactPropTypes.number, - borderTopRightRadius: ReactPropTypes.number, - borderTopStartRadius: ReactPropTypes.number, - borderTopEndRadius: ReactPropTypes.number, - borderBottomLeftRadius: ReactPropTypes.number, - borderBottomRightRadius: ReactPropTypes.number, - borderBottomStartRadius: ReactPropTypes.number, - borderBottomEndRadius: ReactPropTypes.number, - borderStyle: (ReactPropTypes.oneOf([ - 'solid', - 'dotted', - 'dashed', - ]): React$PropType$Primitive<'solid' | 'dotted' | 'dashed'>), - borderWidth: ReactPropTypes.number, - borderTopWidth: ReactPropTypes.number, - borderRightWidth: ReactPropTypes.number, - borderBottomWidth: ReactPropTypes.number, - borderLeftWidth: ReactPropTypes.number, - opacity: ReactPropTypes.number, - /** - * (Android-only) Sets the elevation of a view, using Android's underlying - * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). - * This adds a drop shadow to the item and affects z-order for overlapping views. - * Only supported on Android 5.0+, has no effect on earlier versions. - * @platform android - */ - elevation: ReactPropTypes.number, -}; - -module.exports = DeprecatedViewStylePropTypes; diff --git a/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js b/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js deleted file mode 100644 index 240844ea5c670b..00000000000000 --- a/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const invariant = require('invariant'); - -function deprecatedCreateStrictShapeTypeChecker(shapeTypes: { - [key: string]: ReactPropsCheckType, - ... -}): ReactPropsChainableTypeChecker { - function checkType( - isRequired, - props, - propName, - componentName, - location?, - ...rest - ) { - if (!props[propName]) { - if (isRequired) { - invariant( - false, - `Required object \`${propName}\` was not specified in ` + - `\`${componentName}\`.`, - ); - } - return; - } - const propValue = props[propName]; - const propType = typeof propValue; - const locationName = location || '(unknown)'; - if (propType !== 'object') { - invariant( - false, - `Invalid ${locationName} \`${propName}\` of type \`${propType}\` ` + - `supplied to \`${componentName}\`, expected \`object\`.`, - ); - } - // We need to check all keys in case some are required but missing from - // props. - const allKeys = {...props[propName], ...shapeTypes}; - for (const key in allKeys) { - const checker = shapeTypes[key]; - if (!checker) { - invariant( - false, - `Invalid props.${propName} key \`${key}\` supplied to \`${componentName}\`.` + - '\nBad object: ' + - JSON.stringify(props[propName], null, ' ') + - '\nValid keys: ' + - JSON.stringify(Object.keys(shapeTypes), null, ' '), - ); - } - const error = checker(propValue, key, componentName, location, ...rest); - if (error) { - invariant( - false, - error.message + - '\nBad object: ' + - JSON.stringify(props[propName], null, ' '), - ); - } - } - } - function chainedCheckType( - props: {[key: string]: any, ...}, - propName: string, - componentName: string, - location?: string, - ...rest - ): ?Error { - return checkType(false, props, propName, componentName, location, ...rest); - } - chainedCheckType.isRequired = checkType.bind(null, true); - return chainedCheckType; -} - -module.exports = deprecatedCreateStrictShapeTypeChecker; diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index dbe164fd882ff9..402faec5282cc6 100644 --- a/Libraries/EventEmitter/NativeEventEmitter.js +++ b/Libraries/EventEmitter/NativeEventEmitter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,9 +10,9 @@ 'use strict'; -import { - type EventSubscription, - type IEventEmitter, +import type { + EventSubscription, + IEventEmitter, } from '../vendor/emitter/EventEmitter'; import Platform from '../Utilities/Platform'; import RCTDeviceEventEmitter from './RCTDeviceEventEmitter'; @@ -95,19 +95,6 @@ export default class NativeEventEmitter }; } - /** - * @deprecated Use `remove` on the EventSubscription from `addListener`. - */ - removeListener>( - eventType: TEvent, - listener: (...args: $ElementType) => mixed, - ): void { - this._nativeModule?.removeListeners(1); - // NOTE: This will report a deprecation notice via `console.error`. - // $FlowFixMe[prop-missing] - `removeListener` exists but is deprecated. - RCTDeviceEventEmitter.removeListener(eventType, listener); - } - emit>( eventType: TEvent, ...args: $ElementType diff --git a/Libraries/EventEmitter/RCTDeviceEventEmitter.js b/Libraries/EventEmitter/RCTDeviceEventEmitter.js index f4e57ef40f765d..c9f182f765040b 100644 --- a/Libraries/EventEmitter/RCTDeviceEventEmitter.js +++ b/Libraries/EventEmitter/RCTDeviceEventEmitter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,7 +8,8 @@ * @format */ -import EventEmitter, {type IEventEmitter} from '../vendor/emitter/EventEmitter'; +import EventEmitter from '../vendor/emitter/EventEmitter'; +import type {IEventEmitter} from '../vendor/emitter/EventEmitter'; // FIXME: use typed events type RCTDeviceEventDefinitions = $FlowFixMe; diff --git a/Libraries/EventEmitter/RCTEventEmitter.js b/Libraries/EventEmitter/RCTEventEmitter.js index fd0ac72eaf9995..27519d2d95595b 100644 --- a/Libraries/EventEmitter/RCTEventEmitter.js +++ b/Libraries/EventEmitter/RCTEventEmitter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/EventEmitter/RCTNativeAppEventEmitter.js b/Libraries/EventEmitter/RCTNativeAppEventEmitter.js index 9e7f4918450c83..bae9fa70f1475d 100644 --- a/Libraries/EventEmitter/RCTNativeAppEventEmitter.js +++ b/Libraries/EventEmitter/RCTNativeAppEventEmitter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js index ecaed2cfa23ce9..fe388c81ffc302 100644 --- a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +++ b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,9 +8,9 @@ * @flow strict-local */ -import { - type EventSubscription, - type IEventEmitter, +import type { + EventSubscription, + IEventEmitter, } from '../../vendor/emitter/EventEmitter'; import RCTDeviceEventEmitter from '../RCTDeviceEventEmitter'; diff --git a/Libraries/Events/CustomEvent.js b/Libraries/Events/CustomEvent.js new file mode 100644 index 00000000000000..96f422788f9ea2 --- /dev/null +++ b/Libraries/Events/CustomEvent.js @@ -0,0 +1,32 @@ +/** + * 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. + * + * @format + * @flow strict-local + */ + +// Make sure global Event is defined +import EventPolyfill from './EventPolyfill'; + +type CustomEvent$Options = $ReadOnly<{| + bubbles?: boolean, + cancelable?: boolean, + composed?: boolean, + detail?: {...}, +|}>; + +class CustomEvent extends EventPolyfill { + detail: ?{...}; + + constructor(typeArg: string, options: CustomEvent$Options) { + const {bubbles, cancelable, composed} = options; + super(typeArg, {bubbles, cancelable, composed}); + + this.detail = options.detail; // this would correspond to `NativeEvent` in SyntheticEvent + } +} + +export default CustomEvent; diff --git a/Libraries/Events/EventPolyfill.js b/Libraries/Events/EventPolyfill.js new file mode 100644 index 00000000000000..9d6f4364918d2f --- /dev/null +++ b/Libraries/Events/EventPolyfill.js @@ -0,0 +1,239 @@ +/** + * 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. + * + * @format + * @flow strict-local + */ + +// https://dom.spec.whatwg.org/#dictdef-eventinit +type Event$Init = { + bubbles?: boolean, + cancelable?: boolean, + composed?: boolean, + /** Non-standard. See `composed` instead. */ + scoped?: boolean, + ... +}; + +/** + * This is a copy of the Event interface defined in Flow: + * https://github.com/facebook/flow/blob/741104e69c43057ebd32804dd6bcc1b5e97548ea/lib/dom.js + * which is itself a faithful interface of the W3 spec: + * https://dom.spec.whatwg.org/#interface-event + * + * Since Flow assumes that Event is provided and is on the global object, + * we must provide an implementation of Event for CustomEvent (and future + * alignment of React Native's event system with the W3 spec). + */ +interface IEvent { + constructor(type: string, eventInitDict?: Event$Init): void; + /** + * Returns the type of event, e.g. "click", "hashchange", or "submit". + */ + +type: string; + /** + * Returns the object to which event is dispatched (its target). + */ + +target: EventTarget; // TODO: nullable + /** @deprecated */ + +srcElement: Element; // TODO: nullable + /** + * Returns the object whose event listener's callback is currently being invoked. + */ + +currentTarget: EventTarget; // TODO: nullable + /** + * Returns the invocation target objects of event's path (objects on which + * listeners will be invoked), except for any nodes in shadow trees of which + * the shadow root's mode is "closed" that are not reachable from event's + * currentTarget. + */ + composedPath(): Array; + + +NONE: number; + +AT_TARGET: number; + +BUBBLING_PHASE: number; + +CAPTURING_PHASE: number; + /** + * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, + * and BUBBLING_PHASE. + */ + +eventPhase: number; + + /** + * When dispatched in a tree, invoking this method prevents event from reaching + * any objects other than the current object. + */ + stopPropagation(): void; + /** + * Invoking this method prevents event from reaching any registered event + * listeners after the current one finishes running and, when dispatched in a + * tree, also prevents event from reaching any other objects. + */ + stopImmediatePropagation(): void; + + /** + * Returns true or false depending on how event was initialized. True if + * event goes through its target's ancestors in reverse tree order, and + * false otherwise. + */ + +bubbles: boolean; + /** + * Returns true or false depending on how event was initialized. Its + * return value does not always carry meaning, but true can indicate + * that part of the operation during which event was dispatched, can + * be canceled by invoking the preventDefault() method. + */ + +cancelable: boolean; + // returnValue: boolean; // legacy, and some subclasses still define it as a string! + /** + * If invoked when the cancelable attribute value is true, and while + * executing a listener for the event with passive set to false, signals to + * the operation that caused event to be dispatched that it needs to be + * canceled. + */ + preventDefault(): void; + /** + * Returns true if preventDefault() was invoked successfully to indicate + * cancelation, and false otherwise. + */ + +defaultPrevented: boolean; + /** + * Returns true or false depending on how event was initialized. True if + * event invokes listeners past a ShadowRoot node that is the root of its + * target, and false otherwise. + */ + +composed: boolean; + + /** + * Returns true if event was dispatched by the user agent, and false otherwise. + */ + +isTrusted: boolean; + /** + * Returns the event's timestamp as the number of milliseconds measured relative + * to the time origin. + */ + +timeStamp: number; + + /** Non-standard. See Event.prototype.composedPath */ + +deepPath?: () => EventTarget[]; + /** Non-standard. See Event.prototype.composed */ + +scoped: boolean; + + /** + * @deprecated + */ + initEvent(type: string, bubbles: boolean, cancelable: boolean): void; +} + +class EventPolyfill implements IEvent { + type: string; + bubbles: boolean; + cancelable: boolean; + composed: boolean; + // Non-standard. See `composed` instead. + scoped: boolean; + isTrusted: boolean; + defaultPrevented: boolean; + timeStamp: number; + + // https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase + NONE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; + + eventPhase: number; + + currentTarget: EventTarget; // TODO: nullable + target: EventTarget; // TODO: nullable + /** @deprecated */ + srcElement: Element; // TODO: nullable + + // React Native-specific: proxy data to a SyntheticEvent when + // certain methods are called. + // SyntheticEvent will also have a reference to this instance - + // it is circular - and both classes use this reference to keep + // data with the other in sync. + _syntheticEvent: mixed; + + constructor(type: string, eventInitDict?: Event$Init): void { + this.type = type; + this.bubbles = !!(eventInitDict?.bubbles || false); + this.cancelable = !!(eventInitDict?.cancelable || false); + this.composed = !!(eventInitDict?.composed || false); + this.scoped = !!(eventInitDict?.scoped || false); + + // TODO: somehow guarantee that only "private" instantiations of Event + // can set this to true + this.isTrusted = false; + + // TODO: in the future we'll want to make sure this has the same + // time-basis as events originating from native + this.timeStamp = Date.now(); + + this.defaultPrevented = false; + + // https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase + this.NONE = 0; + this.AT_TARGET = 1; + this.BUBBLING_PHASE = 2; + this.CAPTURING_PHASE = 3; + this.eventPhase = this.NONE; + + // $FlowFixMe + this.currentTarget = null; + // $FlowFixMe + this.target = null; + // $FlowFixMe + this.srcElement = null; + } + + composedPath(): Array { + throw new Error('TODO: not yet implemented'); + } + + preventDefault(): void { + this.defaultPrevented = true; + + if (this._syntheticEvent != null) { + // $FlowFixMe + this._syntheticEvent.preventDefault(); + } + } + + initEvent(type: string, bubbles: boolean, cancelable: boolean): void { + throw new Error( + 'TODO: not yet implemented. This method is also deprecated.', + ); + } + + stopImmediatePropagation(): void { + throw new Error('TODO: not yet implemented'); + } + + stopPropagation(): void { + if (this._syntheticEvent != null) { + // $FlowFixMe + this._syntheticEvent.stopPropagation(); + } + } + + setSyntheticEvent(value: mixed): void { + this._syntheticEvent = value; + } +} + +// Assertion magic for polyfill follows. +declare var checkEvent: Event; + +/*:: +// This can be a strict mode error at runtime so put it in a Flow comment. +(checkEvent: IEvent); +*/ + +global.Event = EventPolyfill; + +export default EventPolyfill; diff --git a/Libraries/FBLazyVector/BUCK b/Libraries/FBLazyVector/BUCK index 089bca264b12ab..89ab4c058e5b8c 100644 --- a/Libraries/FBLazyVector/BUCK +++ b/Libraries/FBLazyVector/BUCK @@ -12,7 +12,10 @@ fb_apple_library( enable_exceptions = False, extension_api_only = True, frameworks = [], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], link_whole = False, visibility = ["PUBLIC"], ) diff --git a/Libraries/FBLazyVector/FBLazyVector.podspec b/Libraries/FBLazyVector/FBLazyVector.podspec index d78d17e2b02d2d..41a0f756f0fdb0 100644 --- a/Libraries/FBLazyVector/FBLazyVector.podspec +++ b/Libraries/FBLazyVector/FBLazyVector.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "**/*.{c,h,m,mm,cpp}" s.header_dir = "FBLazyVector" diff --git a/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h b/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h index 3b6d27bbb9e983..bbeff166a11ee3 100644 --- a/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h +++ b/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h b/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h index a7eee0ca350e9a..ddd64bb2e774a3 100644 --- a/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h +++ b/Libraries/FBLazyVector/FBLazyVector/FBLazyVector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/HeapCapture/HeapCapture.js b/Libraries/HeapCapture/HeapCapture.js index b13099ecec831e..0c9be9caf21595 100644 --- a/Libraries/HeapCapture/HeapCapture.js +++ b/Libraries/HeapCapture/HeapCapture.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/HeapCapture/NativeJSCHeapCapture.js b/Libraries/HeapCapture/NativeJSCHeapCapture.js index 9a9b7abb0f0e10..21347dac036efa 100644 --- a/Libraries/HeapCapture/NativeJSCHeapCapture.js +++ b/Libraries/HeapCapture/NativeJSCHeapCapture.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/AssetRegistry.js b/Libraries/Image/AssetRegistry.js index 436195f76f77a6..78613fbe5be08f 100644 --- a/Libraries/Image/AssetRegistry.js +++ b/Libraries/Image/AssetRegistry.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index af702130fbfbd4..61b7c10794d317 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,7 +35,7 @@ const { /** * Returns a path like 'assets/AwesomeModule/icon@2x.png' */ -function getScaledAssetPath(asset): string { +function getScaledAssetPath(asset: PackagerAsset): string { const scale = pickScale(asset.scales, PixelRatio.get()); const scaleSuffix = scale === 1 ? '' : '@' + scale + 'x'; const assetDir = getBasePath(asset); @@ -45,7 +45,7 @@ function getScaledAssetPath(asset): string { /** * Returns a path like 'drawable-mdpi/icon.png' */ -function getAssetPathInDrawableFolder(asset): string { +function getAssetPathInDrawableFolder(asset: PackagerAsset): string { const scale = pickScale(asset.scales, PixelRatio.get()); const drawbleFolder = getAndroidResourceFolderName(asset, scale); const fileName = getAndroidResourceIdentifier(asset); diff --git a/Libraries/Image/AssetUtils.js b/Libraries/Image/AssetUtils.js index a2f85473ffc4be..fd370621f0c080 100644 --- a/Libraries/Image/AssetUtils.js +++ b/Libraries/Image/AssetUtils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 24b0f55b3782c8..eac8a56c63eba7 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -32,7 +32,7 @@ function generateRequestId() { /** * Retrieve the width and height (in pixels) of an image prior to displaying it * - * See https://reactnative.dev/docs/image.html#getsize + * See https://reactnative.dev/docs/image#getsize */ function getSize( url: string, @@ -55,7 +55,7 @@ function getSize( * Retrieve the width and height (in pixels) of an image prior to displaying it * with the ability to provide the headers for the request * - * See https://reactnative.dev/docs/image.html#getsizewithheaders + * See https://reactnative.dev/docs/image#getsizewithheaders */ function getSizeWithHeaders( url: string, @@ -98,7 +98,7 @@ function abortPrefetch(requestId: number) { /** * Perform cache interrogation. * - * See https://reactnative.dev/docs/image.html#querycache + * See https://reactnative.dev/docs/image#querycache */ async function queryCache( urls: Array, @@ -106,7 +106,7 @@ async function queryCache( return await NativeImageLoaderAndroid.queryCache(urls); } -type ImageComponentStatics = $ReadOnly<{| +export type ImageComponentStatics = $ReadOnly<{| getSize: typeof getSize, getSizeWithHeaders: typeof getSizeWithHeaders, prefetch: typeof prefetch, @@ -121,9 +121,11 @@ type ImageComponentStatics = $ReadOnly<{| * including network images, static resources, temporary local images, and * images from local disk, such as the camera roll. * - * See https://reactnative.dev/docs/image.html + * See https://reactnative.dev/docs/image */ -let Image = (props: ImagePropsType, forwardedRef) => { +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +const BaseImage = (props: ImagePropsType, forwardedRef) => { let source = resolveAssetSource(props.source); const defaultSource = resolveAssetSource(props.defaultSource); const loadingIndicatorSource = resolveAssetSource( @@ -198,13 +200,22 @@ let Image = (props: ImagePropsType, forwardedRef) => { : nativeProps; return ( - {hasTextAncestor => - hasTextAncestor ? ( - - ) : ( - - ) - } + {hasTextAncestor => { + if (hasTextAncestor) { + let src = Array.isArray(sources) ? sources : [sources]; + return ( + + ); + } + + return ; + }} ); }} @@ -212,11 +223,11 @@ let Image = (props: ImagePropsType, forwardedRef) => { ); }; -Image = React.forwardRef< +let Image = React.forwardRef< ImagePropsType, | React.ElementRef | React.ElementRef, ->(Image); +>(BaseImage); if (ImageInjection.unstable_createImageComponent != null) { Image = ImageInjection.unstable_createImageComponent(Image); @@ -227,7 +238,7 @@ Image.displayName = 'Image'; /** * Retrieve the width and height (in pixels) of an image prior to displaying it * - * See https://reactnative.dev/docs/image.html#getsize + * See https://reactnative.dev/docs/image#getsize */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -238,7 +249,7 @@ Image.getSize = getSize; * Retrieve the width and height (in pixels) of an image prior to displaying it * with the ability to provide the headers for the request * - * See https://reactnative.dev/docs/image.html#getsizewithheaders + * See https://reactnative.dev/docs/image#getsizewithheaders */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -249,7 +260,7 @@ Image.getSizeWithHeaders = getSizeWithHeaders; * Prefetches a remote image for later use by downloading it to the disk * cache * - * See https://reactnative.dev/docs/image.html#prefetch + * See https://reactnative.dev/docs/image#prefetch */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -260,7 +271,7 @@ Image.prefetch = prefetch; * Prefetches a remote image for later use by downloading it to the disk * cache, and adds metadata for queryRootName and rootTag. * - * See https://reactnative.dev/docs/image.html#prefetch + * See https://reactnative.dev/docs/image#prefetch */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -270,7 +281,7 @@ Image.prefetchWithMetadata = prefetchWithMetadata; /** * Abort prefetch request. * - * See https://reactnative.dev/docs/image.html#abortprefetch + * See https://reactnative.dev/docs/image#abortprefetch */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -280,7 +291,7 @@ Image.abortPrefetch = abortPrefetch; /** * Perform cache interrogation. * - * See https://reactnative.dev/docs/image.html#querycache + * See https://reactnative.dev/docs/image#querycache */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this @@ -290,19 +301,13 @@ Image.queryCache = queryCache; /** * Resolves an asset reference into an object. * - * See https://reactnative.dev/docs/image.html#resolveassetsource + * See https://reactnative.dev/docs/image#resolveassetsource */ /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an * error found when Flow v0.89 was deployed. To see the error, delete this * comment and run Flow. */ Image.resolveAssetSource = resolveAssetSource; -/** - * Switch to `deprecated-react-native-prop-types` for compatibility with future - * releases. This is deprecated and will be removed in the future. - */ -Image.propTypes = require('deprecated-react-native-prop-types').ImagePropTypes; - const styles = StyleSheet.create({ base: { overflow: 'hidden', diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 953d01716d51b5..7b5d0c0c43372c 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -86,7 +86,7 @@ async function queryCache( return await NativeImageLoaderIOS.queryCache(urls); } -type ImageComponentStatics = $ReadOnly<{| +export type ImageComponentStatics = $ReadOnly<{| getSize: typeof getSize, getSizeWithHeaders: typeof getSizeWithHeaders, prefetch: typeof prefetch, @@ -100,9 +100,11 @@ type ImageComponentStatics = $ReadOnly<{| * including network images, static resources, temporary local images, and * images from local disk, such as the camera roll. * - * See https://reactnative.dev/docs/image.html + * See https://reactnative.dev/docs/image */ -let Image = (props: ImagePropsType, forwardedRef) => { +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +const BaseImage = (props: ImagePropsType, forwardedRef) => { const source = resolveAssetSource(props.source) || { uri: undefined, width: undefined, @@ -158,11 +160,12 @@ let Image = (props: ImagePropsType, forwardedRef) => { ); }; -Image = React.forwardRef< +const ImageForwardRef = React.forwardRef< ImagePropsType, React.ElementRef, ->(Image); +>(BaseImage); +let Image = ImageForwardRef; if (ImageInjection.unstable_createImageComponent != null) { Image = ImageInjection.unstable_createImageComponent(Image); } @@ -172,7 +175,7 @@ Image.displayName = 'Image'; /** * Retrieve the width and height (in pixels) of an image prior to displaying it. * - * See https://reactnative.dev/docs/image.html#getsize + * See https://reactnative.dev/docs/image#getsize */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, @@ -183,7 +186,7 @@ Image.getSize = getSize; * Retrieve the width and height (in pixels) of an image prior to displaying it * with the ability to provide the headers for the request. * - * See https://reactnative.dev/docs/image.html#getsizewithheaders + * See https://reactnative.dev/docs/image#getsizewithheaders */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, @@ -194,7 +197,7 @@ Image.getSizeWithHeaders = getSizeWithHeaders; * Prefetches a remote image for later use by downloading it to the disk * cache. * - * See https://reactnative.dev/docs/image.html#prefetch + * See https://reactnative.dev/docs/image#prefetch */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, @@ -205,7 +208,7 @@ Image.prefetch = prefetch; * Prefetches a remote image for later use by downloading it to the disk * cache, and adds metadata for queryRootName and rootTag. * - * See https://reactnative.dev/docs/image.html#prefetch + * See https://reactnative.dev/docs/image#prefetch */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, @@ -215,7 +218,7 @@ Image.prefetchWithMetadata = prefetchWithMetadata; /** * Performs cache interrogation. * - * See https://reactnative.dev/docs/image.html#querycache + * See https://reactnative.dev/docs/image#querycache */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, @@ -225,19 +228,13 @@ Image.queryCache = queryCache; /** * Resolves an asset reference into an object. * - * See https://reactnative.dev/docs/image.html#resolveassetsource + * See https://reactnative.dev/docs/image#resolveassetsource */ /* $FlowFixMe[prop-missing] (>=0.89.0 site=react_native_ios_fb) This comment * suppresses an error found when Flow v0.89 was deployed. To see the error, * delete this comment and run Flow. */ Image.resolveAssetSource = resolveAssetSource; -/** - * Switch to `deprecated-react-native-prop-types` for compatibility with future - * releases. This is deprecated and will be removed in the future. - */ -Image.propTypes = require('deprecated-react-native-prop-types').ImagePropTypes; - const styles = StyleSheet.create({ base: { overflow: 'hidden', diff --git a/Libraries/Image/ImageAnalyticsTagContext.js b/Libraries/Image/ImageAnalyticsTagContext.js index 742a042c98d584..81ecba24da5ea0 100644 --- a/Libraries/Image/ImageAnalyticsTagContext.js +++ b/Libraries/Image/ImageAnalyticsTagContext.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/ImageBackground.js b/Libraries/Image/ImageBackground.js index 445b66dbc381c5..30ac413552af33 100644 --- a/Libraries/Image/ImageBackground.js +++ b/Libraries/Image/ImageBackground.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/ImageInjection.js b/Libraries/Image/ImageInjection.js index 43723fa37566ce..9a32ef3fd0a22f 100644 --- a/Libraries/Image/ImageInjection.js +++ b/Libraries/Image/ImageInjection.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/ImagePickerIOS.js b/Libraries/Image/ImagePickerIOS.js index 60ae31ba764e95..e94cd646e9a1f0 100644 --- a/Libraries/Image/ImagePickerIOS.js +++ b/Libraries/Image/ImagePickerIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/ImageProps.js b/Libraries/Image/ImageProps.js index ed3349c2b247b5..6bb36fedb5d4aa 100644 --- a/Libraries/Image/ImageProps.js +++ b/Libraries/Image/ImageProps.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -32,19 +32,19 @@ type IOSImageProps = $ReadOnly<{| /** * A static image to display while loading the image source. * - * See https://reactnative.dev/docs/image.html#defaultsource + * See https://reactnative.dev/docs/image#defaultsource */ defaultSource?: ?ImageSource, /** * Invoked when a partial load of the image is complete. * - * See https://reactnative.dev/docs/image.html#onpartialload + * See https://reactnative.dev/docs/image#onpartialload */ onPartialLoad?: ?() => void, /** * Invoked on download progress with `{nativeEvent: {loaded, total}}`. * - * See https://reactnative.dev/docs/image.html#onprogress + * See https://reactnative.dev/docs/image#onprogress */ onProgress?: ?( event: SyntheticEvent<$ReadOnly<{|loaded: number, total: number|}>>, @@ -65,7 +65,7 @@ export type ImageProps = {| /** * When true, indicates the image is an accessibility element. * - * See https://reactnative.dev/docs/image.html#accessible + * See https://reactnative.dev/docs/image#accessible */ accessible?: ?boolean, @@ -78,26 +78,26 @@ export type ImageProps = {| * The text that's read by the screen reader when the user interacts with * the image. * - * See https://reactnative.dev/docs/image.html#accessibilitylabel + * See https://reactnative.dev/docs/image#accessibilitylabel */ accessibilityLabel?: ?Stringish, /** * blurRadius: the blur radius of the blur filter added to the image * - * See https://reactnative.dev/docs/image.html#blurradius + * See https://reactnative.dev/docs/image#blurradius */ blurRadius?: ?number, /** - * See https://reactnative.dev/docs/image.html#capinsets + * See https://reactnative.dev/docs/image#capinsets */ capInsets?: ?EdgeInsetsProp, /** * Invoked on load error with `{nativeEvent: {error}}`. * - * See https://reactnative.dev/docs/image.html#onerror + * See https://reactnative.dev/docs/image#onerror */ onError?: ?( event: SyntheticEvent< @@ -111,7 +111,7 @@ export type ImageProps = {| * Invoked on mount and layout changes with * `{nativeEvent: {layout: {x, y, width, height}}}`. * - * See https://reactnative.dev/docs/image.html#onlayout + * See https://reactnative.dev/docs/image#onlayout */ onLayout?: ?(event: LayoutEvent) => mixed, @@ -119,38 +119,38 @@ export type ImageProps = {| /** * Invoked when load completes successfully. * - * See https://reactnative.dev/docs/image.html#onload + * See https://reactnative.dev/docs/image#onload */ onLoad?: ?(event: ImageLoadEvent) => void, /** * Invoked when load either succeeds or fails. * - * See https://reactnative.dev/docs/image.html#onloadend + * See https://reactnative.dev/docs/image#onloadend */ onLoadEnd?: ?() => void, /** * Invoked on load start. * - * See https://reactnative.dev/docs/image.html#onloadstart + * See https://reactnative.dev/docs/image#onloadstart */ onLoadStart?: ?() => void, /** - * See https://reactnative.dev/docs/image.html#resizemethod + * See https://reactnative.dev/docs/image#resizemethod */ resizeMethod?: ?('auto' | 'resize' | 'scale'), /** * The image source (either a remote URL or a local file resource). * - * See https://reactnative.dev/docs/image.html#source + * See https://reactnative.dev/docs/image#source */ source?: ?ImageSource, /** - * See https://reactnative.dev/docs/image.html#style + * See https://reactnative.dev/docs/image#style */ style?: ?ImageStyleProp, @@ -158,7 +158,7 @@ export type ImageProps = {| * Determines how to resize the image when the frame doesn't match the raw * image dimensions. * - * See https://reactnative.dev/docs/image.html#resizemode + * See https://reactnative.dev/docs/image#resizemode */ resizeMode?: ?('cover' | 'contain' | 'stretch' | 'repeat' | 'center'), @@ -166,7 +166,7 @@ export type ImageProps = {| * A unique identifier for this element to be used in UI Automation * testing scripts. * - * See https://reactnative.dev/docs/image.html#testid + * See https://reactnative.dev/docs/image#testid */ testID?: ?string, diff --git a/Libraries/Image/ImageResizeMode.js b/Libraries/Image/ImageResizeMode.js index 1dad3309b1588d..b63627b793bd43 100644 --- a/Libraries/Image/ImageResizeMode.js +++ b/Libraries/Image/ImageResizeMode.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/ImageSource.js b/Libraries/Image/ImageSource.js index 903b144b9ac889..20966d58166051 100644 --- a/Libraries/Image/ImageSource.js +++ b/Libraries/Image/ImageSource.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -91,9 +91,7 @@ export type ImageSource = | ImageURISource | $ReadOnlyArray; -export function getImageSourceProperties( - imageSource: ImageURISource, -): $ReadOnly<{ +type ImageSourceProperties = { body?: ?string, bundle?: ?string, cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), @@ -104,8 +102,12 @@ export function getImageSourceProperties( uri?: ?string, width?: ?number, ... -}> { - const object = {}; +}; + +export function getImageSourceProperties( + imageSource: ImageURISource, +): $ReadOnly { + const object: ImageSourceProperties = {}; if (imageSource.body != null) { object.body = imageSource.body; } diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index 652f59d9b6d200..ad724a5efb72ee 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,12 +12,17 @@ import type {ResolvedAssetSource} from './AssetSourceResolver'; import type {ImageProps} from './ImageProps'; import type {ViewProps} from '../Components/View/ViewPropTypes'; import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry'; -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; +import {ConditionallyIgnoredEventHandlers} from '../NativeComponent/ViewConfigIgnore'; +import type { + HostComponent, + PartialViewConfig, +} from '../Renderer/shims/ReactNativeTypes'; import type { ColorValue, DangerouslyImpreciseStyle, ImageStyleProp, } from '../StyleSheet/StyleSheet'; +import Platform from '../Utilities/Platform'; type Props = $ReadOnly<{ ...ImageProps, @@ -31,67 +36,114 @@ type Props = $ReadOnly<{ // Android native props shouldNotifyLoadEvents?: boolean, src?: ?ResolvedAssetSource | $ReadOnlyArray<{uri: string, ...}>, - headers?: ?string, + headers?: ?{[string]: string}, defaultSrc?: ?string, loadingIndicatorSrc?: ?string, }>; +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = + Platform.OS === 'android' + ? { + uiViewClassName: 'RCTImageView', + bubblingEventTypes: {}, + directEventTypes: { + topLoadStart: { + registrationName: 'onLoadStart', + }, + topProgress: { + registrationName: 'onProgress', + }, + topError: { + registrationName: 'onError', + }, + topLoad: { + registrationName: 'onLoad', + }, + topLoadEnd: { + registrationName: 'onLoadEnd', + }, + }, + validAttributes: { + blurRadius: true, + internal_analyticTag: true, + resizeMode: true, + tintColor: { + process: require('../StyleSheet/processColor'), + }, + borderBottomLeftRadius: true, + borderTopLeftRadius: true, + resizeMethod: true, + src: true, + borderRadius: true, + headers: true, + shouldNotifyLoadEvents: true, + defaultSrc: true, + overlayColor: { + process: require('../StyleSheet/processColor'), + }, + borderColor: { + process: require('../StyleSheet/processColor'), + }, + accessible: true, + progressiveRenderingEnabled: true, + fadeDuration: true, + borderBottomRightRadius: true, + borderTopRightRadius: true, + loadingIndicatorSrc: true, + }, + } + : { + uiViewClassName: 'RCTImageView', + bubblingEventTypes: {}, + directEventTypes: { + topLoadStart: { + registrationName: 'onLoadStart', + }, + topProgress: { + registrationName: 'onProgress', + }, + topError: { + registrationName: 'onError', + }, + topPartialLoad: { + registrationName: 'onPartialLoad', + }, + topLoad: { + registrationName: 'onLoad', + }, + topLoadEnd: { + registrationName: 'onLoadEnd', + }, + }, + validAttributes: { + blurRadius: true, + capInsets: { + diff: require('../Utilities/differ/insetsDiffer'), + }, + defaultSource: { + process: require('./resolveAssetSource'), + }, + internal_analyticTag: true, + resizeMode: true, + source: true, + tintColor: { + process: require('../StyleSheet/processColor'), + }, + ...ConditionallyIgnoredEventHandlers({ + onLoadStart: true, + onLoad: true, + onLoadEnd: true, + onProgress: true, + onError: true, + onPartialLoad: true, + }), + }, + }; + const ImageViewNativeComponent: HostComponent = - NativeComponentRegistry.get('RCTImageView', () => ({ - uiViewClassName: 'RCTImageView', - bubblingEventTypes: {}, - directEventTypes: { - topLoadStart: { - registrationName: 'onLoadStart', - }, - topProgress: { - registrationName: 'onProgress', - }, - topError: { - registrationName: 'onError', - }, - topPartialLoad: { - registrationName: 'onPartialLoad', - }, - topLoad: { - registrationName: 'onLoad', - }, - topLoadEnd: { - registrationName: 'onLoadEnd', - }, - }, - validAttributes: { - blurRadius: true, - capInsets: { - diff: require('../Utilities/differ/insetsDiffer'), - }, - defaultSource: { - process: require('./resolveAssetSource'), - }, - defaultSrc: true, - fadeDuration: true, - headers: true, - internal_analyticTag: true, - loadingIndicatorSrc: true, - onError: true, - onLoad: true, - onLoadEnd: true, - onLoadStart: true, - onPartialLoad: true, - onProgress: true, - overlayColor: { - process: require('../StyleSheet/processColor'), - }, - progressiveRenderingEnabled: true, - resizeMethod: true, - resizeMode: true, - shouldNotifyLoadEvents: true, - source: true, - src: true, - tintColor: { - process: require('../StyleSheet/processColor'), - }, - }, - })); + NativeComponentRegistry.get( + 'RCTImageView', + () => __INTERNAL_VIEW_CONFIG, + ); export default ImageViewNativeComponent; diff --git a/Libraries/Image/NativeImageEditor.js b/Libraries/Image/NativeImageEditor.js index 726bf2b0b9e1c7..e17f836e3a1d06 100644 --- a/Libraries/Image/NativeImageEditor.js +++ b/Libraries/Image/NativeImageEditor.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/NativeImageLoaderAndroid.js b/Libraries/Image/NativeImageLoaderAndroid.js index f75ddbfde694f2..dcc3db261573ac 100644 --- a/Libraries/Image/NativeImageLoaderAndroid.js +++ b/Libraries/Image/NativeImageLoaderAndroid.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/NativeImageLoaderIOS.js b/Libraries/Image/NativeImageLoaderIOS.js index 91c65a6e245cad..18a4703d886bad 100644 --- a/Libraries/Image/NativeImageLoaderIOS.js +++ b/Libraries/Image/NativeImageLoaderIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/NativeImagePickerIOS.js b/Libraries/Image/NativeImagePickerIOS.js index 8db58d407e2108..9e641f206a956e 100644 --- a/Libraries/Image/NativeImagePickerIOS.js +++ b/Libraries/Image/NativeImagePickerIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/NativeImageStoreAndroid.js b/Libraries/Image/NativeImageStoreAndroid.js index 4f870f6c067861..7dc4ed58e05cab 100644 --- a/Libraries/Image/NativeImageStoreAndroid.js +++ b/Libraries/Image/NativeImageStoreAndroid.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/NativeImageStoreIOS.js b/Libraries/Image/NativeImageStoreIOS.js index 4b30843e9cabb1..7a057f0ad37796 100644 --- a/Libraries/Image/NativeImageStoreIOS.js +++ b/Libraries/Image/NativeImageStoreIOS.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTAnimatedImage.h b/Libraries/Image/RCTAnimatedImage.h index 933a49232bf892..34911498aa2000 100644 --- a/Libraries/Image/RCTAnimatedImage.h +++ b/Libraries/Image/RCTAnimatedImage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTAnimatedImage.m b/Libraries/Image/RCTAnimatedImage.m index 4b32c8bb9b8291..158d7a2b657e54 100644 --- a/Libraries/Image/RCTAnimatedImage.m +++ b/Libraries/Image/RCTAnimatedImage.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTDisplayWeakRefreshable.h b/Libraries/Image/RCTDisplayWeakRefreshable.h index c1ea105a62943a..d285c0c181926c 100644 --- a/Libraries/Image/RCTDisplayWeakRefreshable.h +++ b/Libraries/Image/RCTDisplayWeakRefreshable.h @@ -1,11 +1,12 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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 +#import @protocol RCTDisplayRefreshable diff --git a/Libraries/Image/RCTDisplayWeakRefreshable.m b/Libraries/Image/RCTDisplayWeakRefreshable.m index c84e54053e77a1..20631dd53cbef8 100644 --- a/Libraries/Image/RCTDisplayWeakRefreshable.m +++ b/Libraries/Image/RCTDisplayWeakRefreshable.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTGIFImageDecoder.h b/Libraries/Image/RCTGIFImageDecoder.h index 2d5663799c66fd..8c397484e4bc7c 100644 --- a/Libraries/Image/RCTGIFImageDecoder.h +++ b/Libraries/Image/RCTGIFImageDecoder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTGIFImageDecoder.mm b/Libraries/Image/RCTGIFImageDecoder.mm index 2dd15a576ac408..a7d101b0825ca5 100644 --- a/Libraries/Image/RCTGIFImageDecoder.mm +++ b/Libraries/Image/RCTGIFImageDecoder.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageBlurUtils.h b/Libraries/Image/RCTImageBlurUtils.h index 18a286e65ed584..4edcf3f2fa2659 100644 --- a/Libraries/Image/RCTImageBlurUtils.h +++ b/Libraries/Image/RCTImageBlurUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageBlurUtils.m b/Libraries/Image/RCTImageBlurUtils.m index 3ba8c64eac85d6..d40cd2d0da5c25 100644 --- a/Libraries/Image/RCTImageBlurUtils.m +++ b/Libraries/Image/RCTImageBlurUtils.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,10 +22,13 @@ if (CGImageGetBitsPerPixel(imageRef) != 32 || CGImageGetBitsPerComponent(imageRef) != 8 || !((CGImageGetBitmapInfo(imageRef) & kCGBitmapAlphaInfoMask))) { - UIGraphicsBeginImageContextWithOptions(inputImage.size, NO, inputImage.scale); - [inputImage drawAtPoint:CGPointZero]; - imageRef = UIGraphicsGetImageFromCurrentImageContext().CGImage; - UIGraphicsEndImageContext(); + UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat]; + rendererFormat.scale = inputImage.scale; + UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:inputImage.size format:rendererFormat]; + + imageRef = [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { + [inputImage drawAtPoint:CGPointZero]; + }].CGImage; } vImage_Buffer buffer1, buffer2; @@ -51,7 +54,7 @@ //create temp buffer vImage_Error tempBufferSize = vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, - NULL, kvImageGetTempBufferSize | kvImageEdgeExtend); + NULL, kvImageGetTempBufferSize | kvImageEdgeExtend); if (tempBufferSize < 0) { free(buffer1.data); free(buffer2.data); diff --git a/Libraries/Image/RCTImageCache.h b/Libraries/Image/RCTImageCache.h index a4d15b4403c7c6..b85de924e221ad 100644 --- a/Libraries/Image/RCTImageCache.h +++ b/Libraries/Image/RCTImageCache.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -39,4 +39,7 @@ @end @interface RCTImageCache : NSObject + +RCT_EXTERN void RCTSetImageCacheLimits(NSUInteger maxCachableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit); + @end diff --git a/Libraries/Image/RCTImageCache.m b/Libraries/Image/RCTImageCache.m index 4c7b598d232dea..76e28cf947de08 100644 --- a/Libraries/Image/RCTImageCache.m +++ b/Libraries/Image/RCTImageCache.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,13 @@ #import -static const NSUInteger RCTMaxCachableDecodedImageSizeInBytes = 2097152; // 2 MB +static NSUInteger RCTMaxCachableDecodedImageSizeInBytes = 2*1024*1024; +static NSUInteger RCTImageCacheTotalCostLimit = 20*1024*1024; + +void RCTSetImageCacheLimits(NSUInteger maxCachableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit) { + RCTMaxCachableDecodedImageSizeInBytes = maxCachableDecodedImageSizeInBytes; + RCTImageCacheTotalCostLimit = imageCacheTotalCostLimit; +} static NSString *RCTCacheKeyForImage(NSString *imageTag, CGSize size, CGFloat scale, RCTResizeMode resizeMode) @@ -38,7 +44,7 @@ - (instancetype)init { if (self = [super init]) { _decodedImageCache = [NSCache new]; - _decodedImageCache.totalCostLimit = 20 * 1024 * 1024; // 20 MB + _decodedImageCache.totalCostLimit = RCTImageCacheTotalCostLimit; _cacheStaleTimes = [NSMutableDictionary new]; [[NSNotificationCenter defaultCenter] addObserver:self diff --git a/Libraries/Image/RCTImageDataDecoder.h b/Libraries/Image/RCTImageDataDecoder.h index b7fbb00d877a69..1d126aab5f893a 100644 --- a/Libraries/Image/RCTImageDataDecoder.h +++ b/Libraries/Image/RCTImageDataDecoder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageEditingManager.h b/Libraries/Image/RCTImageEditingManager.h index 216b622ac28b22..a155cbdfee00ba 100644 --- a/Libraries/Image/RCTImageEditingManager.h +++ b/Libraries/Image/RCTImageEditingManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageEditingManager.mm b/Libraries/Image/RCTImageEditingManager.mm index 47b2f60f849762..1f75fe3006f8d9 100644 --- a/Libraries/Image/RCTImageEditingManager.mm +++ b/Libraries/Image/RCTImageEditingManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageLoader.h b/Libraries/Image/RCTImageLoader.h index da0df284e6f6b8..c24d5ad384b372 100644 --- a/Libraries/Image/RCTImageLoader.h +++ b/Libraries/Image/RCTImageLoader.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 90bdfbb01296a0..85a1fbae64c4e1 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -40,7 +40,7 @@ void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled) static NSInteger RCTImageBytesForImage(UIImage *image) { - NSInteger singleImageBytes = image.size.width * image.size.height * image.scale * image.scale * 4; + NSInteger singleImageBytes = (NSInteger)(image.size.width * image.size.height * image.scale * image.scale * 4); return image.images ? image.images.count * singleImageBytes : singleImageBytes; } @@ -56,6 +56,15 @@ static uint64_t monotonicTimeGetCurrentNanoseconds(void) return (mach_absolute_time() * tb_info.numer) / tb_info.denom; } +static NSError* addResponseHeadersToError(NSError* originalError, NSHTTPURLResponse* response) { + NSMutableDictionary* _userInfo = (NSMutableDictionary*)originalError.userInfo.mutableCopy; + _userInfo[@"httpStatusCode"] = [NSNumber numberWithInt:response.statusCode]; + _userInfo[@"httpResponseHeaders"] = response.allHeaderFields; + NSError *error = [NSError errorWithDomain:originalError.domain code:originalError.code userInfo:_userInfo]; + + return error; +} + @interface RCTImageLoader() @end @@ -492,6 +501,16 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req BOOL cacheResult = [loadHandler respondsToSelector:@selector(shouldCacheLoadedImages)] ? [loadHandler shouldCacheLoadedImages] : YES; + if (cacheResult && partialLoadHandler) { + UIImage *image = [[self imageCache] imageForUrl:request.URL.absoluteString + size:size + scale:scale + resizeMode:resizeMode]; + if (image) { + partialLoadHandler(image); + } + } + auto cancelled = std::make_shared>(0); __block dispatch_block_t cancelLoad = nil; __block NSLock *cancelLoadLock = [NSLock new]; @@ -513,6 +532,10 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req } }); } else if (!std::atomic_load(cancelled.get())) { + if (response && error && [response isKindOfClass: [NSHTTPURLResponse class]]) { + NSHTTPURLResponse* _httpResp = (NSHTTPURLResponse*)response; + error = addResponseHeadersToError(error, _httpResp); + } completionBlock(error, imageOrData, imageMetadata, cacheResult, response); } }; @@ -614,7 +637,7 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req }); return [[RCTImageURLLoaderRequest alloc] initWithRequestId:requestId imageURL:request.URL cancellationBlock:^{ - BOOL alreadyCancelled = atomic_fetch_or(cancelled.get(), 1); + BOOL alreadyCancelled = atomic_fetch_or(cancelled.get(), 1) ? YES : NO; if (alreadyCancelled) { return; } @@ -754,7 +777,7 @@ - (RCTImageURLLoaderRequest *)loadImageWithURLRequest:(NSURLRequest *)imageURLRe __block dispatch_block_t cancelLoad = nil; __block NSLock *cancelLoadLock = [NSLock new]; dispatch_block_t cancellationBlock = ^{ - BOOL alreadyCancelled = atomic_fetch_or(cancelled.get(), 1); + BOOL alreadyCancelled = atomic_fetch_or(cancelled.get(), 1) ? YES : NO; if (alreadyCancelled) { return; } @@ -904,7 +927,7 @@ - (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)data } else { dispatch_block_t decodeBlock = ^{ // Calculate the size, in bytes, that the decompressed image will require - NSInteger decodedImageBytes = (size.width * scale) * (size.height * scale) * 4; + NSInteger decodedImageBytes = (NSInteger)((size.width * scale) * (size.height * scale) * 4); // Mark these bytes as in-use self->_activeBytes += decodedImageBytes; diff --git a/Libraries/Image/RCTImageLoaderLoggable.h b/Libraries/Image/RCTImageLoaderLoggable.h index 3b78c482bb5fa7..08507e7f6422db 100644 --- a/Libraries/Image/RCTImageLoaderLoggable.h +++ b/Libraries/Image/RCTImageLoaderLoggable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageLoaderProtocol.h b/Libraries/Image/RCTImageLoaderProtocol.h index f1bb2689607e9d..5e8f4f8b16fd2a 100644 --- a/Libraries/Image/RCTImageLoaderProtocol.h +++ b/Libraries/Image/RCTImageLoaderProtocol.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN * Use PriorityPrefetch to prefetch images at a lower priority. * The priority logic is up to each @RCTImageLoaderProtocol implementation */ -typedef NS_ENUM(NSUInteger, RCTImageLoaderPriority) { +typedef NS_ENUM(NSInteger, RCTImageLoaderPriority) { RCTImageLoaderPriorityImmediate, RCTImageLoaderPriorityPrefetch }; diff --git a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h index 07aab9d79544e3..1bdbe2eb87dbd3 100644 --- a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h +++ b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImagePlugins.h b/Libraries/Image/RCTImagePlugins.h index 1e943d8356061f..fb782692764ce6 100644 --- a/Libraries/Image/RCTImagePlugins.h +++ b/Libraries/Image/RCTImagePlugins.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImagePlugins.mm b/Libraries/Image/RCTImagePlugins.mm index 1e03e76066e244..e928330b611983 100644 --- a/Libraries/Image/RCTImagePlugins.mm +++ b/Libraries/Image/RCTImagePlugins.mm @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageShadowView.h b/Libraries/Image/RCTImageShadowView.h index 30571186c0fdc3..8333da31521b25 100644 --- a/Libraries/Image/RCTImageShadowView.h +++ b/Libraries/Image/RCTImageShadowView.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageShadowView.m b/Libraries/Image/RCTImageShadowView.m index 3438c68b89ceef..bfdad70f342d21 100644 --- a/Libraries/Image/RCTImageShadowView.m +++ b/Libraries/Image/RCTImageShadowView.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageStoreManager.h b/Libraries/Image/RCTImageStoreManager.h index 00733812725c30..389f613ea8afe1 100644 --- a/Libraries/Image/RCTImageStoreManager.h +++ b/Libraries/Image/RCTImageStoreManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageStoreManager.mm b/Libraries/Image/RCTImageStoreManager.mm index 22ea6547c81f20..c62ad09275372f 100644 --- a/Libraries/Image/RCTImageStoreManager.mm +++ b/Libraries/Image/RCTImageStoreManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageURLLoader.h b/Libraries/Image/RCTImageURLLoader.h index e49ed1118f326f..e8ceb26121a116 100644 --- a/Libraries/Image/RCTImageURLLoader.h +++ b/Libraries/Image/RCTImageURLLoader.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageURLLoaderWithAttribution.h b/Libraries/Image/RCTImageURLLoaderWithAttribution.h index 118bed138057e9..f417cdc79899bd 100644 --- a/Libraries/Image/RCTImageURLLoaderWithAttribution.h +++ b/Libraries/Image/RCTImageURLLoaderWithAttribution.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageURLLoaderWithAttribution.mm b/Libraries/Image/RCTImageURLLoaderWithAttribution.mm index 61baa4aafee979..1ba2d8964a05d3 100644 --- a/Libraries/Image/RCTImageURLLoaderWithAttribution.mm +++ b/Libraries/Image/RCTImageURLLoaderWithAttribution.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageUtils.h b/Libraries/Image/RCTImageUtils.h index df04a2c3bb6956..5763b04dfbfa7e 100644 --- a/Libraries/Image/RCTImageUtils.h +++ b/Libraries/Image/RCTImageUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageUtils.m b/Libraries/Image/RCTImageUtils.m index 899bfe4fc61bab..2724a3d6c0eab8 100644 --- a/Libraries/Image/RCTImageUtils.m +++ b/Libraries/Image/RCTImageUtils.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -370,13 +370,14 @@ BOOL RCTUpscalingRequired(CGSize sourceSize, CGFloat sourceScale, } BOOL opaque = !RCTImageHasAlpha(image.CGImage); - UIGraphicsBeginImageContextWithOptions(destSize, opaque, destScale); - CGContextRef currentContext = UIGraphicsGetCurrentContext(); - CGContextConcatCTM(currentContext, transform); - [image drawAtPoint:CGPointZero]; - UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return result; + UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat]; + rendererFormat.opaque = opaque; + rendererFormat.scale = destScale; + UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:destSize format:rendererFormat]; + return [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { + CGContextConcatCTM(context.CGContext, transform); + [image drawAtPoint:CGPointZero]; + }]; } BOOL RCTImageHasAlpha(CGImageRef image) diff --git a/Libraries/Image/RCTImageView.h b/Libraries/Image/RCTImageView.h index c895a538e4da0e..c5057fc8db155a 100644 --- a/Libraries/Image/RCTImageView.h +++ b/Libraries/Image/RCTImageView.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageView.mm b/Libraries/Image/RCTImageView.mm index 60a46555378f78..410f21b73aa7bd 100644 --- a/Libraries/Image/RCTImageView.mm +++ b/Libraries/Image/RCTImageView.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -234,7 +234,7 @@ - (void)cancelAndClearImageLoad [_imageLoader trackURLImageRequestDidDestroy:_loaderRequest]; _loaderRequest = nil; - + if (!self.image) { self.image = _defaultImage; } @@ -313,9 +313,10 @@ - (void)reloadImage } RCTImageLoaderProgressBlock progressHandler = nil; - if (_onProgress) { + if (self.onProgress) { + RCTDirectEventBlock onProgress = self.onProgress; progressHandler = ^(int64_t loaded, int64_t total) { - self->_onProgress(@{ + onProgress(@{ @"loaded": @((double)loaded), @"total": @((double)total), }); @@ -371,12 +372,13 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage error:(NSError *)error for } if (error) { + __weak RCTImageView *weakSelf = self; RCTExecuteOnMainQueue(^{ - self.image = nil; + weakSelf.image = nil; }); if (_onError) { - _onError(@{ @"error": error.localizedDescription }); + _onError(@{ @"error": error.localizedDescription, @"responseCode": (error.userInfo[@"httpStatusCode"]?: [NSNull null]), @"httpResponseHeaders": (error.userInfo[@"httpResponseHeaders"] ?: [NSNull null]) }); } if (_onLoadEnd) { _onLoadEnd(nil); @@ -384,33 +386,39 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage error:(NSError *)error for return; } + __weak RCTImageView *weakSelf = self; void (^setImageBlock)(UIImage *) = ^(UIImage *image) { + RCTImageView *strongSelf = weakSelf; + if (!strongSelf) { + return; + } if (!isPartialLoad) { - self->_imageSource = source; - self->_pendingImageSource = nil; + strongSelf->_imageSource = source; + strongSelf->_pendingImageSource = nil; } - self.image = image; + strongSelf.image = image; if (isPartialLoad) { - if (self->_onPartialLoad) { - self->_onPartialLoad(nil); + if (strongSelf->_onPartialLoad) { + strongSelf->_onPartialLoad(nil); } } else { - if (self->_onLoad) { + if (strongSelf->_onLoad) { RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:source.scale]; - self->_onLoad(onLoadParamsForSource(sourceLoaded)); + strongSelf->_onLoad(onLoadParamsForSource(sourceLoaded)); } - if (self->_onLoadEnd) { - self->_onLoadEnd(nil); + if (strongSelf->_onLoadEnd) { + strongSelf->_onLoadEnd(nil); } } }; if (_blurRadius > __FLT_EPSILON__) { // Blur on a background thread to avoid blocking interaction + CGFloat blurRadius = self.blurRadius; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - UIImage *blurredImage = RCTBlurredImageWithRadius(loadedImage, self->_blurRadius); + UIImage *blurredImage = RCTBlurredImageWithRadius(loadedImage, blurRadius); RCTExecuteOnMainQueue(^{ setImageBlock(blurredImage); }); diff --git a/Libraries/Image/RCTImageViewManager.h b/Libraries/Image/RCTImageViewManager.h index 9431f355d0c1b1..8202aab1d38c9a 100644 --- a/Libraries/Image/RCTImageViewManager.h +++ b/Libraries/Image/RCTImageViewManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTImageViewManager.mm b/Libraries/Image/RCTImageViewManager.mm index 32025234688894..cbf0d4eee953f8 100644 --- a/Libraries/Image/RCTImageViewManager.mm +++ b/Libraries/Image/RCTImageViewManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTLocalAssetImageLoader.h b/Libraries/Image/RCTLocalAssetImageLoader.h index c04f21e129539b..453accef355c48 100644 --- a/Libraries/Image/RCTLocalAssetImageLoader.h +++ b/Libraries/Image/RCTLocalAssetImageLoader.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTLocalAssetImageLoader.mm b/Libraries/Image/RCTLocalAssetImageLoader.mm index 9cb0d46b1b0008..ec1527c6fbbd03 100644 --- a/Libraries/Image/RCTLocalAssetImageLoader.mm +++ b/Libraries/Image/RCTLocalAssetImageLoader.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTResizeMode.h b/Libraries/Image/RCTResizeMode.h index 468a58a84c4211..322ce53d0b939e 100644 --- a/Libraries/Image/RCTResizeMode.h +++ b/Libraries/Image/RCTResizeMode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTResizeMode.m b/Libraries/Image/RCTResizeMode.m index fccbd637866228..75d7ecefa86737 100644 --- a/Libraries/Image/RCTResizeMode.m +++ b/Libraries/Image/RCTResizeMode.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTUIImageViewAnimated.h b/Libraries/Image/RCTUIImageViewAnimated.h index 9af8d4e943e11f..1215e21b2d641b 100644 --- a/Libraries/Image/RCTUIImageViewAnimated.h +++ b/Libraries/Image/RCTUIImageViewAnimated.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/RCTUIImageViewAnimated.m b/Libraries/Image/RCTUIImageViewAnimated.m index b10db4da68e18d..9e1cd1eb5c477b 100644 --- a/Libraries/Image/RCTUIImageViewAnimated.m +++ b/Libraries/Image/RCTUIImageViewAnimated.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -298,7 +298,7 @@ - (void)calculateMaxBufferCount // Calculate based on current memory, these factors are by experience NSUInteger total = RCTDeviceTotalMemory(); NSUInteger free = RCTDeviceFreeMemory(); - max = MIN(total * 0.2, free * 0.6); + max = MIN((double)total * 0.2, (double)free * 0.6); } NSUInteger maxBufferCount = (double)max / (double)bytes; diff --git a/Libraries/Image/React-RCTImage.podspec b/Libraries/Image/React-RCTImage.podspec index d7c4a313ad10e2..614245a225300d 100644 --- a/Libraries/Image/React-RCTImage.podspec +++ b/Libraries/Image/React-RCTImage.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' Pod::Spec.new do |s| s.name = "React-RCTImage" @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.documentation_url = "https://reactnative.dev/docs/image" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source s.source_files = "*.{m,mm}" @@ -35,8 +35,8 @@ Pod::Spec.new do |s| s.header_dir = "RCTImage" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"" + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\"" } s.dependency "RCT-Folly", folly_version diff --git a/Libraries/Image/RelativeImageStub.js b/Libraries/Image/RelativeImageStub.js index 3303143d933780..c8cf0f4da4418c 100644 --- a/Libraries/Image/RelativeImageStub.js +++ b/Libraries/Image/RelativeImageStub.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/TextInlineImageNativeComponent.js b/Libraries/Image/TextInlineImageNativeComponent.js index 6e6cddbc822d8c..2ba778b217cc15 100644 --- a/Libraries/Image/TextInlineImageNativeComponent.js +++ b/Libraries/Image/TextInlineImageNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,91 +10,41 @@ 'use strict'; -import type {ResolvedAssetSource} from './AssetSourceResolver'; -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; -import type {ImageProps} from './ImageProps'; +import type { + HostComponent, + PartialViewConfig, +} from '../Renderer/shims/ReactNativeTypes'; import type {ViewProps} from '../Components/View/ViewPropTypes'; +import type {ImageResizeMode} from './ImageResizeMode'; import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry'; -import type { - ColorValue, - DangerouslyImpreciseStyle, - ImageStyleProp, -} from '../StyleSheet/StyleSheet'; +import type {ColorValue} from '../StyleSheet/StyleSheet'; -type Props = $ReadOnly<{ - ...ImageProps, +type NativeProps = $ReadOnly<{ ...ViewProps, - - style?: ImageStyleProp | DangerouslyImpreciseStyle, - - // iOS native props - tintColor?: ColorValue, - - // Android native props - shouldNotifyLoadEvents?: boolean, - src?: ?ResolvedAssetSource | $ReadOnlyArray<{uri: string, ...}>, - headers?: ?string, - defaultSrc?: ?string, - loadingIndicatorSrc?: ?string, - internal_analyticTag?: ?string, + resizeMode?: ?ImageResizeMode, + src?: ?$ReadOnlyArray>, + tintColor?: ?ColorValue, + headers?: ?{[string]: string}, }>; -const TextInlineImage: HostComponent = - NativeComponentRegistry.get('RCTTextInlineImage', () => ({ - uiViewClassName: 'RCTImageView', - bubblingEventTypes: {}, - directEventTypes: { - topLoadStart: { - registrationName: 'onLoadStart', - }, - topProgress: { - registrationName: 'onProgress', - }, - topError: { - registrationName: 'onError', - }, - topPartialLoad: { - registrationName: 'onPartialLoad', - }, - topLoad: { - registrationName: 'onLoad', - }, - topLoadEnd: { - registrationName: 'onLoadEnd', - }, - }, - validAttributes: { - blurRadius: true, - capInsets: { - diff: require('../Utilities/differ/insetsDiffer'), - }, - defaultSource: { - process: require('./resolveAssetSource'), - }, - defaultSrc: true, - fadeDuration: true, - headers: true, - internal_analyticTag: true, - loadingIndicatorSrc: true, - onError: true, - onLoad: true, - onLoadEnd: true, - onLoadStart: true, - onPartialLoad: true, - onProgress: true, - overlayColor: { - process: require('../StyleSheet/processColor'), - }, - progressiveRenderingEnabled: true, - resizeMethod: true, - resizeMode: true, - shouldNotifyLoadEvents: true, - source: true, - src: true, - tintColor: { - process: require('../StyleSheet/processColor'), - }, +export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = { + uiViewClassName: 'RCTTextInlineImage', + bubblingEventTypes: {}, + directEventTypes: {}, + validAttributes: { + resizeMode: true, + src: true, + tintColor: { + process: require('../StyleSheet/processColor'), }, - })); + headers: true, + }, +}; + +const TextInlineImage: HostComponent = + NativeComponentRegistry.get( + 'RCTTextInlineImage', + () => __INTERNAL_VIEW_CONFIG, + ); -module.exports = TextInlineImage; +export default TextInlineImage; diff --git a/Libraries/Image/__tests__/AssetUtils-test.js b/Libraries/Image/__tests__/AssetUtils-test.js index f1cbe77e535408..4da66686a28d0b 100644 --- a/Libraries/Image/__tests__/AssetUtils-test.js +++ b/Libraries/Image/__tests__/AssetUtils-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/__tests__/Image-test.js b/Libraries/Image/__tests__/Image-test.js index 3e9302d7c8209a..eec7d4b3c6bbe7 100644 --- a/Libraries/Image/__tests__/Image-test.js +++ b/Libraries/Image/__tests__/Image-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/__tests__/assetRelativePathInSnapshot-test.js b/Libraries/Image/__tests__/assetRelativePathInSnapshot-test.js index 618d706123c27d..a3b6ae47b93b95 100644 --- a/Libraries/Image/__tests__/assetRelativePathInSnapshot-test.js +++ b/Libraries/Image/__tests__/assetRelativePathInSnapshot-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/__tests__/resolveAssetSource-test.js b/Libraries/Image/__tests__/resolveAssetSource-test.js index 2fc46ed6f59fdf..364fb779a54758 100644 --- a/Libraries/Image/__tests__/resolveAssetSource-test.js +++ b/Libraries/Image/__tests__/resolveAssetSource-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Image/nativeImageSource.js b/Libraries/Image/nativeImageSource.js index 65a3169c50c931..c6272c8e43ab88 100644 --- a/Libraries/Image/nativeImageSource.js +++ b/Libraries/Image/nativeImageSource.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,7 @@ type NativeImageSourceSpec = $ReadOnly<{| default?: string, // For more details on width and height, see - // https://reactnative.dev/docs/images.html#why-not-automatically-size-everything + // https://reactnative.dev/docs/images#why-not-automatically-size-everything height: number, width: number, |}>; @@ -36,7 +36,7 @@ type NativeImageSourceSpec = $ReadOnly<{| * automates measurements and allows adding new images without rebuilding the * native app. For more details visit: * - * https://reactnative.dev/docs/images.html + * https://reactnative.dev/docs/images * */ function nativeImageSource(spec: NativeImageSourceSpec): ImageURISource { diff --git a/Libraries/Image/resolveAssetSource.js b/Libraries/Image/resolveAssetSource.js index fe8e543e1ff91e..40ea0f0f9e9a90 100644 --- a/Libraries/Image/resolveAssetSource.js +++ b/Libraries/Image/resolveAssetSource.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Inspector/BorderBox.js b/Libraries/Inspector/BorderBox.js index 886beb784d5922..c178f25ff51ae5 100644 --- a/Libraries/Inspector/BorderBox.js +++ b/Libraries/Inspector/BorderBox.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Inspector/BoxInspector.js b/Libraries/Inspector/BoxInspector.js index e1002f568ca0f4..1cc41c173800de 100644 --- a/Libraries/Inspector/BoxInspector.js +++ b/Libraries/Inspector/BoxInspector.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/Libraries/Inspector/ElementBox.js b/Libraries/Inspector/ElementBox.js index 07684d2204d169..738be209c6bffd 100644 --- a/Libraries/Inspector/ElementBox.js +++ b/Libraries/Inspector/ElementBox.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,7 +26,7 @@ class ElementBox extends React.Component<$FlowFixMeProps> { let padding = resolveBoxStyle('padding', style); const frameStyle = {...this.props.frame}; - const contentStyle = { + const contentStyle: {width: number, height: number} = { width: this.props.frame.width, height: this.props.frame.height, }; @@ -102,7 +102,7 @@ type Style = { * @return a modified copy */ function resolveRelativeSizes(style: $ReadOnly - - diff --git a/ReactAndroid/src/main/res/views/uimanager/values/ids.xml b/ReactAndroid/src/main/res/views/uimanager/values/ids.xml index 8fe4be952af418..405ca4d7af9dbc 100644 --- a/ReactAndroid/src/main/res/views/uimanager/values/ids.xml +++ b/ReactAndroid/src/main/res/views/uimanager/values/ids.xml @@ -15,6 +15,12 @@ + + + + + + @@ -27,12 +33,21 @@ + + + + + + + + + diff --git a/ReactAndroid/src/main/third-party/android/androidx/BUCK b/ReactAndroid/src/main/third-party/android/androidx/BUCK index d8398497d33652..8bea0a99bf3a6c 100644 --- a/ReactAndroid/src/main/third-party/android/androidx/BUCK +++ b/ReactAndroid/src/main/third-party/android/androidx/BUCK @@ -12,6 +12,7 @@ fb_native.android_library( exported_deps = [ ":annotation", ":appcompat-binary", + ":appcompat-resources-binary", ":collection", ":core", ":cursoradapter", @@ -365,6 +366,11 @@ fb_native.android_prebuilt_aar( aar = ":appcompat-binary-aar", ) +fb_native.android_prebuilt_aar( + name = "appcompat-resources-binary", + aar = ":appcompat-resources-binary-aar", +) + fb_native.android_prebuilt_aar( name = "asynclayoutinflater-binary", aar = ":asynclayoutinflater-binary-aar", @@ -534,8 +540,14 @@ fb_native.remote_file( fb_native.remote_file( name = "appcompat-binary-aar", - sha1 = "002533a36c928bb27a3cc6843a25f83754b3c3ae", - url = "mvn:androidx.appcompat:appcompat:aar:1.0.2", + sha1 = "d384d125d196ed4997b418d7ba6fc18a4680ed22", + url = "mvn:androidx.appcompat:appcompat:aar:1.4.1", +) + +fb_native.remote_file( + name = "appcompat-resources-binary-aar", + sha1 = "527d93d44bb18bc7dcf5213df8d4d069f0ceff61", + url = "mvn:androidx.appcompat:appcompat-resources:aar:1.4.1", ) fb_native.remote_file( @@ -558,8 +570,8 @@ fb_native.remote_file( fb_native.remote_file( name = "core-binary-aar", - sha1 = "263deba7f9c24bd0cefb93c0aaaf402cc50828ee", - url = "mvn:androidx.core:core:aar:1.0.1", + sha1 = "b26edc58f29ca0671e60828a68582760f880acdd", + url = "mvn:androidx.core:core:aar:1.7.0", ) fb_native.remote_file( diff --git a/ReactAndroid/src/main/third-party/java/asm/BUCK b/ReactAndroid/src/main/third-party/java/asm/BUCK index 5741e1c0ea7998..2e4b5dedb8001f 100644 --- a/ReactAndroid/src/main/third-party/java/asm/BUCK +++ b/ReactAndroid/src/main/third-party/java/asm/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "asm", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":asm-analysis", diff --git a/ReactAndroid/src/main/third-party/java/assertj/BUCK b/ReactAndroid/src/main/third-party/java/assertj/BUCK new file mode 100644 index 00000000000000..41dd6918984c4d --- /dev/null +++ b/ReactAndroid/src/main/third-party/java/assertj/BUCK @@ -0,0 +1,14 @@ +load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") +load("//tools/build_defs/oss:rn_defs.bzl", "rn_prebuilt_jar") + +rn_prebuilt_jar( + name = "assertj-core", + binary_jar = ":assertj-core.jar", + visibility = ["//ReactAndroid/..."], +) + +fb_native.remote_file( + name = "assertj-core.jar", + sha1 = "27a14d6d22c4e3d58f799fb2a5ca8eaf53e6942a", + url = "mvn:org.assertj:assertj-core:jar:3.21.0", +) diff --git a/ReactAndroid/src/main/third-party/java/fest/BUCK b/ReactAndroid/src/main/third-party/java/fest/BUCK deleted file mode 100644 index 50285d715060a0..00000000000000 --- a/ReactAndroid/src/main/third-party/java/fest/BUCK +++ /dev/null @@ -1,36 +0,0 @@ -load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") -load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_jar") - -rn_android_library( - name = "fest", - autoglob = False, - visibility = ["//ReactAndroid/..."], - exported_deps = [ - ":fest-core", - ":fest-util", - ], -) - -rn_prebuilt_jar( - name = "fest-core", - binary_jar = ":fest-binary.jar", - visibility = ["//ReactAndroid/..."], -) - -fb_native.remote_file( - name = "fest-binary.jar", - sha1 = "cb7c91cf614901928ae405f19d9bcdedf82781db", - url = "mvn:org.easytesting:fest-assert-core:jar:2.0M10", -) - -rn_prebuilt_jar( - name = "fest-util", - binary_jar = ":fest-util-binary.jar", - visibility = ["//ReactAndroid/..."], -) - -fb_native.remote_file( - name = "fest-util-binary.jar", - sha1 = "c4a8d7305b23b8d043be12c979813b096df11f44", - url = "mvn:org.easytesting:fest-util:jar:1.2.5", -) diff --git a/ReactAndroid/src/main/third-party/java/junit/BUCK b/ReactAndroid/src/main/third-party/java/junit/BUCK index 555a01989f107f..0598146bd093ad 100644 --- a/ReactAndroid/src/main/third-party/java/junit/BUCK +++ b/ReactAndroid/src/main/third-party/java/junit/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "junit", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":hamcrest", diff --git a/ReactAndroid/src/main/third-party/java/mockito/BUCK b/ReactAndroid/src/main/third-party/java/mockito/BUCK index 9fda3bf174d9d6..0d4f87f04006ba 100644 --- a/ReactAndroid/src/main/third-party/java/mockito/BUCK +++ b/ReactAndroid/src/main/third-party/java/mockito/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "mockito", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":mockito-core", diff --git a/ReactAndroid/src/main/third-party/java/mockito2/BUCK b/ReactAndroid/src/main/third-party/java/mockito2/BUCK index b5332e4f2ec559..6e1e71c9292cce 100644 --- a/ReactAndroid/src/main/third-party/java/mockito2/BUCK +++ b/ReactAndroid/src/main/third-party/java/mockito2/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "mockito2", autoglob = False, + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":byte-buddy", diff --git a/ReactAndroid/src/main/third-party/java/okhttp/BUCK b/ReactAndroid/src/main/third-party/java/okhttp/BUCK index 62813049874d1f..a246892ab4717f 100644 --- a/ReactAndroid/src/main/third-party/java/okhttp/BUCK +++ b/ReactAndroid/src/main/third-party/java/okhttp/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_android_library( name = "okhttp3", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":okhttp3-binary", @@ -16,6 +17,7 @@ rn_android_library( rn_android_library( name = "okhttp3-urlconnection", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":okhttp3", @@ -30,8 +32,8 @@ rn_prebuilt_jar( fb_native.remote_file( name = "okhttp3-binary.jar", - sha1 = "51215279c3fe472c59b6b7dd7491e6ac2e28a81b", - url = "mvn:com.squareup.okhttp3:okhttp:jar:4.9.1", + sha1 = "5302714ee9320b64cf65ed865e5f65981ef9ba46", + url = "mvn:com.squareup.okhttp3:okhttp:jar:4.9.2", ) rn_prebuilt_jar( @@ -41,6 +43,6 @@ rn_prebuilt_jar( fb_native.remote_file( name = "okhttp3-urlconnection-binary.jar", - sha1 = "f45e809215bd0961350148cf5b78707865084e6f", - url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:4.9.1", + sha1 = "3b9e64d3d56370bc7488ed8b336d17a8013cb336", + url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:4.9.2", ) diff --git a/ReactAndroid/src/main/third-party/java/okio/BUCK b/ReactAndroid/src/main/third-party/java/okio/BUCK index 9f5ff9a60a1ee4..d3d83bacc5ca7d 100644 --- a/ReactAndroid/src/main/third-party/java/okio/BUCK +++ b/ReactAndroid/src/main/third-party/java/okio/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_target", "rn_android_li rn_android_library( name = "okio", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":okio-binary", diff --git a/ReactAndroid/src/main/third-party/java/robolectric/BUCK b/ReactAndroid/src/main/third-party/java/robolectric/BUCK index 39db5c323fe735..f2d67b79b50142 100644 --- a/ReactAndroid/src/main/third-party/java/robolectric/BUCK +++ b/ReactAndroid/src/main/third-party/java/robolectric/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra rn_android_library( name = "robolectric", autoglob = False, + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":android-all-5.0.2_r3-robolectric-r0", diff --git a/ReactAndroid/src/main/third-party/java/sqlite/BUCK b/ReactAndroid/src/main/third-party/java/sqlite/BUCK index f93cb4833b10b5..492ba08c6a5d86 100644 --- a/ReactAndroid/src/main/third-party/java/sqlite/BUCK +++ b/ReactAndroid/src/main/third-party/java/sqlite/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "sqlite", autoglob = False, + language = "JAVA", visibility = ["//ReactAndroid/..."], exported_deps = [ ":sqlite4java", diff --git a/ReactAndroid/src/main/third-party/kotlin/BUCK b/ReactAndroid/src/main/third-party/kotlin/BUCK index caad9d63e62805..c1d09721a55377 100644 --- a/ReactAndroid/src/main/third-party/kotlin/BUCK +++ b/ReactAndroid/src/main/third-party/kotlin/BUCK @@ -3,6 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "kotlin-stdlib", + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":jetbrains-annotations", @@ -13,6 +14,7 @@ rn_android_library( rn_android_library( name = "kotlin-stdlib-jdk7", + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":kotlin-stdlib", @@ -22,6 +24,7 @@ rn_android_library( rn_android_library( name = "kotlin-stdlib-jdk8", + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":kotlin-stdlib", @@ -32,28 +35,16 @@ rn_android_library( rn_prebuilt_jar( name = "jetbrains-annotations", - binary_jar = ":jetbrains-annotations.jar", + binary_jar = ":annotations-13.0.jar", visibility = ["//ReactAndroid/..."], ) -fb_native.remote_file( - name = "jetbrains-annotations.jar", - sha1 = "919f0dfe192fb4e063e7dacadee7f8bb9a2672a9", - url = "mvn:org.jetbrains:annotations:jar:13.0", -) - rn_prebuilt_jar( name = "kotlin-stdlib-binary", - binary_jar = ":kotlin-stdlib-binary.jar", + binary_jar = ":kotlin-stdlib.jar", visibility = ["//ReactAndroid/..."], ) -fb_native.remote_file( - name = "kotlin-stdlib-binary.jar", - sha1 = "ea29e063d2bbe695be13e9d044dcfb0c7add398e", - url = "mvn:org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.10", -) - rn_prebuilt_jar( name = "kotlin-stdlib-common", binary_jar = ":kotlin-stdlib-common.jar", @@ -62,30 +53,96 @@ rn_prebuilt_jar( fb_native.remote_file( name = "kotlin-stdlib-common.jar", - sha1 = "6229be3465805c99db1142ad75e6c6ddeac0b04c", - url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.10", + sha1 = "0c118700e3a33c8a0d9adc920e9dec0831171925", + url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.6.10", ) rn_prebuilt_jar( name = "kotlin-stdlib-jdk7-binary", - binary_jar = ":kotlin-stdlib-jdk7-binary.jar", + binary_jar = ":kotlin-stdlib-jdk7.jar", visibility = ["//ReactAndroid/..."], ) fb_native.remote_file( - name = "kotlin-stdlib-jdk7-binary.jar", - sha1 = "30e46450b0bb3dbf43898d2f461be4a942784780", - url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.4.10", + name = "kotlin-stdlib-jdk7.jar", + sha1 = "e1c380673654a089c4f0c9f83d0ddfdc1efdb498", + url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.6.10", ) rn_prebuilt_jar( name = "kotlin-stdlib-jdk8-binary", - binary_jar = ":kotlin-stdlib-jdk8-binary.jar", + binary_jar = ":kotlin-stdlib-jdk8.jar", visibility = ["//ReactAndroid/..."], ) fb_native.remote_file( - name = "kotlin-stdlib-jdk8-binary.jar", - sha1 = "998caa30623f73223194a8b657abd2baec4880ea", - url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.4.10", + name = "kotlin-stdlib-jdk8.jar", + sha1 = "e80fe6ac3c3573a80305f5ec43f86b829e8ab53d", + url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.6.10", +) + +fb_native.genrule( + name = "kotlin-compiler-download", + type = "copy", + srcs = [ + ":annotations-13.0.jar", + ":kotlin-annotation-processing.jar", + ":kotlin-compiler.jar", + ":kotlin-compiler-embeddable.jar", + ":kotlin-reflect.jar", + ":kotlin-script-runtime.jar", + ":kotlin-stdlib.jar", + ":trove4j.jar", + ], + cmd = "mkdir ${OUT} && cp ${SRCS} ${OUT}", + cmd_exe = "@powershell -Command Copy-Item '${SRCS}' '${OUT}'", + out = "kotlin-compiler-out", +) + +fb_native.remote_file( + name = "kotlin-compiler-embeddable.jar", + sha1 = "88f2073f4020cdb83132cfe940ceb9a60aba54ea", + url = "mvn:org.jetbrains.kotlin:kotlin-compiler-embeddable:jar:1.6.10", +) + +fb_native.remote_file( + name = "kotlin-compiler.jar", + sha1 = "d3e2482aae0dfd96eb51054c8845963b9cbcf49f", + url = "mvn:org.jetbrains.kotlin:kotlin-compiler:jar:1.6.10", +) + +fb_native.remote_file( + name = "kotlin-annotation-processing.jar", + sha1 = "bdc1313091f9bd04c1d965c9fda16c214f9f27fc", + url = "mvn:org.jetbrains.kotlin:kotlin-annotation-processing:jar:1.6.10", +) + +fb_native.remote_file( + name = "kotlin-reflect.jar", + sha1 = "1cbe9c92c12a94eea200d23c2bbaedaf3daf5132", + url = "mvn:org.jetbrains.kotlin:kotlin-reflect:jar:1.6.10", +) + +fb_native.remote_file( + name = "kotlin-script-runtime.jar", + sha1 = "d0a7ff2e2500ef497ed0214ae40ad3c8387a6164", + url = "mvn:org.jetbrains.kotlin:kotlin-script-runtime:jar:1.6.10", +) + +fb_native.remote_file( + name = "kotlin-stdlib.jar", + sha1 = "b8af3fe6f1ca88526914929add63cf5e7c5049af", + url = "mvn:org.jetbrains.kotlin:kotlin-stdlib:jar:1.6.10", +) + +fb_native.remote_file( + name = "trove4j.jar", + sha1 = "3afb14d5f9ceb459d724e907a21145e8ff394f02", + url = "mvn:org.jetbrains.intellij.deps:trove4j:jar:1.0.20200330", +) + +fb_native.remote_file( + name = "annotations-13.0.jar", + sha1 = "919f0dfe192fb4e063e7dacadee7f8bb9a2672a9", + url = "mvn:org.jetbrains:annotations:jar:13.0", ) diff --git a/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK b/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK index 71326c7077e3b6..3a8b7585a4448a 100644 --- a/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/common/logging/BUCK @@ -4,6 +4,7 @@ rn_android_library( name = "logging", srcs = glob(["**/*.java"]), autoglob = False, + language = "JAVA", visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/test/java/com/facebook/common/logging/FakeLoggingDelegate.java b/ReactAndroid/src/test/java/com/facebook/common/logging/FakeLoggingDelegate.java index 1508886d385085..abfc9546daf129 100644 --- a/ReactAndroid/src/test/java/com/facebook/common/logging/FakeLoggingDelegate.java +++ b/ReactAndroid/src/test/java/com/facebook/common/logging/FakeLoggingDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/BUCK b/ReactAndroid/src/test/java/com/facebook/react/BUCK index 036fe8a98d8bfb..b6adefeaaba221 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/BUCK @@ -4,6 +4,7 @@ rn_robolectric_test( name = "react", srcs = glob(["*.java"]), contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", deps = [ YOGA_TARGET, react_native_dep("third-party/android/androidx:annotation"), @@ -11,7 +12,7 @@ rn_robolectric_test( react_native_dep("third-party/android/androidx:fragment"), react_native_dep("third-party/android/androidx:legacy-support-core-ui"), react_native_dep("third-party/android/androidx:legacy-support-core-utils"), - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java b/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java index 266fda794d1daf..e641e254e3f0de 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt b/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt new file mode 100644 index 00000000000000..3cad72ef2afdd1 --- /dev/null +++ b/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt @@ -0,0 +1,62 @@ +/* + * 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. + */ + +package com.facebook.react + +import android.os.Bundle +import org.junit.Assert.* +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +class ReactActivityDelegateTest { + + @Test + fun delegateWithConcurrentRoot_populatesInitialPropsCorrectly() { + val delegate = + object : ReactActivityDelegate(null, "test-delegate") { + override fun isConcurrentRootEnabled() = true + public val inspectLaunchOptions: Bundle? + get() = getLaunchOptions() + } + + assertNotNull(delegate.inspectLaunchOptions) + assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot")) + assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot")) + } + + @Test + fun delegateWithoutConcurrentRoot_hasNullInitialProperties() { + val delegate = + object : ReactActivityDelegate(null, "test-delegate") { + override fun isConcurrentRootEnabled() = false + public val inspectLaunchOptions: Bundle? + get() = getLaunchOptions() + } + + assertNull(delegate.inspectLaunchOptions) + } + + @Test + fun delegateWithConcurrentRoot_composesInitialPropertiesCorrectly() { + val delegate = + object : ReactActivityDelegate(null, "test-delegate") { + override fun isConcurrentRootEnabled() = true + override fun getLaunchOptions(): Bundle = + Bundle().apply { putString("test-property", "test-value") } + public val inspectLaunchOptions: Bundle? + get() = getLaunchOptions() + } + + assertNotNull(delegate.inspectLaunchOptions) + assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot")) + assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot")) + assertTrue(delegate.inspectLaunchOptions!!.containsKey("test-property")) + assertEquals("test-value", delegate.inspectLaunchOptions!!.getString("test-property")) + } +} diff --git a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java index 6389c29d7179a9..f4a57fe1663d1c 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; diff --git a/ReactAndroid/src/test/java/com/facebook/react/animated/BUCK b/ReactAndroid/src/test/java/com/facebook/react/animated/BUCK index c25e292d64b382..4a4a66cc6f45d3 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/animated/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/animated/BUCK @@ -4,11 +4,12 @@ rn_robolectric_test( name = "animated", srcs = glob(["**/*.java"]), contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_target("java/com/facebook/react:react"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.java b/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.java index c06e763a8ce3f6..4bf4cb3d332d4d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedInterpolationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.animated; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java b/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java index 8c624bb62a71df..4a77639eec142e 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.animated; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK index c89522bca2fc88..7bb8b24c8e41f4 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK @@ -11,6 +11,7 @@ rn_android_library( exclude = STANDARD_TEST_SRCS, ), autoglob = False, + language = "JAVA", visibility = [ "PUBLIC", ], @@ -27,13 +28,14 @@ rn_robolectric_test( name = "bridge", srcs = glob(STANDARD_TEST_SRCS), contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ ":testhelpers", react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_target("java/com/facebook/react/bridge:bridge"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java index d5b89b2465147c..27537562e590a4 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/FallbackJSBundleLoaderTest.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/FallbackJSBundleLoaderTest.java index 3778d3844c08d8..7c877bff8423b0 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/FallbackJSBundleLoaderTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/FallbackJSBundleLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ package com.facebook.react.bridge; -import static org.fest.assertions.api.Assertions.assertThat; -import static org.fest.assertions.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/InstanceHandleHelper.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/InstanceHandleHelper.java index bfa603245b7900..1b56926b2dc31c 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/InstanceHandleHelper.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/InstanceHandleHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaOnlyArrayTest.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaOnlyArrayTest.java index ce9fa5c3552470..6421ae2a5985da 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaOnlyArrayTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaOnlyArrayTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.bridge; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaScriptModuleRegistryTest.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaScriptModuleRegistryTest.java index 47b8614c30919e..79abb47f6ac9e1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaScriptModuleRegistryTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/JavaScriptModuleRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.java b/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.java index d3ab1b7fe70e5b..717b689a2b04af 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.java +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/ReactTestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/devsupport/BUCK b/ReactAndroid/src/test/java/com/facebook/react/devsupport/BUCK index 6fd2c2c49f5601..4e0f5b811cb137 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/devsupport/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/devsupport/BUCK @@ -4,11 +4,12 @@ rn_robolectric_test( name = "devsupport", srcs = glob(["**/*.java"]), contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java b/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java index 53a1340330911a..ba1511ee9ae611 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.java b/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.java index 03ab628fbe7990..63612bc66d5ff4 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/devsupport/MultipartStreamReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.devsupport; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.util.Map; diff --git a/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.java b/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.java index b91f6bc3d89d3b..a0e26087336374 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.devsupport; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import com.facebook.react.devsupport.interfaces.StackFrame; import org.junit.Test; diff --git a/ReactAndroid/src/test/java/com/facebook/react/fabric/events/BUCK b/ReactAndroid/src/test/java/com/facebook/react/fabric/events/BUCK new file mode 100644 index 00000000000000..7fe0aac8ac70cb --- /dev/null +++ b/ReactAndroid/src/test/java/com/facebook/react/fabric/events/BUCK @@ -0,0 +1,17 @@ +load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_robolectric_test") + +rn_robolectric_test( + name = "events", + srcs = glob(["*.java"]), + contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", + deps = [ + react_native_dep("third-party/java/jsr-305:jsr-305"), + react_native_dep("third-party/java/junit:junit"), + react_native_target("java/com/facebook/react:react"), + react_native_target("java/com/facebook/react/bridge:bridge"), + react_native_target("java/com/facebook/react/common:common"), + react_native_target("java/com/facebook/react/touch:touch"), + react_native_target("java/com/facebook/react/fabric:fabric"), + ], +) diff --git a/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java b/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java new file mode 100644 index 00000000000000..eb748ea20892b9 --- /dev/null +++ b/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java @@ -0,0 +1,616 @@ +/* + * 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. + */ + +package com.facebook.react.fabric.events; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.powermock.api.mockito.PowerMockito.doAnswer; +import static org.powermock.api.mockito.PowerMockito.mock; + +import android.util.DisplayMetrics; +import android.view.MotionEvent; +import android.view.MotionEvent.PointerCoords; +import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.JavaOnlyArray; +import com.facebook.react.bridge.JavaOnlyMap; +import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.WritableMap; +import com.facebook.react.fabric.FabricUIManager; +import com.facebook.react.uimanager.DisplayMetricsHolder; +import com.facebook.react.uimanager.events.TouchEvent; +import com.facebook.react.uimanager.events.TouchEventCoalescingKeyHelper; +import com.facebook.react.uimanager.events.TouchEventType; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.rule.PowerMockRule; +import org.robolectric.RobolectricTestRunner; + +@PrepareForTest({Arguments.class, FabricUIManager.class}) +@SuppressStaticInitializationFor("com.facebook.react.fabric.FabricUIManager") +@RunWith(RobolectricTestRunner.class) +@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +public class TouchEventDispatchTest { + + private static final int SURFACE_ID = 121; + private static final int TARGET_VIEW_ID = 42; + private static final int GESTURE_START_TIME = 1; + + @Rule public PowerMockRule rule = new PowerMockRule(); + + private final TouchEventCoalescingKeyHelper mTouchEventCoalescingKeyHelper = + new TouchEventCoalescingKeyHelper(); + + /** Events (1 pointer): START -> MOVE -> MOVE -> UP */ + private final TouchEvent[] mStartMoveEndSequence = + new TouchEvent[] { + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_DOWN, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_MOVE, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 2f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_MOVE, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 3f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_UP, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 3f)}) + }; + + /** Expected values for {@link #mStartMoveEndSequence} */ + private final List mStartMoveEndExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 1f, + GESTURE_START_TIME, + 0, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0))), + /* + * MOVE event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 2f, + GESTURE_START_TIME, + 0, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0))), + /* + * MOVE event for touch 1: + * { + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 3f, + GESTURE_START_TIME, + 0, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0))), + /* + * END event for touch 1: + * { + * touches: [], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 3f, + GESTURE_START_TIME, + 0, + Collections.emptyList(), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0)))); + + /** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> UP 2st -> UP 1st */ + private final TouchEvent[] mStartPointerMoveUpSequence = + new TouchEvent[] { + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_DOWN, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_POINTER_DOWN, + 1, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 1f), pointerCoords(2f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_MOVE, + 0, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 2f), pointerCoords(2f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_POINTER_UP, + 1, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 2f), pointerCoords(2f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_POINTER_UP, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 2f)}) + }; + + /** Expected values for {@link #mStartPointerMoveUpSequence} */ + private final List mStartPointerMoveUpExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touch: 0, + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 1f, + GESTURE_START_TIME, + 0, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0))), + /* + * START event for touch 2: + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + /* + * MOVE event for touch 1: + * { + * touch: 0, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 2f, + GESTURE_START_TIME, + 0, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + /* + * UP event pointer 1: + * { + * touch: 1, + * touches: [touch0], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + /* + * UP event pointer 0: + * { + * touch: 0, + * touches: [], + * changed: [touch0] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 2f, + GESTURE_START_TIME, + 0, + Collections.emptyList(), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0)))); + + /** Events (2 pointer): START 1st -> START 2nd -> MOVE 1st -> CANCEL */ + private final TouchEvent[] mStartMoveCancelSequence = + new TouchEvent[] { + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_DOWN, + 0, + new int[] {0}, + new PointerCoords[] {pointerCoords(1f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_POINTER_DOWN, + 1, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 1f), pointerCoords(2f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_MOVE, + 0, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 2f), pointerCoords(2f, 1f)}), + createTouchEvent( + GESTURE_START_TIME, + MotionEvent.ACTION_CANCEL, + 0, + new int[] {0, 1}, + new PointerCoords[] {pointerCoords(1f, 3f), pointerCoords(2f, 1f)}) + }; + + /** Expected values for {@link #mStartMoveCancelSequence} */ + private final List mStartMoveCancelExpectedSequence = + listOf( + /* + * START event for touch 1: + * { + * touch: 0, + * touches: [touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 1f, + GESTURE_START_TIME, + 0, + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0))), + /* + * START event for touch 2: + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 1f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf(buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + /* + * MOVE event for touch 1: + * { + * touch: 0, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [touch0, touch1], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 2f, + GESTURE_START_TIME, + 0, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 2f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + /* + * CANCEL event: + * { + * touch: 0, + * touches: [], + * changed: [touch0, touch1] + * } + * { + * touch: 1, + * touches: [], + * changed: [touch0, touch1] + * } + */ + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 1f, + 3f, + GESTURE_START_TIME, + 0, + Collections.emptyList(), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1))), + buildGestureEvent( + SURFACE_ID, + TARGET_VIEW_ID, + 2f, + 1f, + GESTURE_START_TIME, + 1, + Collections.emptyList(), + listOf( + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 1f, 3f, GESTURE_START_TIME, 0), + buildGesture(SURFACE_ID, TARGET_VIEW_ID, 2f, 1f, GESTURE_START_TIME, 1)))); + + List mDispatchedEvents; + FabricEventEmitter mEventEmitter; + + @Before + public void setUp() { + PowerMockito.mockStatic(Arguments.class); + PowerMockito.mockStatic(FabricUIManager.class); + PowerMockito.when(Arguments.createArray()) + .thenAnswer( + new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + return new JavaOnlyArray(); + } + }); + PowerMockito.when(Arguments.createMap()) + .thenAnswer( + new Answer() { + @Override + public Object answer(InvocationOnMock invocation) { + return new JavaOnlyMap(); + } + }); + + DisplayMetrics metrics = new DisplayMetrics(); + metrics.xdpi = 1f; + metrics.ydpi = 1f; + metrics.density = 1f; + DisplayMetricsHolder.setWindowDisplayMetrics(metrics); + + FabricUIManager fabricUIManager = mock(FabricUIManager.class); + mDispatchedEvents = new ArrayList<>(); + doAnswer( + new Answer() { + @Override + public Void answer(InvocationOnMock invocation) { + mDispatchedEvents.add(invocation.getArgument(5)); + return null; + } + }) + .when(fabricUIManager) + .receiveEvent( + anyInt(), + anyInt(), + anyString(), + anyBoolean(), + anyInt(), + ArgumentMatchers.any(), + anyInt()); + mEventEmitter = new FabricEventEmitter(fabricUIManager); + } + + @Test + public void testFabric_startMoveEnd() { + for (TouchEvent event : mStartMoveEndSequence) { + event.dispatchModern(mEventEmitter); + } + + assertEquals(mStartMoveEndExpectedSequence, mDispatchedEvents); + } + + @Test + public void testFabric_startMoveCancel() { + for (TouchEvent event : mStartMoveCancelSequence) { + event.dispatchModern(mEventEmitter); + } + + assertEquals(mStartMoveCancelExpectedSequence, mDispatchedEvents); + } + + @Test + public void testFabric_startPointerUpCancel() { + for (TouchEvent event : mStartPointerMoveUpSequence) { + event.dispatchModern(mEventEmitter); + } + + assertEquals(mStartPointerMoveUpExpectedSequence, mDispatchedEvents); + } + + private TouchEvent createTouchEvent( + int gestureTime, int action, int pointerId, int[] pointerIds, PointerCoords[] pointerCoords) { + mTouchEventCoalescingKeyHelper.addCoalescingKey(gestureTime); + action |= pointerId << MotionEvent.ACTION_POINTER_INDEX_SHIFT; + return TouchEvent.obtain( + SURFACE_ID, + TARGET_VIEW_ID, + getType(action), + MotionEvent.obtain( + gestureTime, + gestureTime, + action, + pointerIds.length, + pointerIds, + pointerCoords, + 0, + 0f, + 0f, + 0, + 0, + 0, + 0), + gestureTime, + pointerCoords[0].x, + pointerCoords[0].y, + mTouchEventCoalescingKeyHelper); + } + + private static TouchEventType getType(int action) { + action &= ~MotionEvent.ACTION_POINTER_INDEX_MASK; + switch (action) { + case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_POINTER_DOWN: + return TouchEventType.START; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_POINTER_UP: + return TouchEventType.END; + case MotionEvent.ACTION_MOVE: + return TouchEventType.MOVE; + case MotionEvent.ACTION_CANCEL: + return TouchEventType.CANCEL; + } + + return TouchEventType.START; + } + + private static ReadableMap buildGestureEvent( + int surfaceId, + int viewTag, + float locationX, + float locationY, + int time, + int pointerId, + List touches, + List changedTouches) { + WritableMap gesture = buildGesture(surfaceId, viewTag, locationX, locationY, time, pointerId); + gesture.putArray("changedTouches", JavaOnlyArray.from(changedTouches)); + gesture.putArray("touches", JavaOnlyArray.from(touches)); + return gesture; + } + + private static WritableMap buildGesture( + int surfaceId, int viewTag, float locationX, float locationY, int time, int pointerId) { + WritableMap map = new JavaOnlyMap(); + map.putInt("targetSurface", surfaceId); + map.putInt("target", viewTag); + map.putDouble("locationX", locationX); + map.putDouble("locationY", locationY); + map.putDouble("pageX", locationX); + map.putDouble("pageY", locationY); + map.putDouble("identifier", pointerId); + map.putDouble("timestamp", time); + return map; + } + + @SafeVarargs + private static List listOf(E... args) { + return Arrays.asList(args); + } + + private static PointerCoords pointerCoords(float x, float y) { + PointerCoords pointerCoords = new PointerCoords(); + pointerCoords.x = x; + pointerCoords.y = y; + return pointerCoords; + } +} diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK b/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK index f50c34f262d139..7ab27c360a9714 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK @@ -4,6 +4,7 @@ rn_robolectric_test( name = "modules", srcs = glob(["**/*.java"]), contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], @@ -14,7 +15,7 @@ rn_robolectric_test( react_native_dep("third-party/android/androidx:fragment"), react_native_dep("third-party/android/androidx:legacy-support-core-ui"), react_native_dep("third-party/android/androidx:legacy-support-core-utils"), - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/blob/BlobModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/blob/BlobModuleTest.java index 9eff51186515b0..39606f804c944a 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/blob/BlobModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/blob/BlobModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/camera/ImageStoreManagerTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/camera/ImageStoreManagerTest.java index 605b34c487a589..63540fc745283a 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/camera/ImageStoreManagerTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/camera/ImageStoreManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.java index 21ab31a27b8398..4f5e3223f0b360 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/clipboard/ClipboardModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java index 6ed814abb53406..1d9644db98d5ae 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.modules.deviceinfo; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java index 6f12eee70cecef..2bde2d61bc4f74 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java index b2a7b1974b6fe1..35c17cfbc21e98 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java index eb09e6dee01f9a..1e353f8f23e810 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.modules.network; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/ProgressiveStringDecoderTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/ProgressiveStringDecoderTest.java index cdd897e4a6fa9e..a714df574b6310 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/network/ProgressiveStringDecoderTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/ProgressiveStringDecoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/ReactCookieJarContainerTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/ReactCookieJarContainerTest.java index ef21b78fe94019..3acb9a0af8dc98 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/network/ReactCookieJarContainerTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/ReactCookieJarContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.modules.network; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java index 2260bc47dde664..2ca9110d5a4cb9 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java index bc5d9bc332649d..d4b2ee2c4c4563 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/storage/AsyncStorageModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.modules.storage; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import com.facebook.react.bridge.Arguments; diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java index 7164b8489af447..79b45b2faaeb4c 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.modules.timing; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; import com.facebook.react.bridge.Arguments; diff --git a/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/BUCK b/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/BUCK index 18d466c38e3c39..0129610feaf9c1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/BUCK @@ -4,11 +4,12 @@ rn_robolectric_test( name = "packagerconnection", srcs = glob(["**/*.java"]), contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java b/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java index 2d843d13abebed..3ba3bb27a02fe1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK index 21a1e32104a66c..58399a57095cce 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK @@ -11,6 +11,7 @@ rn_robolectric_test( ], contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], is_androidx = True, + language = "JAVA", visibility = [ "PUBLIC", ], @@ -21,7 +22,7 @@ rn_robolectric_test( react_native_dep("third-party/android/androidx:fragment"), react_native_dep("third-party/android/androidx:legacy-support-core-ui"), react_native_dep("third-party/android/androidx:legacy-support-core-utils"), - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java index 28208b8f8aaee1..b922a06cd23983 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import com.facebook.react.R; import com.facebook.react.bridge.Arguments; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java index aad83907a1cb63..d089f565fbc3f9 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java index 047e6541db3dfc..319586c3c34aa1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java index 5dba53965794e9..7c088e9bb931e1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java index 44834866d28813..9739dcb697594d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.fail; +import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java index 97e074481ec62c..62e9497380ff0e 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; -import static org.fest.assertions.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import android.view.View; import com.facebook.react.bridge.ReactApplicationContext; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java index 6a59d00cff893f..8dd914535a1214 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java index 0153ed615987d3..545b891a2ddf21 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java index 91be74945d9c9b..e031f7c80014cd 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; -import static org.fest.assertions.api.Assertions.offset; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.offset; import android.graphics.drawable.ColorDrawable; import android.view.View; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java index 48f287850d5daf..4a8ce0c8dd4a12 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.fest.assertions.data.MapEntry; +import org.assertj.core.data.MapEntry; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java index 745f6dc905db5a..2a78819759114f 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK index 3124e8db34698e..1dcd20c25142c6 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK @@ -4,12 +4,13 @@ rn_robolectric_test( name = "layoutanimation", srcs = glob(["**/*.java"]), contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ YOGA_TARGET, - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/junit:junit"), react_native_target("java/com/facebook/react/uimanager:uimanager"), ], diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/InterpolatorTypeTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/InterpolatorTypeTest.java index 57587beb36ef7a..0bb6671101561f 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/InterpolatorTypeTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/InterpolatorTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.uimanager.layoutanimation; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Locale; import org.junit.Test; diff --git a/ReactAndroid/src/test/java/com/facebook/react/util/BUCK b/ReactAndroid/src/test/java/com/facebook/react/util/BUCK index 039b88cc4e8d3e..ce8386b91f8fe1 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/util/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/util/BUCK @@ -3,12 +3,13 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_tar rn_robolectric_test( name = "util", srcs = glob(["**/*.java"]), - contacts = ["oncall+test_ownership_2020@xmail.facebook.com"], + contacts = ["oncall+react_native@xmail.facebook.com"], + language = "JAVA", visibility = [ "PUBLIC", ], deps = [ - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_target("java/com/facebook/react/util:util"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.java b/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.java index 5c4b73243f8441..d2657ad80d4100 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/BUCK b/ReactAndroid/src/test/java/com/facebook/react/views/BUCK index 318274a05f088d..d624727def624c 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/views/BUCK @@ -2,10 +2,14 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_robolectric_test( name = "views", - # TODO Disabled temporarily until Yoga linking is fixed t14964130 + # TODO (T110934492): Disabled temporarily until tests are fixed # srcs = glob(['**/*.java']), - srcs = glob(["image/*.java"]), + srcs = glob([ + "image/*.java", + "view/*.java", + ]), contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + language = "JAVA", deps = [ YOGA_TARGET, react_native_dep("libraries/fresco/fresco-react-native:fresco-drawee"), @@ -17,7 +21,7 @@ rn_robolectric_test( react_native_dep("third-party/android/androidx:fragment"), react_native_dep("third-party/android/androidx:legacy-support-core-ui"), react_native_dep("third-party/android/androidx:legacy-support-core-utils"), - react_native_dep("third-party/java/fest:fest"), + react_native_dep("third-party/java/assertj:assertj-core"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_dep("third-party/java/junit:junit"), react_native_dep("third-party/java/okhttp:okhttp3"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java index 870be9df2172a9..21ce26fb140b94 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.image; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import com.facebook.drawee.drawable.ScalingUtils; import org.junit.Rule; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java index e172c90a3c7902..99788ecb6d7964 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/slider/ReactSliderPropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/slider/ReactSliderPropertyTest.java index 7320dc7f25d774..71453966cb4658 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/slider/ReactSliderPropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/slider/ReactSliderPropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.slider; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import android.widget.SeekBar; import com.facebook.react.bridge.CatalystInstance; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java index ad79e3bcf1403b..1bb4ee2c4f4eda 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.text; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import android.graphics.Paint; import org.junit.Test; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java index 2af226ff63894d..5c6790bcfb4b77 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.text; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java index b908654deb6d02..a817b810d4161c 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.textinput; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import android.content.res.ColorStateList; import android.graphics.Color; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java index 1db56837f951d0..b029e5160f0b43 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.views.textinput; -import static org.fest.assertions.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java index 92a5212d5d208b..a7ea56f0e2ac65 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -44,4 +44,13 @@ public void testGetOpacityFromColor() { assertEquals(PixelFormat.OPAQUE, ColorUtil.getOpacityFromColor(0xFF123456)); assertEquals(PixelFormat.OPAQUE, ColorUtil.getOpacityFromColor(0xFFFFFFFF)); } + + @Test + public void testNormalize() { + assertEquals(0x800B1621, ColorUtil.normalize(11, 22, 33, 0.5)); + assertEquals(0x00000000, ColorUtil.normalize(0, 0, 0, 0)); + assertEquals(0xFFFFFFFF, ColorUtil.normalize(255, 255, 255, 1)); + assertEquals(0xFF00FFFF, ColorUtil.normalize(-1, 256, 255, 1.1)); + assertEquals(0x000001FF, ColorUtil.normalize(0.4, 0.5, 255.4, -1)); + } } diff --git a/ReactAndroid/src/test/java/org/mockito/configuration/BUCK b/ReactAndroid/src/test/java/org/mockito/configuration/BUCK index ed96ae2d0653cf..70c2371e947cbe 100644 --- a/ReactAndroid/src/test/java/org/mockito/configuration/BUCK +++ b/ReactAndroid/src/test/java/org/mockito/configuration/BUCK @@ -4,6 +4,7 @@ rn_android_library( name = "configuration", srcs = glob(["**/*.java"]), autoglob = False, + language = "JAVA", visibility = [ "PUBLIC", ], diff --git a/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java b/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java index 152fb90f5096ad..ab68d427ceb032 100644 --- a/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java +++ b/ReactAndroid/src/test/java/org/mockito/configuration/MockitoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactAndroid/src/test/resources/BUCK b/ReactAndroid/src/test/resources/BUCK index af94e7bada4fd2..3c1553a6085f52 100644 --- a/ReactAndroid/src/test/resources/BUCK +++ b/ReactAndroid/src/test/resources/BUCK @@ -1,12 +1,15 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. -java_library( +load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") + +fb_native.java_library( name = "robolectric", srcs = [], labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", "supermodule:xplat/default/public.react_native.infra", ], resources = [ diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec index 5502200b35f1a8..48b6b74e541a3d 100644 --- a/ReactCommon/React-Fabric.podspec +++ b/ReactCommon/React-Fabric.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' folly_dep_name = 'RCT-Folly/Fabric' boost_compiler_flags = '-Wno-documentation' react_native_path = ".." @@ -29,7 +29,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "dummyFile.cpp" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", @@ -61,12 +61,12 @@ Pod::Spec.new do |s| ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end - s.subspec "better" do |ss| + s.subspec "butter" do |ss| ss.dependency folly_dep_name, folly_version ss.compiler_flags = folly_compiler_flags - ss.source_files = "better/**/*.{m,mm,cpp,h}" - ss.exclude_files = "better/tests" - ss.header_dir = "better" + ss.source_files = "butter/**/*.{m,mm,cpp,h}" + ss.exclude_files = "butter/tests" + ss.header_dir = "butter" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/RCT-Folly\"" } end diff --git a/ReactCommon/React-bridging.podspec b/ReactCommon/React-bridging.podspec new file mode 100644 index 00000000000000..2ea858270d7232 --- /dev/null +++ b/ReactCommon/React-bridging.podspec @@ -0,0 +1,42 @@ +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1") +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2021.07.22.00' + +Pod::Spec.new do |s| + s.name = "React-bridging" + s.version = version + s.summary = "-" # TODO + s.homepage = "https://reactnative.dev/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "12.4" } + s.source = source + s.source_files = "react/bridging/**/*.{cpp,h}" + s.exclude_files = "react/bridging/tests" + s.header_dir = "react/bridging" + s.header_mappings_dir = "." + s.compiler_flags = folly_compiler_flags + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\"", + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } + + s.dependency "RCT-Folly", folly_version + s.dependency "React-jsi", version +end diff --git a/ReactCommon/React-rncore.podspec b/ReactCommon/React-rncore.podspec index 9e6171ad6eb9c3..635c80e7d241d5 100644 --- a/ReactCommon/React-rncore.podspec +++ b/ReactCommon/React-rncore.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -25,7 +25,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "dummyFile.cpp" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", diff --git a/ReactCommon/ReactCommon.podspec b/ReactCommon/ReactCommon.podspec index a9176cbb5b807a..c6696a4d10da9e 100644 --- a/ReactCommon/ReactCommon.podspec +++ b/ReactCommon/ReactCommon.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -28,17 +28,18 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.header_dir = "ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags - s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\"", + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"", "USE_HEADERMAP" => "YES", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14" } + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } # TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..." # Note: Update this only when ready to minimize breaking changes. s.subspec "turbomodule" do |ss| + ss.dependency "React-bridging", version ss.dependency "React-callinvoker", version ss.dependency "React-perflogger", version ss.dependency "React-Core", version diff --git a/ReactCommon/better/Android.mk b/ReactCommon/better/Android.mk deleted file mode 100644 index fed79b0fbbc136..00000000000000 --- a/ReactCommon/better/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := better - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Better\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := glog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) diff --git a/ReactCommon/better/optional.h b/ReactCommon/better/optional.h deleted file mode 100644 index f788d487822ca2..00000000000000 --- a/ReactCommon/better/optional.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#if defined(BETTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L - -#include - -#else - -#include - -#endif - -namespace facebook { -namespace better { - -#if defined(BETTER_USE_FOLLY_CONTAINERS) || __cplusplus < 202000L - -template -using optional = folly::Optional; - -#else - -template -using optional = std::optional; - -#endif - -} // namespace better -} // namespace facebook diff --git a/ReactCommon/better/.clang-tidy b/ReactCommon/butter/.clang-tidy similarity index 61% rename from ReactCommon/better/.clang-tidy rename to ReactCommon/butter/.clang-tidy index c98fd78ff64baa..8edbbc799e94cf 100644 --- a/ReactCommon/better/.clang-tidy +++ b/ReactCommon/butter/.clang-tidy @@ -1,4 +1,5 @@ --- +InheritParentConfig: true Checks: '> clang-diagnostic-*, ' diff --git a/ReactCommon/better/BUCK b/ReactCommon/butter/BUCK similarity index 82% rename from ReactCommon/better/BUCK rename to ReactCommon/butter/BUCK index c287ec796522ce..e2a65707f06915 100644 --- a/ReactCommon/better/BUCK +++ b/ReactCommon/butter/BUCK @@ -13,7 +13,7 @@ load( APPLE_COMPILER_FLAGS = get_apple_compiler_flags() rn_xplat_cxx_library( - name = "better", + name = "butter", srcs = glob( ["**/*.cpp"], exclude = glob(["tests/**/*.cpp"]), @@ -27,12 +27,15 @@ rn_xplat_cxx_library( [ ("", "*.h"), ], - prefix = "better", + prefix = "butter", ), fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -44,7 +47,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", ], diff --git a/ReactCommon/butter/CMakeLists.txt b/ReactCommon/butter/CMakeLists.txt new file mode 100644 index 00000000000000..f0369712e434b2 --- /dev/null +++ b/ReactCommon/butter/CMakeLists.txt @@ -0,0 +1,20 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -DLOG_TAG=\"Butter\" + -fexceptions + -frtti + -std=c++17 + -Wall) + +add_library(butter INTERFACE) + +target_include_directories(butter INTERFACE .) + +target_link_libraries(butter INTERFACE glog) diff --git a/ReactCommon/better/better.h b/ReactCommon/butter/butter.h similarity index 65% rename from ReactCommon/better/better.h rename to ReactCommon/butter/butter.h index 0d300bd1ec1f4d..69cfb534f22bc1 100644 --- a/ReactCommon/better/better.h +++ b/ReactCommon/butter/butter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,28 +8,37 @@ #pragma once namespace facebook { -namespace better { +namespace butter { /* - * `Better` is a trivial collection of basic tools borrowed from other low-level + * `Butter` is a minimal collection of basic tools borrowed from other low-level * general purpose libraries (like Folly, Abseil or Boost). The main goals of - * Better: + * Butter: * - Make the codebase more portable; * - Make the dependency list explicit (by decoupling it as a dependency list of - * Better); + * Butter); * - Make relying on modern C++ patterns and tools in code simple and easy. * - Make executing experiments with different dependencies easier. + * - Limit reliance on third-party libraries eventually. * - * What should be part of Better and what should not? Should I add some piece of - * functionality in the Better? Here is a quick checklist. + * Target C++ Version + * ------------------ + * Currently, Butter targets C++17. + * + * The Scope + * --------- + * What should be part of Butter and what should not? Should I add some piece of + * functionality in the Butter? Here is a quick checklist. + * + * As of now, Butter is relatively permissive per the guidance below: * * If one of the following is true, yes, go for it: * - If some feature is already in some future C++ standard (possibly in draft * stage) and it's already implemented in some 3rd party library. * - If some standardized feature of C++ is implemented in the standard not in - * the most efficient way (because the standard enforces some tricky constraints - * (like always-valid iterators) which nobody uses and should use), but you have - * a library that does it right providing exact same interface. + * the most efficient way (because the standard enforces some tricky + * constraints, like always-valid iterators, which nobody uses and should use), + * but you have a library that does it right providing exact same interface. * * If one of the following is true, please do *NOT* do it (at least as part of * the library): @@ -41,6 +50,11 @@ namespace better { * faster than the standard one, so You want to use that in the code base. That * container does not have compatible API though (because it's a clear trade-off * with efficiency, of course). + * + * Note that eventually Butter will restrict the API collection to reduce + * reliance on non-standard C++ builtin libraries. That way, the API footprint + * stays small and is limited to just the essential APIs. This restriction is + * currently a work in progress. */ /* @@ -55,8 +69,8 @@ namespace better { * introspections mechanisms. */ #ifndef DEBUG -#define BETTER_USE_FOLLY_CONTAINERS +#define BUTTER_USE_FOLLY_CONTAINERS #endif -} // namespace better +} // namespace butter } // namespace facebook diff --git a/ReactCommon/better/map.h b/ReactCommon/butter/map.h similarity index 67% rename from ReactCommon/better/map.h rename to ReactCommon/butter/map.h index 9fe72bd5e897eb..09e87ae3a5cef5 100644 --- a/ReactCommon/better/map.h +++ b/ReactCommon/butter/map.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,9 +7,9 @@ #pragma once -#include +#include -#ifdef BETTER_USE_FOLLY_CONTAINERS +#ifdef BUTTER_USE_FOLLY_CONTAINERS #include @@ -20,16 +20,16 @@ #endif namespace facebook { -namespace better { +namespace butter { /* - * Note: In Better, `map` aliases to `unorderd_map` because everyone agrees that + * Note: In Butter, `map` aliases to `unorderd_map` because everyone agrees that * an *ordered* map is nonsense and was a huge mistake for standardization. If * you need an *ordered* map, feel free to introduce that as - * `better::ordered_map`. + * `butter::ordered_map`. */ -#ifdef BETTER_USE_FOLLY_CONTAINERS +#ifdef BUTTER_USE_FOLLY_CONTAINERS template using map = folly::F14FastMap; @@ -41,5 +41,5 @@ using map = std::unordered_map; #endif -} // namespace better +} // namespace butter } // namespace facebook diff --git a/ReactCommon/better/mutex.h b/ReactCommon/butter/mutex.h similarity index 76% rename from ReactCommon/better/mutex.h rename to ReactCommon/butter/mutex.h index e8451f818b7157..9071356eba1699 100644 --- a/ReactCommon/better/mutex.h +++ b/ReactCommon/butter/mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,9 +12,9 @@ #include namespace facebook { -namespace better { +namespace butter { using shared_mutex = folly::SharedMutex; -} // namespace better +} // namespace butter } // namespace facebook diff --git a/ReactCommon/better/set.h b/ReactCommon/butter/set.h similarity index 68% rename from ReactCommon/better/set.h rename to ReactCommon/butter/set.h index 2e41ce91eb0a9b..254bf88e47c3ea 100644 --- a/ReactCommon/better/set.h +++ b/ReactCommon/butter/set.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,9 +7,9 @@ #pragma once -#include +#include -#ifdef BETTER_USE_FOLLY_CONTAINERS +#ifdef BUTTER_USE_FOLLY_CONTAINERS #include @@ -20,9 +20,9 @@ #endif namespace facebook { -namespace better { +namespace butter { -#ifdef BETTER_USE_FOLLY_CONTAINERS +#ifdef BUTTER_USE_FOLLY_CONTAINERS template using set = folly::F14FastSet; @@ -34,5 +34,5 @@ using set = std::unordered_set; #endif -} // namespace better +} // namespace butter } // namespace facebook diff --git a/ReactCommon/better/small_vector.h b/ReactCommon/butter/small_vector.h similarity index 69% rename from ReactCommon/better/small_vector.h rename to ReactCommon/butter/small_vector.h index 54af50472b106d..002ec65f964458 100644 --- a/ReactCommon/better/small_vector.h +++ b/ReactCommon/butter/small_vector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,10 +7,10 @@ #pragma once -#include +#include // `folly::small_vector` is broken on some versions of Android. -#if defined(BETTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID) +#if defined(BUTTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID) #include @@ -21,9 +21,9 @@ #endif namespace facebook { -namespace better { +namespace butter { -#if defined(BETTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID) +#if defined(BUTTER_USE_FOLLY_CONTAINERS) && !defined(ANDROID) template using small_vector = folly::small_vector; @@ -35,5 +35,5 @@ using small_vector = std::vector; #endif -} // namespace better +} // namespace butter } // namespace facebook diff --git a/ReactCommon/callinvoker/Android.mk b/ReactCommon/callinvoker/Android.mk deleted file mode 100644 index 3cef3d750c8752..00000000000000 --- a/ReactCommon/callinvoker/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -# Name of this module. -LOCAL_MODULE := callinvoker - -# Compile all local c++ files under ./ReactCommon -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) - -# Build the files in this directory as a shared library -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/callinvoker/BUCK b/ReactCommon/callinvoker/BUCK index d6ff5cdb39a49e..0cd39207d8754a 100644 --- a/ReactCommon/callinvoker/BUCK +++ b/ReactCommon/callinvoker/BUCK @@ -10,7 +10,10 @@ rn_xplat_cxx_library( ], prefix = "ReactCommon", ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preferred_linkage = "static", preprocessor_flags = [ diff --git a/ReactCommon/callinvoker/CMakeLists.txt b/ReactCommon/callinvoker/CMakeLists.txt new file mode 100644 index 00000000000000..58da1e6a1f0709 --- /dev/null +++ b/ReactCommon/callinvoker/CMakeLists.txt @@ -0,0 +1,13 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall) + +add_library(callinvoker INTERFACE) + +target_include_directories(callinvoker INTERFACE .) diff --git a/ReactCommon/callinvoker/React-callinvoker.podspec b/ReactCommon/callinvoker/React-callinvoker.podspec index b05fad87c432b2..7ade869b280185 100644 --- a/ReactCommon/callinvoker/React-callinvoker.podspec +++ b/ReactCommon/callinvoker/React-callinvoker.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "**/*.{cpp,h}" s.header_dir = "ReactCommon" diff --git a/ReactCommon/callinvoker/ReactCommon/CallInvoker.h b/ReactCommon/callinvoker/ReactCommon/CallInvoker.h index 37bb2037ecda60..ccca8b97d154cb 100644 --- a/ReactCommon/callinvoker/ReactCommon/CallInvoker.h +++ b/ReactCommon/callinvoker/ReactCommon/CallInvoker.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/common.mk b/ReactCommon/common.mk deleted file mode 100644 index a7b873a689d7f0..00000000000000 --- a/ReactCommon/common.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -## -# Returns the absolute path to the specified npm package, searching from the -# given base directory. This function uses Node's module resolution algorithm -# searching "node_modules" in the base directory and its ancestors. If no -# matching package is found, this function returns an empty string. -# -# The first argument to this function is the base directory from which to begin -# searching. The second argument is the name of the npm package. -# -# Ex: $(call find-node-module,$(LOCAL_PATH),hermes-engine) -### -define find-node-module -$(strip \ - $(eval _base := $(strip $(1))) \ - $(eval _package := $(strip $(2))) \ - $(eval _candidate := $(abspath $(_base)/node_modules/$(_package))) \ - $(if $(realpath $(_candidate)), \ - $(_candidate), \ - $(if $(_base), \ - $(call find-node-module,$(patsubst %/,%,$(dir $(_base))),$(_package)) \ - ) \ - ) \ -) -endef diff --git a/ReactCommon/cxxreact/Android.mk b/ReactCommon/cxxreact/Android.mk deleted file mode 100644 index 392c33b730a4ac..00000000000000 --- a/ReactCommon/cxxreact/Android.mk +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := reactnative - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture - -LOCAL_STATIC_LIBRARIES := boost jsi callinvoker reactperflogger runtimeexecutor -LOCAL_SHARED_LIBRARIES := jsinspector libfolly_json glog logger - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,callinvoker) -$(call import-module,reactperflogger) -$(call import-module,jsc) -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,jsinspector) -$(call import-module,hermes/inspector) -$(call import-module,hermes/executor) -$(call import-module,logger) diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index a662a78414ba77..0f23dd8fea8ce2 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -1,5 +1,5 @@ load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob") -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "get_android_inspector_flags", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_target", "rn_xplat_cxx_library") +load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "get_android_inspector_flags", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_target", "rn_xplat_cxx_library") rn_xplat_cxx_library( name = "module", @@ -14,7 +14,10 @@ rn_xplat_cxx_library( ), fbobjc_compiler_flags = get_apple_compiler_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], visibility = [ "PUBLIC", ], @@ -35,7 +38,10 @@ rn_xplat_cxx_library( ), fbobjc_compiler_flags = get_apple_compiler_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], visibility = [ "PUBLIC", ], @@ -55,7 +61,10 @@ rn_xplat_cxx_library( "-fno-omit-frame-pointer", ], fbobjc_compiler_flags = get_apple_compiler_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], soname = "libxplat_react_module_samplemodule.$(ext)", visibility = [ "PUBLIC", @@ -113,9 +122,12 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = get_apple_compiler_flags(), fbobjc_force_static = True, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], - platforms = (ANDROID, APPLE), + platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", "-DWITH_FBSYSTRACE=1", @@ -128,13 +140,12 @@ rn_xplat_cxx_library( ":jsbigstring", ":module", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:jsi", react_native_xplat_target("callinvoker:callinvoker"), react_native_xplat_target("jsinspector:jsinspector"), - react_native_xplat_target("microprofiler:microprofiler"), react_native_xplat_target("runtimeexecutor:runtimeexecutor"), react_native_xplat_target("reactperflogger:reactperflogger"), react_native_xplat_target("logger:logger"), diff --git a/ReactCommon/cxxreact/CMakeLists.txt b/ReactCommon/cxxreact/CMakeLists.txt new file mode 100644 index 00000000000000..5518b0909efc27 --- /dev/null +++ b/ReactCommon/cxxreact/CMakeLists.txt @@ -0,0 +1,29 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -Wno-unused-lambda-capture + -DLOG_TAG=\"ReactNative\") + +file(GLOB reactnative_SRC CONFIGURE_DEPENDS *.cpp) +add_library(reactnative STATIC ${reactnative_SRC}) + +target_include_directories(reactnative PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(reactnative + boost + callinvoker + folly_runtime + glog + jsi + jsinspector + logger + reactperflogger + runtimeexecutor) diff --git a/ReactCommon/cxxreact/CxxModule.h b/ReactCommon/cxxreact/CxxModule.h index 64b7db6425951a..a5a89f79423a40 100644 --- a/ReactCommon/cxxreact/CxxModule.h +++ b/ReactCommon/cxxreact/CxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/CxxNativeModule.cpp b/ReactCommon/cxxreact/CxxNativeModule.cpp index 0bcf13657eed9a..fbfdaa0aeb41cb 100644 --- a/ReactCommon/cxxreact/CxxNativeModule.cpp +++ b/ReactCommon/cxxreact/CxxNativeModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -244,8 +244,8 @@ void CxxNativeModule::lazyInit() { module_ = provider_(); provider_ = nullptr; if (module_) { - methods_ = module_->getMethods(); module_->setInstance(instance_); + methods_ = module_->getMethods(); } } diff --git a/ReactCommon/cxxreact/CxxNativeModule.h b/ReactCommon/cxxreact/CxxNativeModule.h index a10f0ec5cb0a54..e9902132000e22 100644 --- a/ReactCommon/cxxreact/CxxNativeModule.h +++ b/ReactCommon/cxxreact/CxxNativeModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/ErrorUtils.h b/ReactCommon/cxxreact/ErrorUtils.h index 3ab715b2efb0ba..d9e42f7d221fc6 100644 --- a/ReactCommon/cxxreact/ErrorUtils.h +++ b/ReactCommon/cxxreact/ErrorUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/Instance.cpp b/ReactCommon/cxxreact/Instance.cpp index f1150821a9659a..71bb1512be2865 100644 --- a/ReactCommon/cxxreact/Instance.cpp +++ b/ReactCommon/cxxreact/Instance.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -109,40 +108,6 @@ void Instance::loadScriptFromString( } } -bool Instance::isHBCBundle(const char *sourcePath) { - std::ifstream bundle_stream(sourcePath, std::ios_base::in); - BundleHeader header; - - if (!bundle_stream || - !bundle_stream.read(reinterpret_cast(&header), sizeof(header))) { - return false; - } - - return parseTypeFromHeader(header) == ScriptTag::HBCBundle; -} - -bool Instance::isIndexedRAMBundle(const char *sourcePath) { - std::ifstream bundle_stream(sourcePath, std::ios_base::in); - BundleHeader header; - - if (!bundle_stream || - !bundle_stream.read(reinterpret_cast(&header), sizeof(header))) { - return false; - } - - return parseTypeFromHeader(header) == ScriptTag::RAMBundle; -} - -bool Instance::isIndexedRAMBundle(std::unique_ptr *script) { - BundleHeader header; - strncpy( - reinterpret_cast(&header), - script->get()->c_str(), - sizeof(header)); - - return parseTypeFromHeader(header) == ScriptTag::RAMBundle; -} - void Instance::loadRAMBundleFromString( std::unique_ptr script, const std::string &sourceURL) { diff --git a/ReactCommon/cxxreact/Instance.h b/ReactCommon/cxxreact/Instance.h index 7cd11f9bdf50b4..12bfd86d7b4b7a 100644 --- a/ReactCommon/cxxreact/Instance.h +++ b/ReactCommon/cxxreact/Instance.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -56,9 +56,6 @@ class RN_EXPORT Instance { std::unique_ptr string, std::string sourceURL, bool loadSynchronously); - static bool isHBCBundle(const char *sourcePath); - static bool isIndexedRAMBundle(const char *sourcePath); - static bool isIndexedRAMBundle(std::unique_ptr *string); void loadRAMBundleFromString( std::unique_ptr script, const std::string &sourceURL); diff --git a/ReactCommon/cxxreact/JSBigString.cpp b/ReactCommon/cxxreact/JSBigString.cpp index 77e22800fd8e6a..59e117c0818e5c 100644 --- a/ReactCommon/cxxreact/JSBigString.cpp +++ b/ReactCommon/cxxreact/JSBigString.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -50,65 +50,6 @@ JSBigFileString::~JSBigFileString() { close(m_fd); } -#ifdef WITH_FBREMAP -// Read and advance the pointer. -static uint16_t read16(char *&data) { - uint16_t result; - ::memcpy(&result, data, sizeof(result)); - data += sizeof(result); - return result; -} - -// If the given file has a remapping table header, remap its pages accordingly -// and return the byte offset from the beginning to the unwrapped payload. -static off_t maybeRemap(char *data, size_t size, int fd) { - // A remapped file's size must be a multiple of its page size, so quickly - // filter out files with incorrect size, without touching any pages. - static const size_t kMinPageSize = 4096; - if (size < kMinPageSize || size % kMinPageSize != 0) { - return 0; - } - const auto begin = data; - static const uint8_t kRemapMagic[] = { - 0xc6, 0x1f, 0xbc, 0x03, 0xc1, 0x03, 0x19, 0x1f, 0xa1, 0xd0, 0xeb, 0x73}; - if (::memcmp(data, kRemapMagic, sizeof(kRemapMagic)) != 0) { - return 0; - } - data += sizeof(kRemapMagic); - const size_t filePS = static_cast(1) << read16(data); - if (size & (filePS - 1)) { - return 0; - } - { - // System page size must be at least as granular as the remapping. - // TODO: Consider fallback that reads entire file into memory. - const size_t systemPS = sysconf(_SC_PAGESIZE); - CHECK(filePS >= systemPS) - << "filePS: " << filePS << "systemPS: " << systemPS; - } - const off_t headerPages = read16(data); - uint16_t numMappings = read16(data); - size_t curFilePage = headerPages; - while (numMappings--) { - auto memPage = read16(data) + headerPages; - auto numPages = read16(data); - if (mmap( - begin + memPage * filePS, - numPages * filePS, - PROT_READ, - MAP_FILE | MAP_PRIVATE | MAP_FIXED, - fd, - curFilePage * filePS) == MAP_FAILED) { - CHECK(false) << " memPage: " << memPage << " numPages: " << numPages - << " curFilePage: " << curFilePage << " size: " << size - << " error: " << std::strerror(errno); - } - curFilePage += numPages; - } - return headerPages * filePS; -} -#endif // WITH_FBREMAP - const char *JSBigFileString::c_str() const { if (m_size == 0) { return ""; @@ -119,12 +60,6 @@ const char *JSBigFileString::c_str() const { CHECK(m_data != MAP_FAILED) << " fd: " << m_fd << " size: " << m_size << " offset: " << m_mapOff << " error: " << std::strerror(errno); -#ifdef WITH_FBREMAP - // Remapping is only attempted when the entire file was requested. - if (m_mapOff == 0 && m_pageOff == 0) { - m_pageOff = maybeRemap(const_cast(m_data), m_size, m_fd); - } -#endif // WITH_FBREMAP } static const size_t kMinPageSize = 4096; CHECK(!(reinterpret_cast(m_data) & (kMinPageSize - 1))) diff --git a/ReactCommon/cxxreact/JSBigString.h b/ReactCommon/cxxreact/JSBigString.h index c4996c47cffb3f..bd7297e992c241 100644 --- a/ReactCommon/cxxreact/JSBigString.h +++ b/ReactCommon/cxxreact/JSBigString.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -82,7 +82,7 @@ class RN_EXPORT JSBigBufferString : public JSBigString { m_data[m_size] = '\0'; } - ~JSBigBufferString() { + ~JSBigBufferString() override { delete[] m_data; } @@ -111,7 +111,7 @@ class RN_EXPORT JSBigBufferString : public JSBigString { class RN_EXPORT JSBigFileString : public JSBigString { public: JSBigFileString(int fd, size_t size, off_t offset = 0); - ~JSBigFileString(); + ~JSBigFileString() override; bool isAscii() const override { return true; diff --git a/ReactCommon/cxxreact/JSBundleType.cpp b/ReactCommon/cxxreact/JSBundleType.cpp index f76610d461a98e..036397c811356f 100644 --- a/ReactCommon/cxxreact/JSBundleType.cpp +++ b/ReactCommon/cxxreact/JSBundleType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,20 +7,21 @@ #include "JSBundleType.h" -#include - namespace facebook { namespace react { static uint32_t constexpr RAMBundleMagicNumber = 0xFB0BD1E5; -static uint32_t constexpr HBCBundleMagicNumber = 0xffe7c3c3; +static uint32_t constexpr MetroHBCBundleMagicNumber = 0xFFE7C3C3; + +// "Hermes" in ancient Greek encoded in UTF-16BE and truncated to 8 bytes. +static uint64_t constexpr HermesBCBundleMagicNumber = 0x1F1903C103BC1FC6; ScriptTag parseTypeFromHeader(const BundleHeader &header) { - switch (folly::Endian::little(header.magic)) { + switch (header.magic32.value) { case RAMBundleMagicNumber: return ScriptTag::RAMBundle; - case HBCBundleMagicNumber: - return ScriptTag::HBCBundle; + case MetroHBCBundleMagicNumber: + return ScriptTag::MetroHBCBundle; default: return ScriptTag::String; } @@ -32,11 +33,15 @@ const char *stringForScriptTag(const ScriptTag &tag) { return "String"; case ScriptTag::RAMBundle: return "RAM Bundle"; - case ScriptTag::HBCBundle: - return "HBC Bundle"; + case ScriptTag::MetroHBCBundle: + return "Metro Hermes Bytecode Bundle"; } return ""; } +bool isHermesBytecodeBundle(const BundleHeader &header) { + return header.magic64 == HermesBCBundleMagicNumber; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/cxxreact/JSBundleType.h b/ReactCommon/cxxreact/JSBundleType.h index be39711dd8d630..a9cdbc806a78dc 100644 --- a/ReactCommon/cxxreact/JSBundleType.h +++ b/ReactCommon/cxxreact/JSBundleType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,20 +19,18 @@ namespace facebook { namespace react { /* - * ScriptTag - * * Scripts given to the JS Executors to run could be in any of the following * formats. They are tagged so the executor knows how to run them. + * Hermes bytecode bundles (as encoded by hermesc, not metro) are not treated + * in a special way, they will be identified as ScriptTag::String. */ enum struct ScriptTag { String = 0, RAMBundle, - HBCBundle, + MetroHBCBundle, }; /** - * BundleHeader - * * RAM bundles and BC bundles begin with headers. For RAM bundles this is * 4 bytes, for BC bundles this is 12 bytes. This structure holds the first 12 * bytes from a bundle in a way that gives access to that information. @@ -43,27 +41,33 @@ struct FOLLY_PACK_ATTR BundleHeader { std::memset(this, 0, sizeof(BundleHeader)); } - uint32_t magic; - uint32_t reserved_; + union { + struct { + uint32_t value; + uint32_t reserved_; + } magic32; + uint64_t magic64; + }; uint32_t version; }; FOLLY_PACK_POP /** - * parseTypeFromHeader - * * Takes the first 8 bytes of a bundle, and returns a tag describing the * bundle's format. */ RN_EXPORT ScriptTag parseTypeFromHeader(const BundleHeader &header); /** - * stringForScriptTag - * * Convert an `ScriptTag` enum into a string, useful for emitting in errors * and diagnostic messages. */ RN_EXPORT const char *stringForScriptTag(const ScriptTag &tag); +/** + * Check whether a given bundle is hermesc-generated bytecode + */ +RN_EXPORT bool isHermesBytecodeBundle(const BundleHeader &header); + } // namespace react } // namespace facebook diff --git a/ReactCommon/cxxreact/JSExecutor.cpp b/ReactCommon/cxxreact/JSExecutor.cpp index f303ef161b8624..471d54ca5ecfdc 100644 --- a/ReactCommon/cxxreact/JSExecutor.cpp +++ b/ReactCommon/cxxreact/JSExecutor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/JSExecutor.h b/ReactCommon/cxxreact/JSExecutor.h index b3b29d1b326503..18125ed04274d6 100644 --- a/ReactCommon/cxxreact/JSExecutor.h +++ b/ReactCommon/cxxreact/JSExecutor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -128,7 +128,8 @@ class RN_EXPORT JSExecutor { */ virtual std::string getDescription() = 0; - virtual void handleMemoryPressure(__unused int pressureLevel) {} + virtual void handleMemoryPressure(__attribute__((unused)) int pressureLevel) { + } virtual void destroy() {} virtual ~JSExecutor() {} diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp b/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp index 9c775d06a17eea..5be7c1b446d1bd 100644 --- a/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp +++ b/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/JSIndexedRAMBundle.h b/ReactCommon/cxxreact/JSIndexedRAMBundle.h index 3045eb6a284757..a8aa34166ada38 100644 --- a/ReactCommon/cxxreact/JSIndexedRAMBundle.h +++ b/ReactCommon/cxxreact/JSIndexedRAMBundle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/JSModulesUnbundle.h b/ReactCommon/cxxreact/JSModulesUnbundle.h index 52103f7a58d28d..56376758292f7d 100644 --- a/ReactCommon/cxxreact/JSModulesUnbundle.h +++ b/ReactCommon/cxxreact/JSModulesUnbundle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/JsArgumentHelpers-inl.h b/ReactCommon/cxxreact/JsArgumentHelpers-inl.h index fa76074d0712e5..22bd10a4d60758 100644 --- a/ReactCommon/cxxreact/JsArgumentHelpers-inl.h +++ b/ReactCommon/cxxreact/JsArgumentHelpers-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/JsArgumentHelpers.h b/ReactCommon/cxxreact/JsArgumentHelpers.h index 25702ba845e5ac..9c6973e0da9736 100644 --- a/ReactCommon/cxxreact/JsArgumentHelpers.h +++ b/ReactCommon/cxxreact/JsArgumentHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/MessageQueueThread.h b/ReactCommon/cxxreact/MessageQueueThread.h index 9026a0ba870196..3313b1a0fd0554 100644 --- a/ReactCommon/cxxreact/MessageQueueThread.h +++ b/ReactCommon/cxxreact/MessageQueueThread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/MethodCall.cpp b/ReactCommon/cxxreact/MethodCall.cpp index 3a22b8994b9c4b..d3e84330075f60 100644 --- a/ReactCommon/cxxreact/MethodCall.cpp +++ b/ReactCommon/cxxreact/MethodCall.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/MethodCall.h b/ReactCommon/cxxreact/MethodCall.h index 665cd70f831842..f2fad2f025694d 100644 --- a/ReactCommon/cxxreact/MethodCall.h +++ b/ReactCommon/cxxreact/MethodCall.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/ModuleRegistry.cpp b/ReactCommon/cxxreact/ModuleRegistry.cpp index 741d97073d36b6..5a0221b02f9f87 100644 --- a/ReactCommon/cxxreact/ModuleRegistry.cpp +++ b/ReactCommon/cxxreact/ModuleRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -189,7 +189,7 @@ folly::Optional ModuleRegistry::getConfig( // no constants or methods return folly::none; } else { - return ModuleConfig{index, config}; + return ModuleConfig{index, std::move(config)}; } } diff --git a/ReactCommon/cxxreact/ModuleRegistry.h b/ReactCommon/cxxreact/ModuleRegistry.h index fba4496a621734..20e30677d40b81 100644 --- a/ReactCommon/cxxreact/ModuleRegistry.h +++ b/ReactCommon/cxxreact/ModuleRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/NativeModule.h b/ReactCommon/cxxreact/NativeModule.h index 2441953b4a040b..a088f5b7d3a797 100644 --- a/ReactCommon/cxxreact/NativeModule.h +++ b/ReactCommon/cxxreact/NativeModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/NativeToJsBridge.cpp b/ReactCommon/cxxreact/NativeToJsBridge.cpp index 3a695201057bcb..88a933915e8473 100644 --- a/ReactCommon/cxxreact/NativeToJsBridge.cpp +++ b/ReactCommon/cxxreact/NativeToJsBridge.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -52,7 +52,7 @@ class JsToNativeBridge : public react::ExecutorDelegate { } void callNativeModules( - __unused JSExecutor &executor, + __attribute__((unused)) JSExecutor &executor, folly::dynamic &&calls, bool isEndOfBatch) override { CHECK(m_registry || calls.empty()) @@ -85,7 +85,7 @@ class JsToNativeBridge : public react::ExecutorDelegate { } MethodCallResult callSerializableNativeHook( - __unused JSExecutor &executor, + __attribute__((unused)) JSExecutor &executor, unsigned int moduleId, unsigned int methodId, folly::dynamic &&args) override { diff --git a/ReactCommon/cxxreact/NativeToJsBridge.h b/ReactCommon/cxxreact/NativeToJsBridge.h index f9548c59509dbd..b8ba6a69c331d0 100644 --- a/ReactCommon/cxxreact/NativeToJsBridge.h +++ b/ReactCommon/cxxreact/NativeToJsBridge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/RAMBundleRegistry.cpp b/ReactCommon/cxxreact/RAMBundleRegistry.cpp index c19110c9ce12f8..7946334dcdb149 100644 --- a/ReactCommon/cxxreact/RAMBundleRegistry.cpp +++ b/ReactCommon/cxxreact/RAMBundleRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/RAMBundleRegistry.h b/ReactCommon/cxxreact/RAMBundleRegistry.h index 9dcb210c990d8a..d310ef1f42c139 100644 --- a/ReactCommon/cxxreact/RAMBundleRegistry.h +++ b/ReactCommon/cxxreact/RAMBundleRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/React-cxxreact.podspec b/ReactCommon/cxxreact/React-cxxreact.podspec index 14bd5eed723cff..c4498e9d3f1f80 100644 --- a/ReactCommon/cxxreact/React-cxxreact.podspec +++ b/ReactCommon/cxxreact/React-cxxreact.podspec @@ -1,5 +1,5 @@ # coding: utf-8 -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -18,7 +18,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -28,7 +28,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.source = source s.source_files = "*.{cpp,h}" s.exclude_files = "SampleCxxModule.*" diff --git a/ReactCommon/cxxreact/ReactMarker.cpp b/ReactCommon/cxxreact/ReactMarker.cpp index 1f9ce2bb5f9a87..8746a19eb83fed 100644 --- a/ReactCommon/cxxreact/ReactMarker.cpp +++ b/ReactCommon/cxxreact/ReactMarker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,7 +17,7 @@ namespace ReactMarker { #endif LogTaggedMarker logTaggedMarker = nullptr; -LogTaggedMarkerWithInstanceKey logTaggedMarkerWithInstanceKey = nullptr; +LogTaggedMarker logTaggedMarkerBridgeless = nullptr; #if __clang__ #pragma clang diagnostic pop @@ -27,6 +27,10 @@ void logMarker(const ReactMarkerId markerId) { logTaggedMarker(markerId, nullptr); } +void logMarkerBridgeless(const ReactMarkerId markerId) { + logTaggedMarkerBridgeless(markerId, nullptr); +} + } // namespace ReactMarker } // namespace react } // namespace facebook diff --git a/ReactCommon/cxxreact/ReactMarker.h b/ReactCommon/cxxreact/ReactMarker.h index 875f7b29d3984a..21d8c2a705bc46 100644 --- a/ReactCommon/cxxreact/ReactMarker.h +++ b/ReactCommon/cxxreact/ReactMarker.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,25 +33,24 @@ enum ReactMarkerId { #ifdef __APPLE__ using LogTaggedMarker = + std::function; // Bridge only +using LogTaggedMarkerBridgeless = std::function; -using LogTaggedMarkerWithInstanceKey = std::function< - void(const ReactMarkerId, const char *tag, const int instanceKey)>; #else -typedef void (*LogTaggedMarker)(const ReactMarkerId, const char *tag); -typedef void (*LogTaggedMarkerWithInstanceKey)( - const ReactMarkerId, - const char *tag, - const int instanceKey); +typedef void ( + *LogTaggedMarker)(const ReactMarkerId, const char *tag); // Bridge only +typedef void (*LogTaggedMarkerBridgeless)(const ReactMarkerId, const char *tag); #endif #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif -extern RN_EXPORT LogTaggedMarker logTaggedMarker; -extern RN_EXPORT LogTaggedMarkerWithInstanceKey logTaggedMarkerWithInstanceKey; +extern RN_EXPORT LogTaggedMarker logTaggedMarker; // Bridge only +extern RN_EXPORT LogTaggedMarker logTaggedMarkerBridgeless; -extern RN_EXPORT void logMarker(const ReactMarkerId markerId); +extern RN_EXPORT void logMarker(const ReactMarkerId markerId); // Bridge only +extern RN_EXPORT void logMarkerBridgeless(const ReactMarkerId markerId); } // namespace ReactMarker } // namespace react diff --git a/ReactCommon/cxxreact/ReactNativeVersion.h b/ReactCommon/cxxreact/ReactNativeVersion.h index d6cbbcd82a9c6d..631530267251ce 100644 --- a/ReactCommon/cxxreact/ReactNativeVersion.h +++ b/ReactCommon/cxxreact/ReactNativeVersion.h @@ -1,10 +1,10 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated by scripts/bump-oss-version.js + * @generated by scripts/set-rn-version.js */ #pragma once diff --git a/ReactCommon/cxxreact/RecoverableError.h b/ReactCommon/cxxreact/RecoverableError.h index 362fea22224403..4ea9fa9f91ff51 100644 --- a/ReactCommon/cxxreact/RecoverableError.h +++ b/ReactCommon/cxxreact/RecoverableError.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/SampleCxxModule.cpp b/ReactCommon/cxxreact/SampleCxxModule.cpp index 31acd0beac7d75..c84aa1594ec4d6 100644 --- a/ReactCommon/cxxreact/SampleCxxModule.cpp +++ b/ReactCommon/cxxreact/SampleCxxModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/SampleCxxModule.h b/ReactCommon/cxxreact/SampleCxxModule.h index e669989645f1e7..58452827501ce5 100644 --- a/ReactCommon/cxxreact/SampleCxxModule.h +++ b/ReactCommon/cxxreact/SampleCxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/SharedProxyCxxModule.h b/ReactCommon/cxxreact/SharedProxyCxxModule.h index 97d67ddf0db196..cb607d3ca5b976 100644 --- a/ReactCommon/cxxreact/SharedProxyCxxModule.h +++ b/ReactCommon/cxxreact/SharedProxyCxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/SystraceSection.h b/ReactCommon/cxxreact/SystraceSection.h index 3a59f0ed6118e0..3527f09fe7eb42 100644 --- a/ReactCommon/cxxreact/SystraceSection.h +++ b/ReactCommon/cxxreact/SystraceSection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/tests/BUCK b/ReactCommon/cxxreact/tests/BUCK index 03bb59f6277501..07373b8f0be444 100644 --- a/ReactCommon/cxxreact/tests/BUCK +++ b/ReactCommon/cxxreact/tests/BUCK @@ -1,70 +1,28 @@ load( "//tools/build_defs/oss:rn_defs.bzl", + "ANDROID", "APPLE", + "CXX", "fb_xplat_cxx_test", - "jni_instrumentation_test_lib", "react_native_xplat_target", ) -TEST_SRCS = [ - "RecoverableErrorTest.cpp", - "jsarg_helpers.cpp", - "jsbigstring.cpp", - "methodcall.cpp", -] - -jni_instrumentation_test_lib( - name = "tests", - srcs = TEST_SRCS, - class_under_test = "com/facebook/react/XplatBridgeTest", - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++14", - ], - soname = "libxplat-bridge.so", - visibility = [ - "//fbandroid/instrumentation_tests/...", - ], - deps = [ - "//xplat/folly:dynamic", - "//xplat/third-party/gmock:gtest", - "//xplat/third-party/linker_lib:android", - "//xplat/third-party/linker_lib:atomic", - react_native_xplat_target("cxxreact:bridge"), - react_native_xplat_target("cxxreact:jsbigstring"), - ], -) - fb_xplat_cxx_test( name = "tests", - srcs = TEST_SRCS, + srcs = glob(["*.cpp"]), compiler_flags = [ "-fexceptions", "-frtti", ], - platforms = APPLE, + contacts = ["oncall+react_native@xmail.facebook.com"], + platforms = (ANDROID, APPLE, CXX), visibility = [ react_native_xplat_target("cxxreact/..."), ], deps = [ - "//xplat/folly:molly", + "//xplat/folly:init_init", "//xplat/third-party/gmock:gtest", react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("cxxreact:jsbigstring"), ], ) - -fb_xplat_cxx_test( - name = "jsbigstring_test", - srcs = ["jsbigstring.cpp"], - compiler_flags = [ - "-fexceptions", - "-frtti", - ], - deps = [ - "//xplat/folly:molly", - "//xplat/third-party/gmock:gtest", - react_native_xplat_target("cxxreact:jsbigstring"), - ], -) diff --git a/ReactCommon/cxxreact/tests/RecoverableErrorTest.cpp b/ReactCommon/cxxreact/tests/RecoverableErrorTest.cpp index cba8d16f70eb65..004859cce727e4 100644 --- a/ReactCommon/cxxreact/tests/RecoverableErrorTest.cpp +++ b/ReactCommon/cxxreact/tests/RecoverableErrorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/cxxreact/tests/jsarg_helpers.cpp b/ReactCommon/cxxreact/tests/jsarg_helpers.cpp index c49a65b47d7fc3..82a99a05fa0cc6 100644 --- a/ReactCommon/cxxreact/tests/jsarg_helpers.cpp +++ b/ReactCommon/cxxreact/tests/jsarg_helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,9 +12,8 @@ #include #include -using namespace std; -using namespace folly; using namespace facebook::xplat; +using dynamic = folly::dynamic; #define EXPECT_JSAE(statement, exstr) \ do { \ @@ -30,10 +29,10 @@ TEST(JsArgumentHelpersTest, args) { const bool aBool = true; const int64_t anInt = 17; const double aDouble = 3.14; - const string aString = "word"; + const std::string aString = "word"; const dynamic anArray = dynamic::array("a", "b", "c"); const dynamic anObject = dynamic::object("k1", "v1")("k2", "v2"); - const string aNumericString = to(anInt); + const std::string aNumericString = folly::to(anInt); folly::dynamic args = dynamic::array( aBool, anInt, aDouble, aString, anArray, anObject, aNumericString); diff --git a/ReactCommon/cxxreact/tests/jsbigstring.cpp b/ReactCommon/cxxreact/tests/jsbigstring.cpp index de5aaad38ab694..7ffa42a47f9d30 100644 --- a/ReactCommon/cxxreact/tests/jsbigstring.cpp +++ b/ReactCommon/cxxreact/tests/jsbigstring.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,7 +12,6 @@ #include #include -using namespace facebook; using namespace facebook::react; namespace { @@ -62,45 +61,3 @@ TEST(JSBigFileString, MapPartTest) { EXPECT_EQ(needle[i], bigStr.c_str()[i]); } } - -TEST(JSBigFileString, RemapTest) { - static const uint8_t kRemapMagic[] = { - 0xc6, 0x1f, 0xbc, 0x03, 0xc1, 0x03, 0x19, 0x1f, 0xa1, 0xd0, 0xeb, 0x73}; - std::string data(std::begin(kRemapMagic), std::end(kRemapMagic)); - auto app = [&data](uint16_t v) { - data.append(reinterpret_cast(&v), sizeof(v)); - }; - size_t pageSizeLog2 = 16; - app(pageSizeLog2); - size_t pageSize = 1 << pageSizeLog2; - app(1); // header pages - app(2); // num mappings - // file page 0 -> memory page 1 - app(1); // memory page - app(1); // num pages - // file page 1 -> memory page 0 - app(0); // memory page - app(1); // num pages - while (data.size() < pageSize) { - app(0); - } - while (data.size() < pageSize * 2) { - app(0x1111); - } - while (data.size() < pageSize * 3) { - app(0x2222); - } - - int fd = tempFileFromString(data); - JSBigFileString bigStr{fd, data.size()}; - - EXPECT_EQ(pageSize * 2, bigStr.size()); - auto remapped = bigStr.c_str(); - size_t i = 0; - for (; i < pageSize; ++i) { - EXPECT_EQ(0x22, remapped[i]); - } - for (; i < pageSize * 2; ++i) { - EXPECT_EQ(0x11, remapped[i]); - } -} diff --git a/ReactCommon/cxxreact/tests/main.cpp b/ReactCommon/cxxreact/tests/main.cpp new file mode 100644 index 00000000000000..d0d05052717c40 --- /dev/null +++ b/ReactCommon/cxxreact/tests/main.cpp @@ -0,0 +1,15 @@ +/* + * 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. + */ + +#include +#include + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + folly::init(&argc, &argv); + return RUN_ALL_TESTS(); +} diff --git a/ReactCommon/cxxreact/tests/methodcall.cpp b/ReactCommon/cxxreact/tests/methodcall.cpp index 3035548d417e66..ff5bcec8ab0f30 100644 --- a/ReactCommon/cxxreact/tests/methodcall.cpp +++ b/ReactCommon/cxxreact/tests/methodcall.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,9 +13,8 @@ #include #pragma GCC diagnostic pop -using namespace facebook; using namespace facebook::react; -using namespace folly; +using dynamic = folly::dynamic; TEST(parseMethodCalls, SingleReturnCallNoArgs) { auto jsText = "[[7],[3],[[]]]"; diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec index 50eaa2ad3fb37e..d08e5b68a7cab7 100644 --- a/ReactCommon/hermes/React-hermes.podspec +++ b/ReactCommon/hermes/React-hermes.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :osx => "10.14", :ios => "11.0" } + s.platforms = { :osx => "10.14", :ios => "12.4" } s.source = source s.source_files = "executor/*.{cpp,h}", "inspector/*.{cpp,h}", diff --git a/ReactCommon/hermes/executor/Android.mk b/ReactCommon/hermes/executor/Android.mk deleted file mode 100644 index 52b4d25085f74e..00000000000000 --- a/ReactCommon/hermes/executor/Android.mk +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../.. - -include $(REACT_NATIVE)/ReactCommon/common.mk -include $(CLEAR_VARS) - -LOCAL_MODULE := hermes-executor-common-release - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-node-module,$(LOCAL_PATH),hermes-engine)/android/include -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_STATIC_LIBRARIES := libjsireact -LOCAL_SHARED_LIBRARIES := libhermes libjsi - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_MODULE := hermes-executor-common-debug -LOCAL_CFLAGS := -DHERMES_ENABLE_DEBUGGER=1 - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-node-module,$(LOCAL_PATH),hermes-engine)/android/include -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_STATIC_LIBRARIES := libjsireact libhermes-inspector -LOCAL_SHARED_LIBRARIES := libhermes libjsi - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/hermes/executor/CMakeLists.txt b/ReactCommon/hermes/executor/CMakeLists.txt new file mode 100644 index 00000000000000..a6d8bbac1ddf01 --- /dev/null +++ b/ReactCommon/hermes/executor/CMakeLists.txt @@ -0,0 +1,29 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp) +add_library( + hermes-executor-common + STATIC + ${hermes_executor_SRC} +) +target_include_directories(hermes-executor-common PUBLIC .) +target_link_libraries(hermes-executor-common + jsireact + hermes-engine::libhermes + jsi + debug hermes-inspector +) + +if(${CMAKE_BUILD_TYPE} MATCHES Debug) + target_compile_options( + hermes-executor-common + PRIVATE + -DHERMES_ENABLE_DEBUGGER=1 + ) +endif() diff --git a/ReactCommon/hermes/executor/HermesExecutorFactory.cpp b/ReactCommon/hermes/executor/HermesExecutorFactory.cpp index 693a9a1bd73caf..e1ab6c8cdcc647 100644 --- a/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +++ b/ReactCommon/hermes/executor/HermesExecutorFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -171,7 +171,7 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator { ~DecoratedRuntime() { #ifdef HERMES_ENABLE_DEBUGGER - facebook::hermes::inspector::chrome::disableDebugging(hermesRuntime_); + facebook::hermes::inspector::chrome::disableDebugging(*runtime_); #endif } diff --git a/ReactCommon/hermes/executor/HermesExecutorFactory.h b/ReactCommon/hermes/executor/HermesExecutorFactory.h index 99d3eb34f4e5d3..5d4468e3668bd1 100644 --- a/ReactCommon/hermes/executor/HermesExecutorFactory.h +++ b/ReactCommon/hermes/executor/HermesExecutorFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/executor/JSITracing.cpp b/ReactCommon/hermes/executor/JSITracing.cpp index 58f910f2826cb2..3c013cf94e42cb 100644 --- a/ReactCommon/hermes/executor/JSITracing.cpp +++ b/ReactCommon/hermes/executor/JSITracing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/executor/JSITracing.h b/ReactCommon/hermes/executor/JSITracing.h index e018144be4e093..13505637c1c0dc 100644 --- a/ReactCommon/hermes/executor/JSITracing.h +++ b/ReactCommon/hermes/executor/JSITracing.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/Android.mk b/ReactCommon/hermes/inspector/Android.mk deleted file mode 100644 index 461b10aaac3323..00000000000000 --- a/ReactCommon/hermes/inspector/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../.. - -include $(REACT_NATIVE)/ReactCommon/common.mk -include $(CLEAR_VARS) - -LOCAL_MODULE := hermes-inspector - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/detail/*.cpp $(LOCAL_PATH)/chrome/*.cpp) - -LOCAL_C_ROOT := $(LOCAL_PATH)/../.. - -LOCAL_CFLAGS := -DHERMES_ENABLE_DEBUGGER=1 -DHERMES_INSPECTOR_FOLLY_KLUDGE=1 -LOCAL_C_INCLUDES := $(LOCAL_C_ROOT) $(REACT_NATIVE)/ReactCommon/jsi $(call find-node-module,$(LOCAL_PATH),hermes-engine)/android/include -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_ROOT) - -LOCAL_CPP_FEATURES := exceptions - -LOCAL_SHARED_LIBRARIES := jsinspector libfb libfbjni libfolly_futures libfolly_json libhermes libjsi libglog - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/hermes/inspector/AsyncPauseState.h b/ReactCommon/hermes/inspector/AsyncPauseState.h index 757605785929cf..b040780f5c90d7 100644 --- a/ReactCommon/hermes/inspector/AsyncPauseState.h +++ b/ReactCommon/hermes/inspector/AsyncPauseState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/BUCK b/ReactCommon/hermes/inspector/BUCK index 0ff039ceb1e37a..9099fb6e59da2a 100644 --- a/ReactCommon/hermes/inspector/BUCK +++ b/ReactCommon/hermes/inspector/BUCK @@ -1,10 +1,8 @@ -# Copyright 2004-present Facebook. All Rights Reserved. - load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary") load("@fbsource//tools/build_defs:fb_xplat_cxx_library.bzl", "fb_xplat_cxx_library") load("@fbsource//tools/build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test") load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "APPLE", "CXX", "FBCODE", "WINDOWS") -load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_target") +load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "get_hermes_shared_library_preprocessor_flags", "react_native_xplat_target") load("@fbsource//xplat/hermes/defs:hermes.bzl", "hermes_build_mode", "hermes_optimize_flag") CFLAGS_BY_MODE = { @@ -197,6 +195,7 @@ fb_xplat_cxx_library( labels = ["supermodule:xplat/default/public.hermes"], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS), + preprocessor_flags = get_hermes_shared_library_preprocessor_flags(), visibility = [ "PUBLIC", ], diff --git a/ReactCommon/hermes/inspector/CMakeLists.txt b/ReactCommon/hermes/inspector/CMakeLists.txt new file mode 100644 index 00000000000000..14f6f1ce263900 --- /dev/null +++ b/ReactCommon/hermes/inspector/CMakeLists.txt @@ -0,0 +1,32 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB hermesinspector_SRC CONFIGURE_DEPENDS *.cpp detail/*.cpp chrome/*.cpp) + +add_library(hermes-inspector + STATIC + ${hermesinspector_SRC}) + +target_compile_options( + hermes-inspector + PRIVATE + -DHERMES_ENABLE_DEBUGGER=1 + -DHERMES_INSPECTOR_FOLLY_KLUDGE=1 + -fexceptions +) + +target_include_directories(hermes-inspector PUBLIC ${REACT_COMMON_DIR}) +target_link_libraries(hermes-inspector + jsinspector + fb + fbjni + folly_futures + folly_runtime + glog + hermes-engine::libhermes + jsi) diff --git a/ReactCommon/hermes/inspector/Exceptions.h b/ReactCommon/hermes/inspector/Exceptions.h index b47f45c83f93df..928b795448ecdb 100644 --- a/ReactCommon/hermes/inspector/Exceptions.h +++ b/ReactCommon/hermes/inspector/Exceptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,6 +47,12 @@ class MultipleCommandsPendingException : public std::runtime_error { ": a step or resume is already pending") {} }; +class UserCallbackException : public std::runtime_error { + public: + UserCallbackException(const std::exception &e) + : std::runtime_error(std::string("callback exception: ") + e.what()) {} +}; + } // namespace inspector } // namespace hermes } // namespace facebook diff --git a/ReactCommon/hermes/inspector/Inspector.cpp b/ReactCommon/hermes/inspector/Inspector.cpp index 1b5a09d356355f..8ec9f82b6b8ab8 100644 --- a/ReactCommon/hermes/inspector/Inspector.cpp +++ b/ReactCommon/hermes/inspector/Inspector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -589,8 +589,11 @@ void Inspector::executeIfEnabledOnExecutor( state_->pushPendingFunc( [wrappedFunc = std::move(wrappedFunc), promise]() mutable { - wrappedFunc(); - promise->setValue(); + if (auto userCallbackException = runUserCallback(wrappedFunc)) { + promise->setException(*userCallbackException); + } else { + promise->setValue(); + } }); } diff --git a/ReactCommon/hermes/inspector/Inspector.h b/ReactCommon/hermes/inspector/Inspector.h index a55f1c45b9cfb0..648499207f6463 100644 --- a/ReactCommon/hermes/inspector/Inspector.h +++ b/ReactCommon/hermes/inspector/Inspector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,11 +15,13 @@ #include #include +#include #include #include #include #include #include +#include #include namespace facebook { @@ -363,6 +365,18 @@ class Inspector : public facebook::hermes::debugger::EventObserver, std::unique_ptr executor_; }; +/// Helper function that guards user code execution in a try-catch block. +template +folly::Optional runUserCallback(C &cb, A &&...arg) { + try { + cb(std::forward(arg)...); + } catch (const std::exception &e) { + return UserCallbackException(e); + } + + return {}; +} + } // namespace inspector } // namespace hermes } // namespace facebook diff --git a/ReactCommon/hermes/inspector/InspectorState.cpp b/ReactCommon/hermes/inspector/InspectorState.cpp index a52e2ac25f0bbc..8ee53e9005c808 100644 --- a/ReactCommon/hermes/inspector/InspectorState.cpp +++ b/ReactCommon/hermes/inspector/InspectorState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -249,10 +249,14 @@ std::pair InspectorState::Running::didPause( } else if (reason == debugger::PauseReason::EvalComplete) { assert(pendingEvalPromise_); - pendingEvalResultTransformer_( - inspector_.debugger_.getProgramState().getEvalResult()); - pendingEvalPromise_->setValue( - inspector_.debugger_.getProgramState().getEvalResult()); + if (auto userCallbackException = runUserCallback( + pendingEvalResultTransformer_, + inspector_.debugger_.getProgramState().getEvalResult())) { + pendingEvalPromise_->setException(*userCallbackException); + } else { + pendingEvalPromise_->setValue( + inspector_.debugger_.getProgramState().getEvalResult()); + } pendingEvalPromise_.reset(); } else if ( reason == debugger::PauseReason::Breakpoint && @@ -364,10 +368,14 @@ std::pair InspectorState::Paused::didPause( break; case debugger::PauseReason::EvalComplete: { assert(pendingEvalPromise_); - pendingEvalResultTransformer_( - inspector_.debugger_.getProgramState().getEvalResult()); - pendingEvalPromise_->setValue( - inspector_.debugger_.getProgramState().getEvalResult()); + if (auto userCallbackException = runUserCallback( + pendingEvalResultTransformer_, + inspector_.debugger_.getProgramState().getEvalResult())) { + pendingEvalPromise_->setException(*userCallbackException); + } else { + pendingEvalPromise_->setValue( + inspector_.debugger_.getProgramState().getEvalResult()); + } pendingEvalPromise_.reset(); } break; case debugger::PauseReason::ScriptLoaded: diff --git a/ReactCommon/hermes/inspector/InspectorState.h b/ReactCommon/hermes/inspector/InspectorState.h index 67a8fbede47418..f5fac9ea006a12 100644 --- a/ReactCommon/hermes/inspector/InspectorState.h +++ b/ReactCommon/hermes/inspector/InspectorState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/RuntimeAdapter.cpp b/ReactCommon/hermes/inspector/RuntimeAdapter.cpp index ce0baa79ada78a..d88ff8256b9bb1 100644 --- a/ReactCommon/hermes/inspector/RuntimeAdapter.cpp +++ b/ReactCommon/hermes/inspector/RuntimeAdapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/RuntimeAdapter.h b/ReactCommon/hermes/inspector/RuntimeAdapter.h index dcf8a008b88a22..c07882470239c4 100644 --- a/ReactCommon/hermes/inspector/RuntimeAdapter.h +++ b/ReactCommon/hermes/inspector/RuntimeAdapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -66,7 +66,7 @@ class INSPECTOR_EXPORT SharedRuntimeAdapter : public RuntimeAdapter { SharedRuntimeAdapter( std::shared_ptr runtime, debugger::Debugger &debugger); - virtual ~SharedRuntimeAdapter(); + ~SharedRuntimeAdapter() override; jsi::Runtime &getRuntime() override; debugger::Debugger &getDebugger() override; diff --git a/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.cpp b/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.cpp index 70d7e5ebcd561d..6b787aa510526a 100644 --- a/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.cpp +++ b/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.h b/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.h index cb501e68e5a81d..8fe0710380b244 100644 --- a/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.h +++ b/ReactCommon/hermes/inspector/chrome/AutoAttachUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/Connection.cpp b/ReactCommon/hermes/inspector/chrome/Connection.cpp index 572a07cc2826f6..b7b264093b221d 100644 --- a/ReactCommon/hermes/inspector/chrome/Connection.cpp +++ b/ReactCommon/hermes/inspector/chrome/Connection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -100,11 +101,18 @@ class Connection::Impl : public inspector::InspectorObserver, void handle( const m::heapProfiler::GetObjectByHeapObjectIdRequest &req) override; void handle(const m::heapProfiler::GetHeapObjectIdRequest &req) override; + void handle(const m::profiler::StartRequest &req) override; + void handle(const m::profiler::StopRequest &req) override; + void handle(const m::runtime::CallFunctionOnRequest &req) override; void handle(const m::runtime::EvaluateRequest &req) override; + void handle(const m::runtime::GetHeapUsageRequest &req) override; void handle(const m::runtime::GetPropertiesRequest &req) override; void handle(const m::runtime::RunIfWaitingForDebuggerRequest &req) override; private: + // The execution context id reported back by the ExecutionContextCreated + // notification. We only ever expect this execution context id. + static constexpr int32_t kHermesExecutionContextId = 1; std::vector makePropsFromScope( std::pair frameAndScopeIndex, const std::string &objectGroup, @@ -129,6 +137,11 @@ class Connection::Impl : public inspector::InspectorObserver, void sendNotificationToClientViaExecutor(const m::Notification ¬e); void sendErrorToClientViaExecutor(int id, const std::string &error); + template + void runInExecutor(int id, C callback) { + folly::via(executor_.get(), [cb = std::move(callback)]() { cb(); }); + } + std::shared_ptr runtimeAdapter_; std::string title_; @@ -291,7 +304,7 @@ void Connection::Impl::onContextCreated(Inspector &inspector) { // Right now, Hermes only has the notion of one JS context per VM instance, // so we just always name the single JS context with id=1 and name=hermes. m::runtime::ExecutionContextCreatedNotification note; - note.context.id = 1; + note.context.id = kHermesExecutionContextId; note.context.name = "hermes"; sendNotificationToClientViaExecutor(note); @@ -370,6 +383,8 @@ void Connection::Impl::onScriptParsed( m::debugger::ScriptParsedNotification note; note.scriptId = folly::to(info.fileId); note.url = info.fileName; + // TODO(jpporto): fix test cases sending invalid context id. + // note.executionContextId = kHermesExecutionContextId; if (!info.sourceMappingUrl.empty()) { note.sourceMapURL = info.sourceMappingUrl; @@ -397,6 +412,8 @@ void Connection::Impl::onMessageAdded( const ConsoleMessageInfo &info) { m::runtime::ConsoleAPICalledNotification apiCalledNote; apiCalledNote.type = info.level; + // TODO(jpporto): fix test cases sending invalid context id. + // apiCalledNote.executionContextId = kHermesExecutionContextId; size_t argsSize = info.args.size(getRuntime()); for (size_t index = 0; index < argsSize; ++index) { @@ -711,6 +728,369 @@ void Connection::Impl::handle( .thenError(sendErrorToClient(req.id)); } +void Connection::Impl::handle(const m::profiler::StartRequest &req) { + auto *hermesRT = dynamic_cast(&getRuntime()); + + if (!hermesRT) { + sendResponseToClientViaExecutor(m::makeErrorResponse( + req.id, m::ErrorCode::ServerError, "Unhandled Runtime kind.")); + return; + } + + runInExecutor(req.id, [this, id = req.id]() { + HermesRuntime::enableSamplingProfiler(); + sendResponseToClient(m::makeOkResponse(id)); + }); +} + +void Connection::Impl::handle(const m::profiler::StopRequest &req) { + auto *hermesRT = dynamic_cast(&getRuntime()); + + if (!hermesRT) { + sendResponseToClientViaExecutor(m::makeErrorResponse( + req.id, m::ErrorCode::ServerError, "Unhandled Runtime kind.")); + return; + } + + runInExecutor(req.id, [this, id = req.id, hermesRT]() { + HermesRuntime::disableSamplingProfiler(); + + std::ostringstream profileStream; + // HermesRuntime instance methods are usually unsafe to be called with a + // running VM, but sampledTraceToStreamInDevToolsFormat is an exception to + // that rule -- it synchronizes access to shared resources so it can be + // safely invoked with a running VM. + hermesRT->sampledTraceToStreamInDevToolsFormat(profileStream); + + // Hermes can emit the proper format directly, but it still needs to + // be parsed into a dynamic. + try { + m::profiler::StopResponse resp; + resp.id = id; + // parseJson throws on errors, so make sure we don't crash the app + // if somehow the sampling profiler output is borked. + resp.profile = m::profiler::Profile( + folly::parseJson(std::move(profileStream).str())); + sendResponseToClient(resp); + } catch (const std::exception &) { + LOG(ERROR) << "Failed to parse Sampling Profiler output"; + sendResponseToClient(m::makeErrorResponse( + id, + m::ErrorCode::InternalError, + "Hermes profile output could not be parsed.")); + } + }); +} + +namespace { +/// Runtime.CallArguments can have their values specified "inline", or they can +/// have remote references. The inline values are eval'd together with the +/// Runtime.CallFunctionOn.functionDeclaration (see CallFunctionOnBuilder +/// below), while remote object Ids need to be resolved outside of the VM. +class CallFunctionOnArgument { + public: + explicit CallFunctionOnArgument( + folly::Optional maybeObjectId) + : maybeObjectId_(std::move(maybeObjectId)) {} + + /// Computes the real value for this argument, which can be an object + /// referenced by maybeObjectId_, or the given evaldValue. Throws if + /// maybeObjectId_ is not empty but references an unknown object. + jsi::Value value( + jsi::Runtime &rt, + RemoteObjectsTable &objTable, + jsi::Value evaldValue) const { + if (maybeObjectId_) { + assert(evaldValue.isUndefined() && "expected undefined placeholder"); + return getValueFromId(rt, objTable, *maybeObjectId_); + } + + return evaldValue; + } + + private: + /// Returns the jsi::Object for the given objId. Throws if such object can't + /// be found. + static jsi::Value getValueFromId( + jsi::Runtime &rt, + RemoteObjectsTable &objTable, + m::runtime::RemoteObjectId objId) { + if (const jsi::Value *ptr = objTable.getValue(objId)) { + return jsi::Value(rt, *ptr); + } + + throw std::runtime_error("unknown object id " + objId); + } + + folly::Optional maybeObjectId_; +}; + +/// Functor that should be used to run the result of eval-ing a CallFunctionOn +/// request. +class CallFunctionOnRunner { + public: + static constexpr size_t kJsThisIndex = 0; + static constexpr size_t kFirstArgIndex = 1; + + // N.B.: constexpr char[] broke react-native-oss-android. + static const char *kJsThisArgPlaceholder; + + CallFunctionOnRunner() = default; + CallFunctionOnRunner(CallFunctionOnRunner &&) = default; + CallFunctionOnRunner &operator=(CallFunctionOnRunner &&) = default; + + /// Performs the actual Runtime.CallFunctionOn request. It assumes. + /// \p evalResult is the result of invoking the Inspector's evaluate() method + /// on the expression built by the CallFunctionOnBuilder below. + jsi::Value operator()( + jsi::Runtime &rt, + RemoteObjectsTable &objTable, + const facebook::hermes::debugger::EvalResult &evalResult) { + // The eval result is an array [a0, a1, ..., an, func] (see + // CallFunctionOnBuilder below). + auto argsAndFunc = evalResult.value.getObject(rt).getArray(rt); + assert( + argsAndFunc.length(rt) == thisAndArguments_.size() + 1 && + "Unexpected result size"); + + // now resolve the arguments to the call, including "this". + std::vector arguments(thisAndArguments_.size() - 1); + + jsi::Object jsThis = + getJsThis(rt, objTable, argsAndFunc.getValueAtIndex(rt, kJsThisIndex)); + + int i = kFirstArgIndex; + for (/*i points to the first param*/; i < thisAndArguments_.size(); ++i) { + arguments[i - kFirstArgIndex] = thisAndArguments_[i].value( + rt, objTable, argsAndFunc.getValueAtIndex(rt, i)); + } + + // i is now func's index. + jsi::Function func = + argsAndFunc.getValueAtIndex(rt, i).getObject(rt).getFunction(rt); + + return func.callWithThis( + rt, + std::move(jsThis), + static_cast(arguments.data()), + arguments.size()); + } + + private: + friend class CallFunctionOnBuilder; + + CallFunctionOnRunner(const CallFunctionOnRunner &) = delete; + CallFunctionOnRunner &operator=(const CallFunctionOnRunner &) = delete; + + CallFunctionOnRunner( + std::vector thisAndArguments, + folly::Optional executionContextId) + : thisAndArguments_(std::move(thisAndArguments)), + executionContextId_(std::move(executionContextId)) {} + + /// Resolves the js "this" for the request, which lives in + /// thisAndArguments_[kJsThisIndex]. \p evaldThis should either be undefined, + /// or the placeholder indicating that globalThis should be used. + jsi::Object getJsThis( + jsi::Runtime &rt, + RemoteObjectsTable &objTable, + jsi::Value evaldThis) const { + // In the future we may support multiple execution context ids; for now, + // there's only one. + (void)executionContextId_; + + // Either evaldThis is undefined (because the request had an object id + // specifying "this"), or it should be a string (i.e., the placeholder + // kJsThisArgPlaceholder). + assert( + (evaldThis.isUndefined() || + (evaldThis.isString() && + evaldThis.getString(rt).utf8(rt) == kJsThisArgPlaceholder)) && + "unexpected value for jsThis argument placeholder"); + + // Need to save this information because of the std::move() below. + const bool useGlobalThis = evaldThis.isString(); + jsi::Value value = thisAndArguments_[kJsThisIndex].value( + rt, objTable, std::move(evaldThis)); + + return useGlobalThis ? rt.global() : value.getObject(rt); + } + + std::vector thisAndArguments_; + folly::Optional executionContextId_; +}; + +/*static*/ const char *CallFunctionOnRunner::kJsThisArgPlaceholder = + "jsThis is Execution Context"; + +/// Returns true if \p str is a number-like string value (e.g., Infinity), +/// and false otherwise. +bool unserializableValueLooksLikeNumber(const std::string &str) { + return str == "Infinity" || str == "-Infinity" || str == "NaN"; +} + +/// Helper class that processes a Runtime.CallFunctionOn request, and +/// builds an expression string that, once eval()d, yields an Array with the +/// CallArguments as well as the function to run. The generated array is +/// +/// [JsThis, P0, P1, P2, P3, Pn, F] +/// +/// where: +/// * F is the functionDeclaration in the request +/// * JsThis is either: +/// * undefined (if the request has an object ID); or +/// * the placeholder kJsThisArgPlaceholder +/// * Pi is either: +/// * the string in CallArgument[i].unserializableValue; or +/// * the string in CallArgument[i].value; or +/// * arguments[j] (i.e., the j-th argument passed to the newly built +/// function), j being the j-th CallArgument with an ObjectId. This is +/// needed because there's no easy way to express the objects referred +/// to by object ids by name. +class CallFunctionOnBuilder { + public: + explicit CallFunctionOnBuilder(const m::runtime::CallFunctionOnRequest &req) + : executionContextId_(req.executionContextId) { + out_ << "["; + thisAndArguments_.emplace_back(CallFunctionOnArgument(req.objectId)); + if (req.objectId) { + out_ << "undefined, "; + } else { + out_ << '\'' << CallFunctionOnRunner::kJsThisArgPlaceholder << "', "; + } + + addParams(req.arguments); + out_ << req.functionDeclaration; + out_ << "]"; + }; + + /// Extracts the functions that handles the CallFunctionOn requests, as well + /// as the list of object ids that must be passed when calling it. + std::pair expressionAndRunner() && { + return std::make_pair( + std::move(out_).str(), + CallFunctionOnRunner( + std::move(thisAndArguments_), std::move(executionContextId_))); + } + + private: + void addParams(const folly::Optional> + &maybeArguments) { + if (maybeArguments) { + for (const auto &ca : *maybeArguments) { + addParam(ca); + thisAndArguments_.emplace_back(CallFunctionOnArgument(ca.objectId)); + out_ << ", "; + } + } + } + + void addParam(const m::runtime::CallArgument &ca) { + if (ca.objectId) { + out_ << "undefined"; + } else if (ca.value) { + // TODO: this may throw if ca.value is a CBOR (see RFC 8949), but the + // chrome debugger doesn't seem to send those. + out_ << "(" << folly::toJson(*ca.value) << ")"; + } else if (ca.unserializableValue) { + if (unserializableValueLooksLikeNumber(*ca.unserializableValue)) { + out_ << "+(" << *ca.unserializableValue << ")"; + } else { + out_ << *ca.unserializableValue; + } + } else { + throw std::runtime_error("unknown payload for CallParam"); + } + } + + std::ostringstream out_; + + std::vector thisAndArguments_; + folly::Optional executionContextId_; +}; + +} // namespace + +void Connection::Impl::handle(const m::runtime::CallFunctionOnRequest &req) { + std::string expression; + CallFunctionOnRunner runner; + + auto validateAndParseRequest = + [&expression, &runner](const m::runtime::CallFunctionOnRequest &req) + -> folly::Optional { + if (req.objectId.hasValue() == req.executionContextId.hasValue()) { + return std::string( + "The request must specify either object id or execution context id."); + } + + if (!req.objectId) { + assert( + req.executionContextId && + "should not be here if both object id and execution context id are missing"); + if (*req.executionContextId != kHermesExecutionContextId) { + return "unknown execution context id " + + std::to_string(*req.executionContextId); + } + } + + try { + std::tie(expression, runner) = + CallFunctionOnBuilder(req).expressionAndRunner(); + } catch (const std::exception &e) { + return std::string(e.what()); + } + + return {}; + }; + + if (auto errMsg = validateAndParseRequest(req)) { + sendErrorToClientViaExecutor(req.id, *errMsg); + return; + } + + auto remoteObjPtr = std::make_shared(); + inspector_ + ->evaluate( + 0, // Top of the stackframe + expression, + [this, + remoteObjPtr, + objectGroup = req.objectGroup, + jsThisId = req.objectId, + executionContextId = req.executionContextId, + byValue = req.returnByValue.value_or(false), + runner = + std::move(runner)](const facebook::hermes::debugger::EvalResult + &evalResult) mutable { + if (evalResult.isException) { + return; + } + + *remoteObjPtr = m::runtime::makeRemoteObject( + getRuntime(), + runner(getRuntime(), objTable_, evalResult), + objTable_, + objectGroup.value_or("ConsoleObjectGroup"), + byValue); + }) + .via(executor_.get()) + .thenValue( + [this, id = req.id, remoteObjPtr](debugger::EvalResult result) { + m::debugger::EvaluateOnCallFrameResponse resp; + resp.id = id; + + if (result.isException) { + resp.exceptionDetails = + m::runtime::makeExceptionDetails(result.exceptionDetails); + } else { + resp.result = *remoteObjPtr; + } + + sendResponseToClient(resp); + }) + .thenError(sendErrorToClient(req.id)); +} + void Connection::Impl::handle(const m::runtime::EvaluateRequest &req) { auto remoteObjPtr = std::make_shared(); @@ -1030,6 +1410,23 @@ Connection::Impl::makePropsFromValue( return result; } +void Connection::Impl::handle(const m::runtime::GetHeapUsageRequest &req) { + auto resp = std::make_shared(); + resp->id = req.id; + + inspector_ + ->executeIfEnabled( + "Runtime.getHeapUsage", + [this, req, resp](const debugger::ProgramState &state) { + auto heapInfo = getRuntime().instrumentation().getHeapInfo(false); + resp->usedSize = heapInfo["hermes_allocatedBytes"]; + resp->totalSize = heapInfo["hermes_heapSize"]; + }) + .via(executor_.get()) + .thenValue([this, resp](auto &&) { sendResponseToClient(*resp); }) + .thenError(sendErrorToClient(req.id)); +} + void Connection::Impl::handle(const m::runtime::GetPropertiesRequest &req) { auto resp = std::make_shared(); resp->id = req.id; diff --git a/ReactCommon/hermes/inspector/chrome/Connection.h b/ReactCommon/hermes/inspector/chrome/Connection.h index 0e49e69e0b0d2c..92dbbdf4a3a6e4 100644 --- a/ReactCommon/hermes/inspector/chrome/Connection.h +++ b/ReactCommon/hermes/inspector/chrome/Connection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp b/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp index 62675f336b110a..7b35662eec8c60 100644 --- a/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp +++ b/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -94,7 +94,7 @@ int ConnectionDemux::enableDebugging( std::make_shared(std::move(adapter), title, waitForDebugger)); } -void ConnectionDemux::disableDebugging(HermesRuntime &runtime) { +void ConnectionDemux::disableDebugging(jsi::Runtime &runtime) { std::lock_guard lock(mutex_); for (auto &it : conns_) { diff --git a/ReactCommon/hermes/inspector/chrome/ConnectionDemux.h b/ReactCommon/hermes/inspector/chrome/ConnectionDemux.h index cf07d23a295869..7ade9eb89c3262 100644 --- a/ReactCommon/hermes/inspector/chrome/ConnectionDemux.h +++ b/ReactCommon/hermes/inspector/chrome/ConnectionDemux.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -39,7 +39,7 @@ class ConnectionDemux { int enableDebugging( std::unique_ptr adapter, const std::string &title); - void disableDebugging(HermesRuntime &runtime); + void disableDebugging(jsi::Runtime &runtime); private: int addPage(std::shared_ptr conn); diff --git a/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp b/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp index 711a05cdced6bd..3ffc17d0b5aab7 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp +++ b/ReactCommon/hermes/inspector/chrome/MessageConverters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/MessageConverters.h b/ReactCommon/hermes/inspector/chrome/MessageConverters.h index 3622568ae3f981..d2f90a482acdf2 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageConverters.h +++ b/ReactCommon/hermes/inspector/chrome/MessageConverters.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/MessageInterfaces.h b/ReactCommon/hermes/inspector/chrome/MessageInterfaces.h index 4ad37dc3b80a42..46cdd7388bde48 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageInterfaces.h +++ b/ReactCommon/hermes/inspector/chrome/MessageInterfaces.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/MessageTypes.cpp b/ReactCommon/hermes/inspector/chrome/MessageTypes.cpp index 484719e130e7b6..551874682ba535 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageTypes.cpp +++ b/ReactCommon/hermes/inspector/chrome/MessageTypes.cpp @@ -1,5 +1,5 @@ -// Copyright 2004-present Facebook. All Rights Reserved. -// @generated SignedSource<<522f29c54f207a4f7b5c33af07cf64d0>> +// Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. +// @generated SignedSource<> #include "MessageTypes.h" @@ -60,7 +60,11 @@ std::unique_ptr Request::fromJsonThrowOnError(const std::string &str) { makeUnique}, {"HeapProfiler.takeHeapSnapshot", makeUnique}, + {"Profiler.start", makeUnique}, + {"Profiler.stop", makeUnique}, + {"Runtime.callFunctionOn", makeUnique}, {"Runtime.evaluate", makeUnique}, + {"Runtime.getHeapUsage", makeUnique}, {"Runtime.getProperties", makeUnique}, {"Runtime.runIfWaitingForDebugger", makeUnique}, @@ -274,6 +278,74 @@ dynamic heapProfiler::SamplingHeapProfile::toDynamic() const { return obj; } +profiler::PositionTickInfo::PositionTickInfo(const dynamic &obj) { + assign(line, obj, "line"); + assign(ticks, obj, "ticks"); +} + +dynamic profiler::PositionTickInfo::toDynamic() const { + dynamic obj = dynamic::object; + + put(obj, "line", line); + put(obj, "ticks", ticks); + return obj; +} + +profiler::ProfileNode::ProfileNode(const dynamic &obj) { + assign(id, obj, "id"); + assign(callFrame, obj, "callFrame"); + assign(hitCount, obj, "hitCount"); + assign(children, obj, "children"); + assign(deoptReason, obj, "deoptReason"); + assign(positionTicks, obj, "positionTicks"); +} + +dynamic profiler::ProfileNode::toDynamic() const { + dynamic obj = dynamic::object; + + put(obj, "id", id); + put(obj, "callFrame", callFrame); + put(obj, "hitCount", hitCount); + put(obj, "children", children); + put(obj, "deoptReason", deoptReason); + put(obj, "positionTicks", positionTicks); + return obj; +} + +profiler::Profile::Profile(const dynamic &obj) { + assign(nodes, obj, "nodes"); + assign(startTime, obj, "startTime"); + assign(endTime, obj, "endTime"); + assign(samples, obj, "samples"); + assign(timeDeltas, obj, "timeDeltas"); +} + +dynamic profiler::Profile::toDynamic() const { + dynamic obj = dynamic::object; + + put(obj, "nodes", nodes); + put(obj, "startTime", startTime); + put(obj, "endTime", endTime); + put(obj, "samples", samples); + put(obj, "timeDeltas", timeDeltas); + return obj; +} + +runtime::CallArgument::CallArgument(const dynamic &obj) { + assign(value, obj, "value"); + assign(unserializableValue, obj, "unserializableValue"); + assign(objectId, obj, "objectId"); +} + +dynamic runtime::CallArgument::toDynamic() const { + dynamic obj = dynamic::object; + + put(obj, "value", value); + put(obj, "unserializableValue", unserializableValue); + put(obj, "objectId", objectId); + return obj; +} + runtime::ExecutionContextDescription::ExecutionContextDescription( const dynamic &obj) { assign(id, obj, "id"); @@ -487,12 +559,22 @@ debugger::ResumeRequest::ResumeRequest(const dynamic &obj) : Request("Debugger.resume") { assign(id, obj, "id"); assign(method, obj, "method"); + + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + assign(terminateOnResume, params, "terminateOnResume"); + } } dynamic debugger::ResumeRequest::toDynamic() const { + dynamic params = dynamic::object; + put(params, "terminateOnResume", terminateOnResume); + dynamic obj = dynamic::object; put(obj, "id", id); put(obj, "method", method); + put(obj, "params", std::move(params)); return obj; } @@ -801,8 +883,11 @@ heapProfiler::StartSamplingRequest::StartSamplingRequest(const dynamic &obj) assign(id, obj, "id"); assign(method, obj, "method"); - dynamic params = obj.at("params"); - assign(samplingInterval, params, "samplingInterval"); + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + assign(samplingInterval, params, "samplingInterval"); + } } dynamic heapProfiler::StartSamplingRequest::toDynamic() const { @@ -829,8 +914,11 @@ heapProfiler::StartTrackingHeapObjectsRequest::StartTrackingHeapObjectsRequest( assign(id, obj, "id"); assign(method, obj, "method"); - dynamic params = obj.at("params"); - assign(trackAllocations, params, "trackAllocations"); + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + assign(trackAllocations, params, "trackAllocations"); + } } dynamic heapProfiler::StartTrackingHeapObjectsRequest::toDynamic() const { @@ -878,15 +966,20 @@ heapProfiler::StopTrackingHeapObjectsRequest::StopTrackingHeapObjectsRequest( assign(id, obj, "id"); assign(method, obj, "method"); - dynamic params = obj.at("params"); - assign(reportProgress, params, "reportProgress"); - assign(treatGlobalObjectsAsRoots, params, "treatGlobalObjectsAsRoots"); + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + assign(reportProgress, params, "reportProgress"); + assign(treatGlobalObjectsAsRoots, params, "treatGlobalObjectsAsRoots"); + assign(captureNumericValue, params, "captureNumericValue"); + } } dynamic heapProfiler::StopTrackingHeapObjectsRequest::toDynamic() const { dynamic params = dynamic::object; put(params, "reportProgress", reportProgress); put(params, "treatGlobalObjectsAsRoots", treatGlobalObjectsAsRoots); + put(params, "captureNumericValue", captureNumericValue); dynamic obj = dynamic::object; put(obj, "id", id); @@ -909,15 +1002,20 @@ heapProfiler::TakeHeapSnapshotRequest::TakeHeapSnapshotRequest( assign(id, obj, "id"); assign(method, obj, "method"); - dynamic params = obj.at("params"); - assign(reportProgress, params, "reportProgress"); - assign(treatGlobalObjectsAsRoots, params, "treatGlobalObjectsAsRoots"); + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + assign(reportProgress, params, "reportProgress"); + assign(treatGlobalObjectsAsRoots, params, "treatGlobalObjectsAsRoots"); + assign(captureNumericValue, params, "captureNumericValue"); + } } dynamic heapProfiler::TakeHeapSnapshotRequest::toDynamic() const { dynamic params = dynamic::object; put(params, "reportProgress", reportProgress); put(params, "treatGlobalObjectsAsRoots", treatGlobalObjectsAsRoots); + put(params, "captureNumericValue", captureNumericValue); dynamic obj = dynamic::object; put(obj, "id", id); @@ -931,6 +1029,87 @@ void heapProfiler::TakeHeapSnapshotRequest::accept( handler.handle(*this); } +profiler::StartRequest::StartRequest() : Request("Profiler.start") {} + +profiler::StartRequest::StartRequest(const dynamic &obj) + : Request("Profiler.start") { + assign(id, obj, "id"); + assign(method, obj, "method"); +} + +dynamic profiler::StartRequest::toDynamic() const { + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "method", method); + return obj; +} + +void profiler::StartRequest::accept(RequestHandler &handler) const { + handler.handle(*this); +} + +profiler::StopRequest::StopRequest() : Request("Profiler.stop") {} + +profiler::StopRequest::StopRequest(const dynamic &obj) + : Request("Profiler.stop") { + assign(id, obj, "id"); + assign(method, obj, "method"); +} + +dynamic profiler::StopRequest::toDynamic() const { + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "method", method); + return obj; +} + +void profiler::StopRequest::accept(RequestHandler &handler) const { + handler.handle(*this); +} + +runtime::CallFunctionOnRequest::CallFunctionOnRequest() + : Request("Runtime.callFunctionOn") {} + +runtime::CallFunctionOnRequest::CallFunctionOnRequest(const dynamic &obj) + : Request("Runtime.callFunctionOn") { + assign(id, obj, "id"); + assign(method, obj, "method"); + + dynamic params = obj.at("params"); + assign(functionDeclaration, params, "functionDeclaration"); + assign(objectId, params, "objectId"); + assign(arguments, params, "arguments"); + assign(silent, params, "silent"); + assign(returnByValue, params, "returnByValue"); + assign(userGesture, params, "userGesture"); + assign(awaitPromise, params, "awaitPromise"); + assign(executionContextId, params, "executionContextId"); + assign(objectGroup, params, "objectGroup"); +} + +dynamic runtime::CallFunctionOnRequest::toDynamic() const { + dynamic params = dynamic::object; + put(params, "functionDeclaration", functionDeclaration); + put(params, "objectId", objectId); + put(params, "arguments", arguments); + put(params, "silent", silent); + put(params, "returnByValue", returnByValue); + put(params, "userGesture", userGesture); + put(params, "awaitPromise", awaitPromise); + put(params, "executionContextId", executionContextId); + put(params, "objectGroup", objectGroup); + + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "method", method); + put(obj, "params", std::move(params)); + return obj; +} + +void runtime::CallFunctionOnRequest::accept(RequestHandler &handler) const { + handler.handle(*this); +} + runtime::EvaluateRequest::EvaluateRequest() : Request("Runtime.evaluate") {} runtime::EvaluateRequest::EvaluateRequest(const dynamic &obj) @@ -971,6 +1150,26 @@ void runtime::EvaluateRequest::accept(RequestHandler &handler) const { handler.handle(*this); } +runtime::GetHeapUsageRequest::GetHeapUsageRequest() + : Request("Runtime.getHeapUsage") {} + +runtime::GetHeapUsageRequest::GetHeapUsageRequest(const dynamic &obj) + : Request("Runtime.getHeapUsage") { + assign(id, obj, "id"); + assign(method, obj, "method"); +} + +dynamic runtime::GetHeapUsageRequest::toDynamic() const { + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "method", method); + return obj; +} + +void runtime::GetHeapUsageRequest::accept(RequestHandler &handler) const { + handler.handle(*this); +} + runtime::GetPropertiesRequest::GetPropertiesRequest() : Request("Runtime.getProperties") {} @@ -1187,6 +1386,42 @@ dynamic heapProfiler::StopSamplingResponse::toDynamic() const { return obj; } +profiler::StopResponse::StopResponse(const dynamic &obj) { + assign(id, obj, "id"); + + dynamic res = obj.at("result"); + assign(profile, res, "profile"); +} + +dynamic profiler::StopResponse::toDynamic() const { + dynamic res = dynamic::object; + put(res, "profile", profile); + + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "result", std::move(res)); + return obj; +} + +runtime::CallFunctionOnResponse::CallFunctionOnResponse(const dynamic &obj) { + assign(id, obj, "id"); + + dynamic res = obj.at("result"); + assign(result, res, "result"); + assign(exceptionDetails, res, "exceptionDetails"); +} + +dynamic runtime::CallFunctionOnResponse::toDynamic() const { + dynamic res = dynamic::object; + put(res, "result", result); + put(res, "exceptionDetails", exceptionDetails); + + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "result", std::move(res)); + return obj; +} + runtime::EvaluateResponse::EvaluateResponse(const dynamic &obj) { assign(id, obj, "id"); @@ -1206,6 +1441,25 @@ dynamic runtime::EvaluateResponse::toDynamic() const { return obj; } +runtime::GetHeapUsageResponse::GetHeapUsageResponse(const dynamic &obj) { + assign(id, obj, "id"); + + dynamic res = obj.at("result"); + assign(usedSize, res, "usedSize"); + assign(totalSize, res, "totalSize"); +} + +dynamic runtime::GetHeapUsageResponse::toDynamic() const { + dynamic res = dynamic::object; + put(res, "usedSize", usedSize); + put(res, "totalSize", totalSize); + + dynamic obj = dynamic::object; + put(obj, "id", id); + put(obj, "result", std::move(res)); + return obj; +} + runtime::GetPropertiesResponse::GetPropertiesResponse(const dynamic &obj) { assign(id, obj, "id"); diff --git a/ReactCommon/hermes/inspector/chrome/MessageTypes.h b/ReactCommon/hermes/inspector/chrome/MessageTypes.h index 2184a223588e4c..c74a21d357e1d4 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageTypes.h +++ b/ReactCommon/hermes/inspector/chrome/MessageTypes.h @@ -1,5 +1,5 @@ -// Copyright 2004-present Facebook. All Rights Reserved. -// @generated SignedSource<> +// Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. +// @generated SignedSource<> #pragma once @@ -48,7 +48,10 @@ struct StepOverRequest; } // namespace debugger namespace runtime { +struct CallArgument; struct CallFrame; +struct CallFunctionOnRequest; +struct CallFunctionOnResponse; struct ConsoleAPICalledNotification; struct EvaluateRequest; struct EvaluateResponse; @@ -56,6 +59,8 @@ struct ExceptionDetails; struct ExecutionContextCreatedNotification; struct ExecutionContextDescription; using ExecutionContextId = int; +struct GetHeapUsageRequest; +struct GetHeapUsageResponse; struct GetPropertiesRequest; struct GetPropertiesResponse; struct InternalPropertyDescriptor; @@ -91,6 +96,15 @@ struct StopTrackingHeapObjectsRequest; struct TakeHeapSnapshotRequest; } // namespace heapProfiler +namespace profiler { +struct PositionTickInfo; +struct Profile; +struct ProfileNode; +struct StartRequest; +struct StopRequest; +struct StopResponse; +} // namespace profiler + /// RequestHandler handles requests via the visitor pattern. struct RequestHandler { virtual ~RequestHandler() = default; @@ -122,7 +136,11 @@ struct RequestHandler { virtual void handle( const heapProfiler::StopTrackingHeapObjectsRequest &req) = 0; virtual void handle(const heapProfiler::TakeHeapSnapshotRequest &req) = 0; + virtual void handle(const profiler::StartRequest &req) = 0; + virtual void handle(const profiler::StopRequest &req) = 0; + virtual void handle(const runtime::CallFunctionOnRequest &req) = 0; virtual void handle(const runtime::EvaluateRequest &req) = 0; + virtual void handle(const runtime::GetHeapUsageRequest &req) = 0; virtual void handle(const runtime::GetPropertiesRequest &req) = 0; virtual void handle(const runtime::RunIfWaitingForDebuggerRequest &req) = 0; }; @@ -156,7 +174,11 @@ struct NoopRequestHandler : public RequestHandler { void handle( const heapProfiler::StopTrackingHeapObjectsRequest &req) override {} void handle(const heapProfiler::TakeHeapSnapshotRequest &req) override {} + void handle(const profiler::StartRequest &req) override {} + void handle(const profiler::StopRequest &req) override {} + void handle(const runtime::CallFunctionOnRequest &req) override {} void handle(const runtime::EvaluateRequest &req) override {} + void handle(const runtime::GetHeapUsageRequest &req) override {} void handle(const runtime::GetPropertiesRequest &req) override {} void handle(const runtime::RunIfWaitingForDebuggerRequest &req) override {} }; @@ -281,6 +303,50 @@ struct heapProfiler::SamplingHeapProfile : public Serializable { std::vector samples; }; +struct profiler::PositionTickInfo : public Serializable { + PositionTickInfo() = default; + explicit PositionTickInfo(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + int line{}; + int ticks{}; +}; + +struct profiler::ProfileNode : public Serializable { + ProfileNode() = default; + explicit ProfileNode(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + int id{}; + runtime::CallFrame callFrame{}; + folly::Optional hitCount; + folly::Optional> children; + folly::Optional deoptReason; + folly::Optional> positionTicks; +}; + +struct profiler::Profile : public Serializable { + Profile() = default; + explicit Profile(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + std::vector nodes; + double startTime{}; + double endTime{}; + folly::Optional> samples; + folly::Optional> timeDeltas; +}; + +struct runtime::CallArgument : public Serializable { + CallArgument() = default; + explicit CallArgument(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + folly::Optional value; + folly::Optional unserializableValue; + folly::Optional objectId; +}; + struct runtime::ExecutionContextDescription : public Serializable { ExecutionContextDescription() = default; explicit ExecutionContextDescription(const folly::dynamic &obj); @@ -385,6 +451,8 @@ struct debugger::ResumeRequest : public Request { folly::dynamic toDynamic() const override; void accept(RequestHandler &handler) const override; + + folly::Optional terminateOnResume; }; struct debugger::SetBreakpointRequest : public Request { @@ -533,6 +601,7 @@ struct heapProfiler::StopTrackingHeapObjectsRequest : public Request { folly::Optional reportProgress; folly::Optional treatGlobalObjectsAsRoots; + folly::Optional captureNumericValue; }; struct heapProfiler::TakeHeapSnapshotRequest : public Request { @@ -544,6 +613,41 @@ struct heapProfiler::TakeHeapSnapshotRequest : public Request { folly::Optional reportProgress; folly::Optional treatGlobalObjectsAsRoots; + folly::Optional captureNumericValue; +}; + +struct profiler::StartRequest : public Request { + StartRequest(); + explicit StartRequest(const folly::dynamic &obj); + + folly::dynamic toDynamic() const override; + void accept(RequestHandler &handler) const override; +}; + +struct profiler::StopRequest : public Request { + StopRequest(); + explicit StopRequest(const folly::dynamic &obj); + + folly::dynamic toDynamic() const override; + void accept(RequestHandler &handler) const override; +}; + +struct runtime::CallFunctionOnRequest : public Request { + CallFunctionOnRequest(); + explicit CallFunctionOnRequest(const folly::dynamic &obj); + + folly::dynamic toDynamic() const override; + void accept(RequestHandler &handler) const override; + + std::string functionDeclaration; + folly::Optional objectId; + folly::Optional> arguments; + folly::Optional silent; + folly::Optional returnByValue; + folly::Optional userGesture; + folly::Optional awaitPromise; + folly::Optional executionContextId; + folly::Optional objectGroup; }; struct runtime::EvaluateRequest : public Request { @@ -563,6 +667,14 @@ struct runtime::EvaluateRequest : public Request { folly::Optional awaitPromise; }; +struct runtime::GetHeapUsageRequest : public Request { + GetHeapUsageRequest(); + explicit GetHeapUsageRequest(const folly::dynamic &obj); + + folly::dynamic toDynamic() const override; + void accept(RequestHandler &handler) const override; +}; + struct runtime::GetPropertiesRequest : public Request { GetPropertiesRequest(); explicit GetPropertiesRequest(const folly::dynamic &obj); @@ -658,6 +770,23 @@ struct heapProfiler::StopSamplingResponse : public Response { heapProfiler::SamplingHeapProfile profile{}; }; +struct profiler::StopResponse : public Response { + StopResponse() = default; + explicit StopResponse(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + profiler::Profile profile{}; +}; + +struct runtime::CallFunctionOnResponse : public Response { + CallFunctionOnResponse() = default; + explicit CallFunctionOnResponse(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + runtime::RemoteObject result{}; + folly::Optional exceptionDetails; +}; + struct runtime::EvaluateResponse : public Response { EvaluateResponse() = default; explicit EvaluateResponse(const folly::dynamic &obj); @@ -667,6 +796,15 @@ struct runtime::EvaluateResponse : public Response { folly::Optional exceptionDetails; }; +struct runtime::GetHeapUsageResponse : public Response { + GetHeapUsageResponse() = default; + explicit GetHeapUsageResponse(const folly::dynamic &obj); + folly::dynamic toDynamic() const override; + + double usedSize{}; + double totalSize{}; +}; + struct runtime::GetPropertiesResponse : public Response { GetPropertiesResponse() = default; explicit GetPropertiesResponse(const folly::dynamic &obj); diff --git a/ReactCommon/hermes/inspector/chrome/MessageTypesInlines.h b/ReactCommon/hermes/inspector/chrome/MessageTypesInlines.h index 641034f0af79c0..2f6bff4f28a809 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageTypesInlines.h +++ b/ReactCommon/hermes/inspector/chrome/MessageTypesInlines.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/Registration.cpp b/ReactCommon/hermes/inspector/chrome/Registration.cpp index 9ba0dbbf84013b..4f0baf27eaed2c 100644 --- a/ReactCommon/hermes/inspector/chrome/Registration.cpp +++ b/ReactCommon/hermes/inspector/chrome/Registration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -28,7 +28,7 @@ void enableDebugging( demux().enableDebugging(std::move(adapter), title); } -void disableDebugging(HermesRuntime &runtime) { +void disableDebugging(jsi::Runtime &runtime) { demux().disableDebugging(runtime); } diff --git a/ReactCommon/hermes/inspector/chrome/Registration.h b/ReactCommon/hermes/inspector/chrome/Registration.h index b6601478f1e24c..f14ac7f3192962 100644 --- a/ReactCommon/hermes/inspector/chrome/Registration.h +++ b/ReactCommon/hermes/inspector/chrome/Registration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -31,7 +31,7 @@ extern void enableDebugging( * disableDebugging removes this runtime from the list of debuggable JS targets * in this process. */ -extern void disableDebugging(HermesRuntime &runtime); +extern void disableDebugging(jsi::Runtime &runtime); } // namespace chrome } // namespace inspector diff --git a/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.cpp b/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.cpp index ffab5d9721b3c8..28f9f79193e64d 100644 --- a/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.cpp +++ b/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.h b/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.h index 468db2f6307e66..97c0c38bc39682 100644 --- a/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.h +++ b/ReactCommon/hermes/inspector/chrome/RemoteObjectsTable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/cli/main.cpp b/ReactCommon/hermes/inspector/chrome/cli/main.cpp index 3e687be4f36172..8071bcc11aabaa 100644 --- a/ReactCommon/hermes/inspector/chrome/cli/main.cpp +++ b/ReactCommon/hermes/inspector/chrome/cli/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.cpp b/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.cpp index c19a5336582447..9c630ad012139d 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -139,6 +139,27 @@ std::string AsyncHermesRuntime::getLastThrownExceptionMessage() { return thrownExceptions_.back(); } +void AsyncHermesRuntime::registerForProfilingInExecutor() { + // Sampling profiler registration needs to happen in the thread where JS runs. + folly::via(executor_.get(), [runtime = runtime_]() { + runtime->registerForProfiling(); + }); + + // Wait until the executor is registered for profiling. + wait(); +} + +void AsyncHermesRuntime::unregisterForProfilingInExecutor() { + // Sampling profiler deregistration needs to happen in the thread where JS + // runs. + folly::via(executor_.get(), [runtime = runtime_]() { + runtime->unregisterForProfiling(); + }); + + // Wait until the executor is unregistered for profiling. + wait(); +} + } // namespace chrome } // namespace inspector } // namespace hermes diff --git a/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.h b/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.h index 60a63147fc38b9..8772b14b62f70c 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.h +++ b/ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -95,6 +95,16 @@ class AsyncHermesRuntime { */ std::string getLastThrownExceptionMessage(); + /** + * registers the runtime for profiling in the executor thread. + */ + void registerForProfilingInExecutor(); + + /** + * unregisters the runtime for profiling in the executor thread. + */ + void unregisterForProfilingInExecutor(); + private: jsi::Value shouldStop( jsi::Runtime &runtime, @@ -115,6 +125,23 @@ class AsyncHermesRuntime { std::vector thrownExceptions_; }; +/// RAII-style class dealing with sampling profiler registration in tests. This +/// is especially important in tests -- if any test failure is caused by an +/// uncaught exception, stack unwinding will destroy a VM registered for +/// profiling in a thread that's not the one where registration happened, which +/// will lead to a hermes fatal error. Using this RAII class ensure that the +/// proper test failure cause is reported. +struct SamplingProfilerRAII { + explicit SamplingProfilerRAII(AsyncHermesRuntime &rt) : runtime_(rt) { + runtime_.registerForProfilingInExecutor(); + } + + ~SamplingProfilerRAII() { + runtime_.unregisterForProfilingInExecutor(); + } + + AsyncHermesRuntime &runtime_; +}; } // namespace chrome } // namespace inspector } // namespace hermes diff --git a/ReactCommon/hermes/inspector/chrome/tests/ConnectionDemuxTests.cpp b/ReactCommon/hermes/inspector/chrome/tests/ConnectionDemuxTests.cpp index 52173027ea6844..4250ee3ac7e788 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/ConnectionDemuxTests.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/ConnectionDemuxTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp b/ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp index f579799bbae538..b6538ea56e6961 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -407,7 +407,7 @@ std::unordered_map expectProps( m::runtime::PropertyDescriptor &desc = resp.result[i]; auto infoIt = infos.find(desc.name); - EXPECT_FALSE(infoIt == infos.end()); + EXPECT_FALSE(infoIt == infos.end()) << desc.name; if (infoIt != infos.end()) { const PropInfo &info = infoIt->second; @@ -460,6 +460,25 @@ void expectEvalResponse( expectProps(conn, id + 1, resp.result.objectId.value(), infos); } +m::runtime::CallArgument makeValueCallArgument(folly::dynamic val) { + m::runtime::CallArgument ret; + ret.value = val; + return ret; +} + +m::runtime::CallArgument makeUnserializableCallArgument(std::string val) { + m::runtime::CallArgument ret; + ret.unserializableValue = std::move(val); + return ret; +} + +m::runtime::CallArgument makeObjectIdCallArgument( + m::runtime::RemoteObjectId objectId) { + m::runtime::CallArgument ret; + ret.objectId = std::move(objectId); + return ret; +} + } // namespace TEST(ConnectionTests, testRespondsOkToUnknownRequests) { @@ -1981,6 +2000,231 @@ TEST(ConnectionTests, testScopeVariables) { expectNotification(conn); } +TEST(ConnectionTests, testRuntimeCallFunctionOnObject) { + TestContext context; + AsyncHermesRuntime &asyncRuntime = context.runtime(); + SyncConnection &conn = context.conn(); + int msgId = 1; + + asyncRuntime.executeScriptAsync(R"( + debugger; + )"); + + send(conn, msgId++); + expectExecutionContextCreated(conn); + expectNotification(conn); + + // create a new Object() that will be used as "this" below. + m::runtime::RemoteObjectId thisId; + { + sendRuntimeEvalRequest(conn, msgId, "new Object()"); + auto resp = expectResponse(conn, msgId++); + ASSERT_TRUE(resp.result.objectId) << resp.toDynamic(); + thisId = *resp.result.objectId; + } + + // expectedPropInfos are properties that are expected to exist in thisId. It + // is modified by addMember (below). + std::unordered_map expectedPropInfos; + + // Add __proto__ as it always exists. + expectedPropInfos.emplace("__proto__", PropInfo("object")); + + /// addMember sends Runtime.callFunctionOn() requests with a function + /// declaration that simply adds a new property called \p propName with type + /// \p type to the remote object \p id. \p ca is the property's value. + /// The new property must not exist in \p id unless \p allowRedefinition is + /// true. + auto addMember = [&](const m::runtime::RemoteObjectId id, + const char *type, + const char *propName, + const m::runtime::CallArgument &ca, + bool allowRedefinition = false) { + m::runtime::CallFunctionOnRequest req; + req.id = msgId++; + req.functionDeclaration = + std::string("function(e){const r=\"") + propName + "\"; this[r]=e,r}"; + req.arguments = std::vector{ca}; + req.objectId = thisId; + conn.send(req.toJson()); + expectResponse(conn, req.id); + + auto it = expectedPropInfos.emplace(propName, PropInfo(type)); + + EXPECT_TRUE(allowRedefinition || it.second) + << "property \"" << propName << "\" redefined."; + + if (ca.value) { + it.first->second.setValue(*ca.value); + } + + if (ca.unserializableValue) { + it.first->second.setUnserializableValue(*ca.unserializableValue); + } + }; + + addMember(thisId, "boolean", "b", makeValueCallArgument(true)); + addMember(thisId, "number", "num", makeValueCallArgument(12)); + addMember(thisId, "string", "str", makeValueCallArgument("string value")); + addMember(thisId, "object", "self_ref", makeObjectIdCallArgument(thisId)); + addMember( + thisId, "number", "inf", makeUnserializableCallArgument("Infinity")); + addMember( + thisId, "number", "ni", makeUnserializableCallArgument("-Infinity")); + addMember(thisId, "number", "nan", makeUnserializableCallArgument("NaN")); + + /// ensures that \p objId has all of the expected properties; Returns the + /// runtime::RemoteObjectId for the "self_ref" property (which must exist). + auto verifyObjShape = [&](const m::runtime::RemoteObjectId &objId) + -> folly::Optional { + auto objProps = expectProps(conn, msgId++, objId, expectedPropInfos); + EXPECT_TRUE(objProps.count("__proto__")); + auto objPropIt = objProps.find("self_ref"); + if (objPropIt == objProps.end()) { + EXPECT_TRUE(false) << "missing \"self_ref\" property."; + return {}; + } + return objPropIt->second; + }; + + // Verify that thisId has the correct shape. + auto selfRefId = verifyObjShape(thisId); + ASSERT_TRUE(selfRefId); + // Then verify that the self reference has the correct shape. If thisId does + // not have the "self_ref" property the call to verifyObjShape will return an + // empty Optional, as well as report an error. + selfRefId = verifyObjShape(*selfRefId); + ASSERT_TRUE(selfRefId); + + // Now we modify the self reference, which should cause thisId to change + // as well. + const bool kAllowRedefinition = true; + + addMember( + *selfRefId, + "number", + "num", + makeValueCallArgument(42), + kAllowRedefinition); + + addMember( + *selfRefId, "number", "neg_zero", makeUnserializableCallArgument("-0")); + + verifyObjShape(thisId); + + send(conn, msgId++); + expectNotification(conn); +} + +TEST(ConnectionTests, testRuntimeCallFunctionOnExecutionContext) { + TestContext context; + AsyncHermesRuntime &asyncRuntime = context.runtime(); + SyncConnection &conn = context.conn(); + int msgId = 1; + + asyncRuntime.executeScriptAsync(R"( + debugger; + )"); + + /// helper that returns a map with all of \p objId 's members. + auto getProps = [&msgId, &conn](const m::runtime::RemoteObjectId &objId) { + m::runtime::GetPropertiesRequest req; + req.id = msgId++; + req.objectId = objId; + conn.send(req.toJson()); + auto resp = expectResponse(conn, req.id); + std::unordered_map> + properties; + for (auto propertyDescriptor : resp.result) { + properties[propertyDescriptor.name] = propertyDescriptor.value; + } + return properties; + }; + + send(conn, msgId++); + expectExecutionContextCreated(conn); + expectNotification(conn); + + // globalThisId is the inspector's object Id for globalThis. + m::runtime::RemoteObjectId globalThisId; + { + sendRuntimeEvalRequest(conn, msgId, "globalThis"); + auto resp = expectResponse(conn, msgId++); + ASSERT_TRUE(resp.result.objectId) << resp.toDynamic(); + globalThisId = *resp.result.objectId; + } + + // This test table has all of the new fields we want to add to globalThis, + // plus the Runtime.CallArgument to be sent to the inspector. + struct { + const char *propName; + const m::runtime::CallArgument callArg; + } tests[] = { + {"callFunctionOnTestMember1", makeValueCallArgument(10)}, + {"callFunctionOnTestMember2", makeValueCallArgument("string")}, + {"callFunctionOnTestMember3", makeUnserializableCallArgument("NaN")}, + {"callFunctionOnTestMember4", makeUnserializableCallArgument("-0")}, + }; + + // sanity-check that our test fields don't exist in global this. + { + auto currProps = getProps(globalThisId); + for (const auto &test : tests) { + EXPECT_EQ(currProps.count(test.propName), 0) << test.propName; + } + } + + auto addMember = [&msgId, &conn]( + const char *propName, + const m::runtime::CallArgument &ca) { + m::runtime::CallFunctionOnRequest req; + req.id = msgId++; + req.functionDeclaration = + std::string("function(e){const r=\"") + propName + "\"; this[r]=e,r}"; + req.arguments = std::vector{ca}; + req.executionContextId = 1; + conn.send(req.toJson()); + expectResponse(conn, req.id); + }; + + for (const auto &test : tests) { + addMember(test.propName, test.callArg); + } + + { + auto currProps = getProps(globalThisId); + for (const auto &test : tests) { + auto it = currProps.find(test.propName); + + // there should be a property named test.propName in globalThis. + ASSERT_TRUE(it != currProps.end()) << test.propName; + + // and it should have a value. + ASSERT_TRUE(it->second) << test.propName; + + if (it->second->value.hasValue()) { + // the property has a value, so make sure that's what's being expected. + auto actual = it->second->value; + auto expected = test.callArg.value; + ASSERT_TRUE(expected.hasValue()) << test.propName; + EXPECT_EQ(*actual, *expected) << test.propName; + } else if (it->second->unserializableValue.hasValue()) { + // the property has an unserializable value, so make sure that's what's + // being expected. + auto actual = it->second->unserializableValue; + auto expected = test.callArg.unserializableValue; + ASSERT_TRUE(expected.hasValue()) << test.propName; + EXPECT_EQ(*actual, *expected) << test.propName; + } else { + FAIL() << "No value or unserializable value in " << test.propName; + } + } + } + + send(conn, msgId++); + expectNotification(conn); +} + TEST(ConnectionTests, testConsoleLog) { TestContext context; AsyncHermesRuntime &asyncRuntime = context.runtime(); @@ -2489,9 +2733,9 @@ TEST(ConnectionTests, heapProfilerSampling) { req.id = msgId++; // Sample every 256 bytes to ensure there are some samples. The default is // 32768, which is too high for a small example. Note that sampling is a - // random process, so there's no guarantee there will be any samples in any - // finite number of allocations. In practice the likelihood is so high that - // there shouldn't be any issues. + // random process, so there's no guarantee there will be any samples in + // any finite number of allocations. In practice the likelihood is so high + // that there shouldn't be any issues. req.samplingInterval = 256; send(conn, req); } @@ -2582,9 +2826,9 @@ TEST(ConnectionTests, heapSnapshotRemoteObject) { testObject(storedObjID, "object", "Array", "Array(3)", "array"); // Force a collection to move the heap. runtime->instrumentation().collectGarbage("test"); - // A collection should not disturb the unique ID lookup, and it should be the - // same object as before. Note that it won't have the same remote ID, because - // Hermes doesn't do uniquing. + // A collection should not disturb the unique ID lookup, and it should be + // the same object as before. Note that it won't have the same remote ID, + // because Hermes doesn't do uniquing. testObject(globalObjID, "object", "Object", "Object", nullptr); testObject(storedObjID, "object", "Array", "Array(3)", "array"); @@ -2593,6 +2837,53 @@ TEST(ConnectionTests, heapSnapshotRemoteObject) { expectNotification(conn); } +TEST(ConnectionTests, testBasicProfilerOperation) { + TestContext context; + AsyncHermesRuntime &asyncRuntime = context.runtime(); + SamplingProfilerRAII spRegistration(asyncRuntime); + SyncConnection &conn = context.conn(); + int msgId = 1; + + asyncRuntime.executeScriptAsync(R"( + while(!shouldStop()); + )"); + + send(conn, msgId++); + expectExecutionContextCreated(conn); + expectNotification(conn); + + // Start the sampling profiler. At this point it is not safe to manipulate the + // VM, so... + send(conn, msgId++); + + // Disable the debugger. + send(conn, msgId++); + + // Keep the profiler running for a small amount of time to allow for some + // samples to be collected. + std::this_thread::sleep_for(500ms); + + // Finally, re-enable the debugger in order to stop profiling. + send(conn, msgId++); + expectExecutionContextCreated(conn); + + // Being re-attached to the VM, send the stop sampling profile request. + { + auto resp = send( + conn, msgId++); + + const m::profiler::Profile &profile = resp.profile; + EXPECT_GT(profile.nodes.size(), 0); + EXPECT_LT(profile.startTime, profile.endTime); + ASSERT_TRUE(profile.samples); + EXPECT_FALSE(profile.samples->empty()); + ASSERT_TRUE(profile.timeDeltas); + EXPECT_EQ(profile.samples->size(), profile.timeDeltas->size()); + } + + asyncRuntime.stop(); +} + } // namespace chrome } // namespace inspector } // namespace hermes diff --git a/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp b/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp index 2b2484b00e3b0b..dae6513a04b902 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -52,6 +52,7 @@ TEST(MessageTests, testDeserializeSomeFieldsInRequest) { )"); debugger::SetBreakpointByUrlRequest req(message); + EXPECT_EQ(req.toDynamic(), message); EXPECT_EQ(req.id, 10); EXPECT_EQ(req.method, "Debugger.setBreakpointByUrl"); EXPECT_EQ(req.lineNumber, 42); @@ -151,7 +152,7 @@ TEST(MessageTests, testDeserializeResponse) { } })"); debugger::SetBreakpointByUrlResponse resp(message); - + EXPECT_EQ(resp.toDynamic(), message); EXPECT_EQ(resp.id, 1); EXPECT_EQ(resp.breakpointId, "myBreakpointId"); EXPECT_EQ(resp.locations.size(), 1); @@ -455,6 +456,1075 @@ TEST(MessageTests, TestRequestHandler) { EXPECT_EQ(handler.removeReq.breakpointId, "foobar"); } +TEST(MessageTests, testEnableRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.enable" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::EnableRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::EnableRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.enable"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testDisableRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.disable" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::DisableRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::DisableRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.disable"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testEvaluateOnCallFrameRequestMinimal) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.evaluateOnCallFrame", + "params":{ + "callFrameId" : "42", + "expression": "Foo Bar" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::EvaluateOnCallFrameRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::EvaluateOnCallFrameRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.evaluateOnCallFrame"); + EXPECT_EQ(resolvedReq->callFrameId, "42"); + EXPECT_EQ(resolvedReq->expression, "Foo Bar"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->callFrameId, deserializedReq.callFrameId); + EXPECT_EQ(resolvedReq->expression, deserializedReq.expression); + + EXPECT_FALSE(resolvedReq->objectGroup.hasValue()); + EXPECT_FALSE(resolvedReq->includeCommandLineAPI.hasValue()); + EXPECT_FALSE(resolvedReq->silent.hasValue()); + EXPECT_FALSE(resolvedReq->returnByValue.hasValue()); + EXPECT_FALSE(resolvedReq->throwOnSideEffect.hasValue()); +} + +TEST(MessageTests, testEvaluateOnCallFrameRequestFull) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.evaluateOnCallFrame", + "params":{ + "callFrameId" : "42", + "expression": "Foo Bar", + "objectGroup" : "FooBarGroup", + "includeCommandLineAPI" : false, + "silent" : true, + "returnByValue" : false, + "throwOnSideEffect" : true + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::EvaluateOnCallFrameRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::EvaluateOnCallFrameRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics, resolvedReq is correct + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.evaluateOnCallFrame"); + EXPECT_EQ(resolvedReq->callFrameId, "42"); + EXPECT_EQ(resolvedReq->expression, "Foo Bar"); + + EXPECT_TRUE(resolvedReq->objectGroup.hasValue()); + EXPECT_TRUE(resolvedReq->includeCommandLineAPI.hasValue()); + EXPECT_TRUE(resolvedReq->silent.hasValue()); + EXPECT_TRUE(resolvedReq->returnByValue.hasValue()); + EXPECT_TRUE(resolvedReq->throwOnSideEffect.hasValue()); + + EXPECT_TRUE(resolvedReq->objectGroup.value() == "FooBarGroup"); + EXPECT_TRUE(resolvedReq->includeCommandLineAPI.value() == false); + EXPECT_TRUE(resolvedReq->silent.value() == true); + EXPECT_TRUE(resolvedReq->returnByValue.value() == false); + EXPECT_TRUE(resolvedReq->throwOnSideEffect.value() == true); + + // Specifics, resolvedReq and deserialized match + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->callFrameId, deserializedReq.callFrameId); + EXPECT_EQ(resolvedReq->expression, deserializedReq.expression); + EXPECT_EQ( + resolvedReq->objectGroup.value(), deserializedReq.objectGroup.value()); + EXPECT_EQ( + resolvedReq->includeCommandLineAPI.value(), + deserializedReq.includeCommandLineAPI.value()); + EXPECT_EQ(resolvedReq->silent.value(), deserializedReq.silent.value()); + EXPECT_EQ( + resolvedReq->returnByValue.value(), + deserializedReq.returnByValue.value()); + EXPECT_EQ( + resolvedReq->throwOnSideEffect.value(), + deserializedReq.throwOnSideEffect.value()); +} + +TEST(MessageTests, testPauseRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.pause" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::PauseRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::PauseRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.pause"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testRemoveBreakpointRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.removeBreakpoint", + "params":{ + "breakpointId" : "42" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::RemoveBreakpointRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::RemoveBreakpointRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.removeBreakpoint"); + EXPECT_TRUE(resolvedReq->breakpointId == "42"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->breakpointId, deserializedReq.breakpointId); +} + +TEST(MessageTests, testResumeRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.resume", + "params": { + "terminateOnResume": false + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::ResumeRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::ResumeRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.resume"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testSetBreakpointRequestMinimal) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.setBreakpoint", + "params":{ + "location" : + { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + } + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetBreakpointRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + debugger::Location location; + location.scriptId = "myScriptId"; + location.lineNumber = 2; + location.columnNumber = 3; + + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.setBreakpoint"); + EXPECT_EQ(resolvedReq->location.scriptId, "myScriptId"); + EXPECT_EQ(resolvedReq->location.lineNumber, 2); + EXPECT_EQ(resolvedReq->location.columnNumber, 3); + + EXPECT_FALSE(resolvedReq->condition.hasValue()); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->location.scriptId, deserializedReq.location.scriptId); + EXPECT_EQ( + resolvedReq->location.lineNumber, deserializedReq.location.lineNumber); + EXPECT_EQ( + resolvedReq->location.columnNumber, + deserializedReq.location.columnNumber); +} + +TEST(MessageTests, testSetBreakpointRequestFull) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.setBreakpoint", + "params":{ + "location" : + { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + }, + "condition": "FooBarCondition" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetBreakpointRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.setBreakpoint"); + EXPECT_EQ(resolvedReq->location.scriptId, "myScriptId"); + EXPECT_EQ(resolvedReq->location.lineNumber, 2); + EXPECT_EQ(resolvedReq->location.columnNumber, 3); + + EXPECT_TRUE(resolvedReq->condition.hasValue()); + EXPECT_EQ(resolvedReq->condition.value(), "FooBarCondition"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->location.scriptId, deserializedReq.location.scriptId); + EXPECT_EQ( + resolvedReq->location.lineNumber, deserializedReq.location.lineNumber); + EXPECT_EQ( + resolvedReq->location.columnNumber, + deserializedReq.location.columnNumber); + EXPECT_EQ(resolvedReq->condition.value(), deserializedReq.condition.value()); +} + +TEST(MessageTests, testSetBreakpointByUrlRequestMinimal) { + std::string message = R"( + { + "id": 1, + "method": "Debugger.setBreakpointByUrl", + "params": { + "lineNumber": 2 + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetBreakpointByUrlRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointByUrlRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 1); + EXPECT_EQ(resolvedReq->method, "Debugger.setBreakpointByUrl"); + EXPECT_EQ(resolvedReq->lineNumber, 2); + + EXPECT_FALSE(resolvedReq->condition.hasValue()); + EXPECT_FALSE(resolvedReq->columnNumber.hasValue()); + EXPECT_FALSE(resolvedReq->url.hasValue()); + EXPECT_FALSE(resolvedReq->urlRegex.hasValue()); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->lineNumber, deserializedReq.lineNumber); +} + +TEST(MessageTests, testSetBreakpointByUrlRequestFull) { + std::string message = R"( + { + "id": 1, + "method": "Debugger.setBreakpointByUrl", + "params": { + "lineNumber": 2, + "columnNumber": 3, + "condition": "foo == 42", + "url": "http://example.com/example.js", + "urlRegex": "http://example.com/.*" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetBreakpointByUrlRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointByUrlRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 1); + EXPECT_EQ(resolvedReq->method, "Debugger.setBreakpointByUrl"); + EXPECT_EQ(resolvedReq->lineNumber, 2); + + EXPECT_TRUE(resolvedReq->condition.hasValue()); + EXPECT_EQ(resolvedReq->condition.value(), "foo == 42"); + EXPECT_TRUE(resolvedReq->columnNumber.hasValue()); + EXPECT_EQ(resolvedReq->columnNumber.value(), 3); + EXPECT_TRUE(resolvedReq->url.hasValue()); + EXPECT_EQ(resolvedReq->url.value(), "http://example.com/example.js"); + EXPECT_TRUE(resolvedReq->urlRegex.hasValue()); + EXPECT_EQ(resolvedReq->urlRegex.value(), "http://example.com/.*"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->lineNumber, deserializedReq.lineNumber); + EXPECT_EQ(resolvedReq->condition.value(), deserializedReq.condition.value()); + EXPECT_EQ( + resolvedReq->columnNumber.value(), deserializedReq.columnNumber.value()); + EXPECT_EQ(resolvedReq->url.value(), deserializedReq.url.value()); + EXPECT_EQ(resolvedReq->urlRegex.value(), deserializedReq.urlRegex.value()); +} + +TEST(MessageTests, testSetBreakpointsActiveRequest) { + std::string message = R"( + { + "id": 1, + "method": "Debugger.setBreakpointsActive", + "params": { + "active": true + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetBreakpointsActiveRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointsActiveRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 1); + EXPECT_EQ(resolvedReq->method, "Debugger.setBreakpointsActive"); + EXPECT_EQ(resolvedReq->active, true); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->active, deserializedReq.active); +} + +TEST(MessageTests, testSetInstrumentationBreakpointRequest) { + std::string message = R"( + { + "id": 1, + "method": "Debugger.setInstrumentationBreakpoint", + "params": { + "instrumentation": "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetInstrumentationBreakpointRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetInstrumentationBreakpointRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 1); + EXPECT_EQ(resolvedReq->method, "Debugger.setInstrumentationBreakpoint"); + EXPECT_EQ( + resolvedReq->instrumentation, "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->instrumentation, deserializedReq.instrumentation); +} + +TEST(MessageTests, testSetPauseOnExceptionsRequest) { + std::string message = R"( + { + "id": 1, + "method": "Debugger.setPauseOnExceptions", + "params": { + "state": "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM" + } + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::SetPauseOnExceptionsRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetPauseOnExceptionsRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 1); + EXPECT_EQ(resolvedReq->method, "Debugger.setPauseOnExceptions"); + EXPECT_EQ(resolvedReq->state, "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); + EXPECT_EQ(resolvedReq->state, deserializedReq.state); +} + +TEST(MessageTests, testStepIntoRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.stepInto" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::StepIntoRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::StepIntoRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.stepInto"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testStepOutRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.stepOut" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::StepOutRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::StepOutRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.stepOut"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testStepOverRequest) { + std::string message = R"( + { + "id": 10, + "method": "Debugger.stepOver" + } + )"; + + // Builder does not throw + auto req = Request::fromJsonThrowOnError(message); + debugger::StepOverRequest *resolvedReq = + dynamic_cast(req.get()); + + // Builder returns correct type + EXPECT_FALSE(resolvedReq == nullptr); + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::StepOverRequest deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(resolvedReq->id, 10); + EXPECT_EQ(resolvedReq->method, "Debugger.stepOver"); + + EXPECT_EQ(resolvedReq->id, deserializedReq.id); + EXPECT_EQ(resolvedReq->method, deserializedReq.method); +} + +TEST(MessageTests, testEvaluateOnCallFrameResponseMinimal) { + std::string message = R"( + { + "result": + { + "result":{ + "type": "string" + } + }, + "id":2 + } + )"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::EvaluateOnCallFrameResponse deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + EXPECT_FALSE(deserializedReq.result.subtype.hasValue()); + EXPECT_FALSE(deserializedReq.result.value.hasValue()); + EXPECT_FALSE(deserializedReq.result.unserializableValue.hasValue()); + EXPECT_FALSE(deserializedReq.result.description.hasValue()); + EXPECT_FALSE(deserializedReq.result.objectId.hasValue()); + + // Specifics + EXPECT_EQ(deserializedReq.id, 2); + EXPECT_EQ(deserializedReq.result.type, "string"); +} + +TEST(MessageTests, testEvaluateOnCallFrameResponseFull) { + std::string message = R"( + { + "result": + { + "result":{ + "type": "string", + "subtype": "SuperString", + "value": {"foobarkey": "foobarval"}, + "unserializableValue": "unserializableValueVal", + "description": "A Wonderful desc", + "objectId": "AnObjectID" + } + }, + "id":2 + } + )"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::EvaluateOnCallFrameResponse deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + EXPECT_TRUE(deserializedReq.result.subtype.hasValue()); + EXPECT_TRUE(deserializedReq.result.value.hasValue()); + EXPECT_TRUE(deserializedReq.result.unserializableValue.hasValue()); + EXPECT_TRUE(deserializedReq.result.description.hasValue()); + EXPECT_TRUE(deserializedReq.result.objectId.hasValue()); + + EXPECT_EQ(deserializedReq.result.subtype.value(), "SuperString"); + EXPECT_EQ( + deserializedReq.result.value.value(), + folly::parseJson(R"({"foobarkey": "foobarval"})")); + EXPECT_EQ( + deserializedReq.result.unserializableValue.value(), + "unserializableValueVal"); + EXPECT_EQ(deserializedReq.result.description.value(), "A Wonderful desc"); + EXPECT_EQ(deserializedReq.result.objectId.value(), "AnObjectID"); + + // Specifics + EXPECT_EQ(deserializedReq.id, 2); + EXPECT_EQ(deserializedReq.result.type, "string"); +} + +TEST(MessageTests, testSetBreakpointByUrlResponse) { + std::string message = R"({ + "id": 1, + "result":{ + "breakpointId": "myBreakpointId", + "locations": [ + { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + } + ] + } + })"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointByUrlResponse deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(deserializedReq.id, 1); + EXPECT_EQ(deserializedReq.breakpointId, "myBreakpointId"); + EXPECT_EQ(deserializedReq.locations.size(), 1); + EXPECT_EQ(deserializedReq.locations[0].lineNumber, 2); + EXPECT_EQ(deserializedReq.locations[0].columnNumber, 3); + EXPECT_EQ(deserializedReq.locations[0].scriptId, "myScriptId"); +} + +TEST(MessageTests, testSetBreakpointResponse) { + std::string message = R"({ + "id": 1, + "result":{ + "breakpointId": "myBreakpointId", + "actualLocation": + { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + } + } + })"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetBreakpointResponse deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(deserializedReq.breakpointId, "myBreakpointId"); + EXPECT_EQ(deserializedReq.actualLocation.lineNumber, 2); + EXPECT_EQ(deserializedReq.actualLocation.columnNumber, 3); + EXPECT_EQ(deserializedReq.actualLocation.scriptId, "myScriptId"); + EXPECT_EQ(deserializedReq.id, 1); +} + +TEST(MessageTests, testSetInstrumentationBreakpointResponse) { + std::string message = R"({ + "id": 1, + "result":{ + "breakpointId": "myBreakpointId" + } + })"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::SetInstrumentationBreakpointResponse deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(deserializedReq.breakpointId, "myBreakpointId"); + EXPECT_EQ(deserializedReq.id, 1); +} + +TEST(MessageTests, testBreakpointResolvedNotification) { + std::string message = R"( + { + "method": "Debugger.breakpointResolved", + "params":{ + "breakpointId" : "42", + "location": + { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + } + } + } + )"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::BreakpointResolvedNotification deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(deserializedReq.method, "Debugger.breakpointResolved"); + EXPECT_EQ(deserializedReq.breakpointId, "42"); + EXPECT_EQ(deserializedReq.location.lineNumber, 2); + EXPECT_EQ(deserializedReq.location.columnNumber, 3); + EXPECT_EQ(deserializedReq.location.scriptId, "myScriptId"); +} + +TEST(MessageTests, testPauseNotificationMinimal) { + std::string message = R"( + { + "method": "Debugger.paused", + "params":{ + "reason": "Some Valid Reason", + "callFrames":[ + { + "callFrameId": "aCallFrameId", + "functionName": "aFunctionName", + "location":{ + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + }, + "url": "aURL", + "scopeChain": [ + { + "type": "aType", + "object": { + "type": "aRemoteObjectType" + } + } + ], + "this": { + "type": "aType" + } + } + ] + } + } + )"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::PausedNotification deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + EXPECT_FALSE(deserializedReq.callFrames[0].functionLocation.hasValue()); + EXPECT_FALSE(deserializedReq.callFrames[0].returnValue.hasValue()); + EXPECT_FALSE(deserializedReq.asyncStackTrace.hasValue()); + EXPECT_FALSE(deserializedReq.hitBreakpoints.hasValue()); + EXPECT_FALSE(deserializedReq.data.hasValue()); + + // Specifics + EXPECT_EQ(deserializedReq.method, "Debugger.paused"); + EXPECT_EQ(deserializedReq.reason, "Some Valid Reason"); + EXPECT_EQ(deserializedReq.callFrames[0].functionName, "aFunctionName"); + EXPECT_EQ(deserializedReq.callFrames[0].callFrameId, "aCallFrameId"); + EXPECT_EQ(deserializedReq.callFrames[0].url, "aURL"); + EXPECT_EQ(deserializedReq.callFrames[0].location.lineNumber, 2); + EXPECT_EQ(deserializedReq.callFrames[0].location.columnNumber, 3); + EXPECT_EQ(deserializedReq.callFrames[0].location.scriptId, "myScriptId"); + EXPECT_EQ(deserializedReq.callFrames[0].scopeChain[0].type, "aType"); + EXPECT_EQ( + deserializedReq.callFrames[0].scopeChain[0].object.type, + "aRemoteObjectType"); + EXPECT_EQ(deserializedReq.callFrames[0].thisObj.type, "aType"); +} + +TEST(MessageTests, testPauseNotificationFull) { + std::string message = R"( + { + "method": "Debugger.paused", + "params":{ + "reason": "Some Valid Reason", + "callFrames":[ + { + "functionLocation": { + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + }, + "returnValue" : { + "type": "aRemoteObjectType", + "subtype": "subtype", + "className":"className", + "value": "value", + "unserializableValue": "unserializableValue", + "description": "description", + "objectId": "objectId" + }, + "callFrameId": "aCallFrameId", + "functionName": "aFunctionName", + "location":{ + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId" + }, + "url": "aURL", + "scopeChain": [ + { + "type": "aType", + "object": { + "type": "aRemoteObjectType" + } + } + ], + "this": { + "type": "aType" + } + } + ], + "data": {"dataKey": "dataVal"}, + "hitBreakpoints": [ + "foo","bar" + ], + "asyncStackTrace":{ + "description": "an asyncStackTrace Desc", + "callFrames":[ + { + "functionName": "aFunctionName", + "lineNumber": 2, + "columnNumber": 3, + "scriptId": "myScriptId", + "url": "aURL" + } + ] + } + } + } + )"; + + folly::Optional functionLocation; + folly::Optional returnValue; + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::PausedNotification deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Check optionnals + // ---------------- + EXPECT_TRUE(deserializedReq.callFrames[0].functionLocation.hasValue()); + EXPECT_TRUE(deserializedReq.callFrames[0].returnValue.hasValue()); + EXPECT_TRUE(deserializedReq.asyncStackTrace.hasValue()); + EXPECT_TRUE(deserializedReq.hitBreakpoints.hasValue()); + EXPECT_TRUE(deserializedReq.data.hasValue()); + + EXPECT_TRUE( + deserializedReq.callFrames[0].returnValue.value().subtype.hasValue()); + EXPECT_TRUE( + deserializedReq.callFrames[0].returnValue.value().className.hasValue()); + EXPECT_TRUE(deserializedReq.callFrames[0] + .returnValue.value() + .unserializableValue.hasValue()); + EXPECT_TRUE( + deserializedReq.callFrames[0].returnValue.value().value.hasValue()); + EXPECT_TRUE( + deserializedReq.callFrames[0].returnValue.value().description.hasValue()); + EXPECT_TRUE( + deserializedReq.callFrames[0].returnValue.value().objectId.hasValue()); + + // Check optionnals Values + // ----------------------- + EXPECT_EQ( + deserializedReq.callFrames[0].functionLocation.value().lineNumber, 2); + EXPECT_EQ( + deserializedReq.callFrames[0].functionLocation.value().columnNumber, 3); + EXPECT_EQ( + deserializedReq.callFrames[0].functionLocation.value().scriptId, + "myScriptId"); + + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().type, + "aRemoteObjectType"); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().subtype.hasValue(), + true); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().subtype.value(), + "subtype"); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().className.hasValue(), + true); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().className.value(), + "className"); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().value.hasValue(), true); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().value.value(), "value"); + EXPECT_EQ( + deserializedReq.callFrames[0] + .returnValue.value() + .unserializableValue.hasValue(), + true); + EXPECT_EQ( + deserializedReq.callFrames[0] + .returnValue.value() + .unserializableValue.value(), + "unserializableValue"); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().description.hasValue(), + true); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().description.value(), + "description"); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().objectId.hasValue(), + true); + EXPECT_EQ( + deserializedReq.callFrames[0].returnValue.value().objectId.value(), + "objectId"); + + EXPECT_EQ(deserializedReq.hitBreakpoints.value()[0], "foo"); + EXPECT_EQ(deserializedReq.hitBreakpoints.value()[1], "bar"); + + EXPECT_EQ( + deserializedReq.data.value(), + folly::parseJson(R"({"dataKey": "dataVal"})")); + + // Check Compulsory + // ---------------- + EXPECT_EQ(deserializedReq.method, "Debugger.paused"); + EXPECT_EQ(deserializedReq.reason, "Some Valid Reason"); + EXPECT_EQ(deserializedReq.callFrames[0].functionName, "aFunctionName"); + EXPECT_EQ(deserializedReq.callFrames[0].callFrameId, "aCallFrameId"); + EXPECT_EQ(deserializedReq.callFrames[0].url, "aURL"); + EXPECT_EQ(deserializedReq.callFrames[0].location.lineNumber, 2); + EXPECT_EQ(deserializedReq.callFrames[0].location.columnNumber, 3); + EXPECT_EQ(deserializedReq.callFrames[0].location.scriptId, "myScriptId"); + EXPECT_EQ(deserializedReq.callFrames[0].scopeChain[0].type, "aType"); + EXPECT_EQ( + deserializedReq.callFrames[0].scopeChain[0].object.type, + "aRemoteObjectType"); + EXPECT_EQ(deserializedReq.callFrames[0].thisObj.type, "aType"); +} + +TEST(MessageTests, testResumedNotification) { + std::string message = R"( + { + "method": "Debugger.resumed" + } + )"; + + // Serialize and Deserialize are inverse functions + dynamic messageJSON = folly::parseJson(message); + debugger::ResumedNotification deserializedReq(messageJSON); + EXPECT_EQ(deserializedReq.toDynamic(), messageJSON); + + // Specifics + EXPECT_EQ(deserializedReq.method, "Debugger.resumed"); +} + } // namespace message } // namespace chrome } // namespace inspector diff --git a/ReactCommon/hermes/inspector/chrome/tests/RemoteObjectsTableTest.cpp b/ReactCommon/hermes/inspector/chrome/tests/RemoteObjectsTableTest.cpp index 0ee9e973d3a1e4..834a8e7270662b 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/RemoteObjectsTableTest.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/RemoteObjectsTableTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp b/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp index 0514db17fe9cef..60aff01ad0c9f7 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp +++ b/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h b/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h index 97da2ec8657ba6..d50018a3d24e8f 100644 --- a/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h +++ b/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/CallbackOStream.cpp b/ReactCommon/hermes/inspector/detail/CallbackOStream.cpp index ed0c5b7cffaeb9..a04524e7b142ef 100644 --- a/ReactCommon/hermes/inspector/detail/CallbackOStream.cpp +++ b/ReactCommon/hermes/inspector/detail/CallbackOStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/CallbackOStream.h b/ReactCommon/hermes/inspector/detail/CallbackOStream.h index 5085743c862410..44a1ab7cdf635b 100644 --- a/ReactCommon/hermes/inspector/detail/CallbackOStream.h +++ b/ReactCommon/hermes/inspector/detail/CallbackOStream.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/SerialExecutor.cpp b/ReactCommon/hermes/inspector/detail/SerialExecutor.cpp index d9c32797dd91cc..dbd89dff98fa68 100644 --- a/ReactCommon/hermes/inspector/detail/SerialExecutor.cpp +++ b/ReactCommon/hermes/inspector/detail/SerialExecutor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/SerialExecutor.h b/ReactCommon/hermes/inspector/detail/SerialExecutor.h index c4b7226f4b5532..e8e52f1310001b 100644 --- a/ReactCommon/hermes/inspector/detail/SerialExecutor.h +++ b/ReactCommon/hermes/inspector/detail/SerialExecutor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/Thread.cpp b/ReactCommon/hermes/inspector/detail/Thread.cpp index 09a50db7c94b42..adfb6330efbab7 100644 --- a/ReactCommon/hermes/inspector/detail/Thread.cpp +++ b/ReactCommon/hermes/inspector/detail/Thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/Thread.h b/ReactCommon/hermes/inspector/detail/Thread.h index c4e832e28e3c71..e4bbc03e6e239c 100644 --- a/ReactCommon/hermes/inspector/detail/Thread.h +++ b/ReactCommon/hermes/inspector/detail/Thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/tests/CallbackOStreamTests.cpp b/ReactCommon/hermes/inspector/detail/tests/CallbackOStreamTests.cpp index 03f0aadc919dda..3b37d4465b865d 100644 --- a/ReactCommon/hermes/inspector/detail/tests/CallbackOStreamTests.cpp +++ b/ReactCommon/hermes/inspector/detail/tests/CallbackOStreamTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/detail/tests/SerialExecutorTests.cpp b/ReactCommon/hermes/inspector/detail/tests/SerialExecutorTests.cpp index f6d44d4302a016..4a74de467b6ab2 100644 --- a/ReactCommon/hermes/inspector/detail/tests/SerialExecutorTests.cpp +++ b/ReactCommon/hermes/inspector/detail/tests/SerialExecutorTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/docs/GenerateInspectorFSM.sh b/ReactCommon/hermes/inspector/docs/GenerateInspectorFSM.sh index 83530976c8f441..6218d33d6ea31f 100755 --- a/ReactCommon/hermes/inspector/docs/GenerateInspectorFSM.sh +++ b/ReactCommon/hermes/inspector/docs/GenerateInspectorFSM.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/ReactCommon/hermes/inspector/tests/InspectorTests.cpp b/ReactCommon/hermes/inspector/tests/InspectorTests.cpp index 680625844bfbb8..6aa9608cb53dfb 100644 --- a/ReactCommon/hermes/inspector/tests/InspectorTests.cpp +++ b/ReactCommon/hermes/inspector/tests/InspectorTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/message_types.txt b/ReactCommon/hermes/inspector/tools/message_types.txt index 6267e82ee0ef03..801ff6a49dce42 100644 --- a/ReactCommon/hermes/inspector/tools/message_types.txt +++ b/ReactCommon/hermes/inspector/tools/message_types.txt @@ -28,8 +28,12 @@ HeapProfiler.heapStatsUpdate HeapProfiler.lastSeenObjectId HeapProfiler.getObjectByHeapObjectId HeapProfiler.getHeapObjectId +Profiler.start +Profiler.stop +Runtime.callFunctionOn Runtime.consoleAPICalled Runtime.evaluate Runtime.executionContextCreated +Runtime.getHeapUsage Runtime.getProperties Runtime.runIfWaitingForDebugger diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js index 5be283814000a7..b409e81cced78b 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js index 00cdcb7e42fe8c..8ebb1ecb6e918f 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/GraphTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/GraphTest.js index 5f443e47903ce1..b890c050ea8905 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/GraphTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/GraphTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js index 44bd13aac1a896..1c9da38f7b99ab 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js index 4437bb144dccf1..6ad01e08231a81 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js index 583fcdf737b8a3..f1f1c8a5be7e3b 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js index 6f5a8649ba1462..14fc860e1e2d0d 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/package.json b/ReactCommon/hermes/inspector/tools/msggen/package.json index 6e42007bf68bfb..b3dcba4544fbe1 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/package.json +++ b/ReactCommon/hermes/inspector/tools/msggen/package.json @@ -12,7 +12,7 @@ "test": "jest" }, "dependencies": { - "devtools-protocol": "0.0.730699", + "devtools-protocol": "0.0.959523", "yargs": "^14.2.0" }, "devDependencies": { diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Command.js b/ReactCommon/hermes/inspector/tools/msggen/src/Command.js index 08b74abcb73a15..b7b60d4aeac1b7 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Command.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Command.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Converters.js b/ReactCommon/hermes/inspector/tools/msggen/src/Converters.js index 2eb43df111b0ad..8061ef1a41aa24 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Converters.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Converters.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Event.js b/ReactCommon/hermes/inspector/tools/msggen/src/Event.js index 7e04311a686728..9edfe7f8f2bea3 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Event.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Event.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/GeneratedHeader.js b/ReactCommon/hermes/inspector/tools/msggen/src/GeneratedHeader.js index dbf43749213a73..9533b2425e2866 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/GeneratedHeader.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/GeneratedHeader.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,5 +12,5 @@ // placeholder token that will be replaced by signedsource script export const GeneratedHeader: string = - '// Copyright 2004-present Facebook. All Rights Reserved.\n' + + '// Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved.\n' + '// @generated <>'; diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Graph.js b/ReactCommon/hermes/inspector/tools/msggen/src/Graph.js index 98fc5e926dad72..d14760ce93d071 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Graph.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Graph.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js b/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js index a5f951783ab953..5784f9f2f261bd 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -70,7 +70,7 @@ export class HeaderWriter { this.stream.write('struct UnknownRequest;\n\n'); const namespaceMap: Map> = new Map(); - const addToMap = function (type) { + const addToMap = function (type: Type | Command | Event) { const domain = type.domain; let types = namespaceMap.get(domain); if (!types) { diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js b/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js index 7dea2bb04d3b42..e2ff75628271b9 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -266,13 +266,26 @@ export function emitRequestDef(stream: Writable, command: Command) { assign(method, obj, "method");\n\n`); if (props.length > 0) { - stream.write('dynamic params = obj.at("params");\n'); + const optionalParams = props.every(p => p.optional); + if (optionalParams) { + stream.write(` + auto it = obj.find("params"); + if (it != obj.items().end()) { + dynamic params = it->second; + `); + } else { + stream.write('dynamic params = obj.at("params");\n'); + } for (const prop of props) { const id = prop.getCppIdentifier(); const name = prop.name; stream.write(`assign(${id}, params, "${name}");\n`); } + + if (optionalParams) { + stream.write('}'); + } } stream.write('}\n\n'); diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Property.js b/ReactCommon/hermes/inspector/tools/msggen/src/Property.js index bfcf5d1a23760a..2ee60145ff6790 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Property.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Property.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -195,7 +195,7 @@ class ArrayProperty extends Property { getFullCppType(): string { let elemType: string = 'folly::dynamic'; - let recursive = false; + let recursive: ?(false | boolean) = false; if (this.items) { if (this.items.type) { diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js b/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js index 476dc195734c81..c53ab4c946789a 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/Type.js b/ReactCommon/hermes/inspector/tools/msggen/src/Type.js index d91432f45693fe..18f9ac11cf5e83 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/Type.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/Type.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/index.js b/ReactCommon/hermes/inspector/tools/msggen/src/index.js index b9a420c592f5c8..1a137ac7170759 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/index.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -32,7 +32,7 @@ type Descriptor = {| events: Array, |}; -function mergeDomains(original, extra) { +function mergeDomains(original: any, extra: any) { return {...original, domains: original.domains.concat(extra.domains)}; } @@ -41,6 +41,7 @@ const proto = mergeDomains(standard, custom); function parseDomains( domainObjs: Array, ignoreExperimental: boolean, + includeExperimental: Set, ): Descriptor { const desc = { types: [], @@ -59,7 +60,12 @@ function parseDomains( } for (const commandObj of obj.commands || []) { - const command = Command.create(domain, commandObj, ignoreExperimental); + const command = Command.create( + domain, + commandObj, + !includeExperimental.has(`${domain}.${commandObj.name}`) && + ignoreExperimental, + ); if (command) { desc.commands.push(command); } @@ -180,7 +186,7 @@ function filterReachableFromRoots( // Sort commands and events so the code is easier to read. Types have to be // topologically sorted as explained above. - const comparator = (a, b) => { + const comparator = (a: Command | Event, b: Command | Event) => { const id1 = a.getDebuggerName(); const id2 = b.getDebuggerName(); return id1 < id2 ? -1 : id1 > id2 ? 1 : 0; @@ -199,18 +205,27 @@ function main() { .boolean('e') .alias('e', 'ignore-experimental') .describe('e', 'ignore experimental commands, props, and types') + .alias('i', 'include-experimental') + .describe('i', 'experimental commands to include') .alias('r', 'roots') .describe('r', 'path to a file listing root types, events, and commands') .nargs('r', 1) .demandCommand(2, 2).argv; const ignoreExperimental = !!args.e; + const includeExperimental = new Set( + typeof args.i === 'string' ? args.i.split(',') : [], + ); const [headerPath, implPath] = args._; const headerStream = fs.createWriteStream(headerPath); const implStream = fs.createWriteStream(implPath); - const desc = parseDomains(proto.domains, ignoreExperimental); + const desc = parseDomains( + proto.domains, + ignoreExperimental, + includeExperimental, + ); const graph = buildGraph(desc); const roots = parseRoots(desc, String(args.roots)); diff --git a/ReactCommon/hermes/inspector/tools/msggen/yarn.lock b/ReactCommon/hermes/inspector/tools/msggen/yarn.lock index b6b1be6b96f535..40a02746282e98 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +++ b/ReactCommon/hermes/inspector/tools/msggen/yarn.lock @@ -2434,10 +2434,10 @@ detect-newline@^3.0.0: resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== -devtools-protocol@0.0.730699: - version "0.0.730699" - resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.730699.tgz#4d18f6a9b7fb7cf3f1ffe73bfe14aad66cf3b2ef" - integrity sha512-dprBpuPzVIIXXL6GevzhvWe2wg836h3d5hY+n6IzzHbKLsUh6QlVmcIy15za0J3MhDFbmEH60s6uYsrw/tgBbw== +devtools-protocol@0.0.959523: + version "0.0.959523" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.959523.tgz#a7ce62c6b88876081fe5bec866f70e467bc021ba" + integrity sha512-taOcAND/oJA5FhJD2I3RA+I8RPdrpPJWwvMBPzTq7Sugev1xTOG3lgtlSfkh5xkjTYw0Ti2CRQq016goFHMoPQ== diff-sequences@^26.6.2: version "26.6.2" diff --git a/ReactCommon/hermes/inspector/tools/run_msggen b/ReactCommon/hermes/inspector/tools/run_msggen index 053cb3673727e5..afe7901ea62f37 100755 --- a/ReactCommon/hermes/inspector/tools/run_msggen +++ b/ReactCommon/hermes/inspector/tools/run_msggen @@ -2,24 +2,29 @@ set -e -DIR=$(dirname "${BASH_SOURCE[0]}") +DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) + +MSGTYPES_PATH="${DIR}/message_types.txt" +HEADER_PATH="${DIR}/../chrome/MessageTypes.h" +CPP_PATH="${DIR}/../chrome/MessageTypes.cpp" + +FBSOURCE=$(hg root) +CLANG_FORMAT="${FBSOURCE}/tools/third-party/clang-format/clang-format" +SIGNEDSOURCE="${FBSOURCE}/tools/signedsource" + cd "${DIR}/msggen" yarn install yarn build -FBSOURCE=$(hg root) -MSGTYPES_PATH="${FBSOURCE}/xplat/js/react-native-github/ReactCommon/hermes/inspector/tools/message_types.txt" -HEADER_PATH="${FBSOURCE}/xplat/js/react-native-github/ReactCommon/hermes/inspector/chrome/MessageTypes.h" -CPP_PATH="${FBSOURCE}/xplat/js/react-native-github/ReactCommon/hermes/inspector/chrome/MessageTypes.cpp" - node bin/index.js \ --ignore-experimental \ - --roots "$MSGTYPES_PATH" \ - "$HEADER_PATH" "$CPP_PATH" + --include-experimental=Runtime.getHeapUsage \ + --roots "${MSGTYPES_PATH}" \ + "${HEADER_PATH}" "${CPP_PATH}" -clang-format -i --style=file "$HEADER_PATH" -clang-format -i --style=file "$CPP_PATH" +"${CLANG_FORMAT}" -i --style=file "${HEADER_PATH}" +"${CLANG_FORMAT}" -i --style=file "${CPP_PATH}" -"${FBSOURCE}/tools/signedsource" sign "$HEADER_PATH" -"${FBSOURCE}/tools/signedsource" sign "$CPP_PATH" +"${SIGNEDSOURCE}" sign "${HEADER_PATH}" +"${SIGNEDSOURCE}" sign "${CPP_PATH}" diff --git a/ReactCommon/hermes/inspector/tools/sandcastle/build_and_test.sh b/ReactCommon/hermes/inspector/tools/sandcastle/build_and_test.sh index 12c603ffe55be9..dab7ee09b674d9 100755 --- a/ReactCommon/hermes/inspector/tools/sandcastle/build_and_test.sh +++ b/ReactCommon/hermes/inspector/tools/sandcastle/build_and_test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/ReactCommon/hermes/inspector/tools/sandcastle/setup.sh b/ReactCommon/hermes/inspector/tools/sandcastle/setup.sh index b4da00851ec94f..eb6c194f59524f 100755 --- a/ReactCommon/hermes/inspector/tools/sandcastle/setup.sh +++ b/ReactCommon/hermes/inspector/tools/sandcastle/setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/ReactCommon/jsi/Android.mk b/ReactCommon/jsi/Android.mk deleted file mode 100644 index 3fce2059e2d759..00000000000000 --- a/ReactCommon/jsi/Android.mk +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsi - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jsi/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 -LOCAL_SHARED_LIBRARIES := libfolly_json glog - -include $(BUILD_SHARED_LIBRARY) - - -include $(CLEAR_VARS) - -LOCAL_MODULE := jscruntime - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 -LOCAL_SHARED_LIBRARIES := libfolly_json libjsc glog - -# TODO: Remove this flag when ready. -# Android has this enabled by default, but the flag is still needed for iOS. -LOCAL_CFLAGS += -DRN_FABRIC_ENABLED - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/jsi/BUCK b/ReactCommon/jsi/BUCK index a3bfde64b98d8c..7186cad79e24fa 100644 --- a/ReactCommon/jsi/BUCK +++ b/ReactCommon/jsi/BUCK @@ -27,7 +27,10 @@ rn_xplat_cxx_library( "-Wglobal-constructors", "-Wmissing-prototypes", ], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], visibility = ["PUBLIC"], ) @@ -41,7 +44,10 @@ rn_xplat_cxx_library( "jsi/JSIDynamic.h", ], fbobjc_force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], visibility = [ "PUBLIC", ], @@ -68,7 +74,10 @@ rn_xplat_cxx_library( fbobjc_frameworks = [ "$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework", ], - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = APPLE, visibility = ["PUBLIC"], xplat_mangled_args = { diff --git a/ReactCommon/jsi/CMakeLists.txt b/ReactCommon/jsi/CMakeLists.txt new file mode 100644 index 00000000000000..3f2a8c15d3faaa --- /dev/null +++ b/ReactCommon/jsi/CMakeLists.txt @@ -0,0 +1,43 @@ +# 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. + +################## +### jsi ### +################## + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -O3 + -Wno-unused-lambda-capture + -DLOG_TAG=\"ReactNative\") + +file(GLOB jsi_SRC CONFIGURE_DEPENDS jsi/*.cpp) +add_library(jsi SHARED ${jsi_SRC}) + +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) diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index c9465b33dff585..9eb578a229eb12 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -142,6 +142,7 @@ class JSCRuntime : public jsi::Runtime { }; PointerValue *cloneSymbol(const Runtime::PointerValue *pv) override; + PointerValue *cloneBigInt(const Runtime::PointerValue *pv) override; PointerValue *cloneString(const Runtime::PointerValue *pv) override; PointerValue *cloneObject(const Runtime::PointerValue *pv) override; PointerValue *clonePropNameID(const Runtime::PointerValue *pv) override; @@ -151,6 +152,7 @@ class JSCRuntime : public jsi::Runtime { jsi::PropNameID createPropNameIDFromUtf8(const uint8_t *utf8, size_t length) override; jsi::PropNameID createPropNameIDFromString(const jsi::String &str) override; + jsi::PropNameID createPropNameIDFromSymbol(const jsi::Symbol &sym) override; std::string utf8(const jsi::PropNameID &) override; bool compare(const jsi::PropNameID &, const jsi::PropNameID &) override; @@ -166,6 +168,12 @@ class JSCRuntime : public jsi::Runtime { const jsi::Object &) override; jsi::HostFunctionType &getHostFunction(const jsi::Function &) override; + bool hasNativeState(const jsi::Object &) override; + std::shared_ptr getNativeState( + const jsi::Object &) override; + void setNativeState(const jsi::Object &, std::shared_ptr) + override; + jsi::Value getProperty(const jsi::Object &, const jsi::String &name) override; jsi::Value getProperty(const jsi::Object &, const jsi::PropNameID &name) override; @@ -213,6 +221,7 @@ class JSCRuntime : public jsi::Runtime { size_t count) override; bool strictEquals(const jsi::Symbol &a, const jsi::Symbol &b) const override; + bool strictEquals(const jsi::BigInt &a, const jsi::BigInt &b) const override; bool strictEquals(const jsi::String &a, const jsi::String &b) const override; bool strictEquals(const jsi::Object &a, const jsi::Object &b) const override; bool instanceOf(const jsi::Object &o, const jsi::Function &f) override; @@ -598,6 +607,11 @@ jsi::Runtime::PointerValue *JSCRuntime::cloneSymbol( return makeSymbolValue(symbol->sym_); } +jsi::Runtime::PointerValue *JSCRuntime::cloneBigInt( + const Runtime::PointerValue *) { + throw std::logic_error("Not implemented"); +} + jsi::Runtime::PointerValue *JSCRuntime::cloneString( const jsi::Runtime::PointerValue *pv) { if (!pv) { @@ -653,6 +667,13 @@ jsi::PropNameID JSCRuntime::createPropNameIDFromString(const jsi::String &str) { return createPropNameID(stringRef(str)); } +jsi::PropNameID JSCRuntime::createPropNameIDFromSymbol(const jsi::Symbol &sym) { + // TODO: Support for symbols through the native API in JSC is very limited. + // While we could construct a PropNameID here, we would not be able to get a + // symbol property through the C++ API. + throw std::logic_error("Not implemented"); +} + std::string JSCRuntime::utf8(const jsi::PropNameID &sym) { return JSStringToSTLString(stringRef(sym)); } @@ -847,6 +868,21 @@ std::shared_ptr JSCRuntime::getHostObject( return metadata->hostObject; } +bool JSCRuntime::hasNativeState(const jsi::Object &) { + throw std::logic_error("Not implemented"); +} + +std::shared_ptr JSCRuntime::getNativeState( + const jsi::Object &) { + throw std::logic_error("Not implemented"); +} + +void JSCRuntime::setNativeState( + const jsi::Object &, + std::shared_ptr) { + throw std::logic_error("Not implemented"); +} + jsi::Value JSCRuntime::getProperty( const jsi::Object &obj, const jsi::String &name) { @@ -1291,6 +1327,11 @@ bool JSCRuntime::strictEquals(const jsi::Symbol &a, const jsi::Symbol &b) return ret; } +bool JSCRuntime::strictEquals(const jsi::BigInt &a, const jsi::BigInt &b) + const { + throw std::logic_error("Not implemented"); +} + bool JSCRuntime::strictEquals(const jsi::String &a, const jsi::String &b) const { return JSStringIsEqual(stringRef(a), stringRef(b)); diff --git a/ReactCommon/jsi/JSCRuntime.h b/ReactCommon/jsi/JSCRuntime.h index 54554230f04993..1d6b2259fcdbe2 100644 --- a/ReactCommon/jsi/JSCRuntime.h +++ b/ReactCommon/jsi/JSCRuntime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/React-jsi.podspec b/ReactCommon/jsi/React-jsi.podspec index 92bc7f92d07cac..0e2ee388889c50 100644 --- a/ReactCommon/jsi/React-jsi.podspec +++ b/ReactCommon/jsi/React-jsi.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "**/*.{cpp,h}" s.exclude_files = "**/test/*" diff --git a/ReactCommon/jsi/jsi/CMakeLists.txt b/ReactCommon/jsi/jsi/CMakeLists.txt index acfa48395e518b..3d2959e54914aa 100644 --- a/ReactCommon/jsi/jsi/CMakeLists.txt +++ b/ReactCommon/jsi/jsi/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/ReactCommon/jsi/jsi/JSIDynamic.cpp b/ReactCommon/jsi/jsi/JSIDynamic.cpp index acac7a3a04729d..4464cc3b62f952 100644 --- a/ReactCommon/jsi/jsi/JSIDynamic.cpp +++ b/ReactCommon/jsi/jsi/JSIDynamic.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/JSIDynamic.h b/ReactCommon/jsi/jsi/JSIDynamic.h index 41f9d9f8f33375..110dd13999f437 100644 --- a/ReactCommon/jsi/jsi/JSIDynamic.h +++ b/ReactCommon/jsi/jsi/JSIDynamic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/decorator.h b/ReactCommon/jsi/jsi/decorator.h index be6f4f568b68ec..5c4811ac26ba8e 100644 --- a/ReactCommon/jsi/jsi/decorator.h +++ b/ReactCommon/jsi/jsi/decorator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -154,6 +154,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation { Runtime::PointerValue* cloneSymbol(const Runtime::PointerValue* pv) override { return plain_.cloneSymbol(pv); }; + Runtime::PointerValue* cloneBigInt(const Runtime::PointerValue* pv) override { + return plain_.cloneBigInt(pv); + }; Runtime::PointerValue* cloneString(const Runtime::PointerValue* pv) override { return plain_.cloneString(pv); }; @@ -176,6 +179,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation { PropNameID createPropNameIDFromString(const String& str) override { return plain_.createPropNameIDFromString(str); }; + PropNameID createPropNameIDFromSymbol(const Symbol& sym) override { + return plain_.createPropNameIDFromSymbol(sym); + }; std::string utf8(const PropNameID& id) override { return plain_.utf8(id); }; @@ -216,6 +222,17 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation { return dhf.target()->plainHF_; }; + bool hasNativeState(const Object& o) override { + return plain_.hasNativeState(o); + } + std::shared_ptr getNativeState(const Object& o) override { + return plain_.getNativeState(o); + } + void setNativeState(const Object& o, std::shared_ptr state) + override { + plain_.setNativeState(o, state); + } + Value getProperty(const Object& o, const PropNameID& name) override { return plain_.getProperty(o, name); }; @@ -312,6 +329,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation { bool strictEquals(const Symbol& a, const Symbol& b) const override { return plain_.strictEquals(a, b); }; + bool strictEquals(const BigInt& a, const BigInt& b) const override { + return plain_.strictEquals(a, b); + }; bool strictEquals(const String& a, const String& b) const override { return plain_.strictEquals(a, b); }; diff --git a/ReactCommon/jsi/jsi/instrumentation.h b/ReactCommon/jsi/jsi/instrumentation.h index a337a7a841510f..e841af07df8f1d 100644 --- a/ReactCommon/jsi/jsi/instrumentation.h +++ b/ReactCommon/jsi/jsi/instrumentation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/jsi-inl.h b/ReactCommon/jsi/jsi/jsi-inl.h index 63d4a2f5868d90..992ee9f535e84f 100644 --- a/ReactCommon/jsi/jsi/jsi-inl.h +++ b/ReactCommon/jsi/jsi/jsi-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -56,7 +56,12 @@ inline PropNameID&& toPropNameID(Runtime&, PropNameID&& name) { return std::move(name); } -void throwJSError(Runtime&, const char* msg); +/// Helper to throw while still compiling with exceptions turned off. +template +[[noreturn]] inline void throwOrDie(Args&&... args) { + std::rethrow_exception( + std::make_exception_ptr(E{std::forward(args)...})); +} } // namespace detail @@ -184,7 +189,8 @@ inline std::shared_ptr Object::getHostObject(Runtime& runtime) const { template inline std::shared_ptr Object::asHostObject(Runtime& runtime) const { if (!isHostObject(runtime)) { - detail::throwJSError(runtime, "Object is not a HostObject of desired type"); + detail::throwOrDie( + "Object is not a HostObject of desired type"); } return std::static_pointer_cast(runtime.getHostObject(*this)); } @@ -196,6 +202,24 @@ inline std::shared_ptr Object::getHostObject( return runtime.getHostObject(*this); } +template +inline bool Object::hasNativeState(Runtime& runtime) const { + return runtime.hasNativeState(*this) && + std::dynamic_pointer_cast(runtime.getNativeState(*this)); +} + +template +inline std::shared_ptr Object::getNativeState(Runtime& runtime) const { + assert(hasNativeState(runtime)); + return std::static_pointer_cast(runtime.getNativeState(*this)); +} + +inline void Object::setNativeState( + Runtime& runtime, + std::shared_ptr state) const { + runtime.setNativeState(*this, state); +} + inline Array Object::getPropertyNames(Runtime& runtime) const { return runtime.getPropertyNames(*this); } diff --git a/ReactCommon/jsi/jsi/jsi.cpp b/ReactCommon/jsi/jsi/jsi.cpp index be38c9787ecd84..c8fe78379eaf67 100644 --- a/ReactCommon/jsi/jsi/jsi.cpp +++ b/ReactCommon/jsi/jsi/jsi.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -30,6 +30,10 @@ std::string kindToString(const Value& v, Runtime* rt = nullptr) { return "a number"; } else if (v.isString()) { return "a string"; + } else if (v.isSymbol()) { + return "a symbol"; + } else if (v.isBigInt()) { + return "a bigint"; } else { assert(v.isObject() && "Expecting object."); return rt != nullptr && v.getObject(*rt).isFunction(*rt) ? "a function" @@ -60,14 +64,6 @@ Value callGlobalFunction(Runtime& runtime, const char* name, const Value& arg) { } // namespace -namespace detail { - -void throwJSError(Runtime& rt, const char* msg) { - throw JSError(rt, msg); -} - -} // namespace detail - Buffer::~Buffer() = default; PreparedJavaScript::~PreparedJavaScript() = default; @@ -85,6 +81,8 @@ void HostObject::set(Runtime& rt, const PropNameID& name, const Value&) { HostObject::~HostObject() {} +NativeState::~NativeState() {} + Runtime::~Runtime() {} Instrumentation& Runtime::instrumentation() { @@ -240,6 +238,8 @@ Value::Value(Runtime& runtime, const Value& other) : Value(other.kind_) { data_.number = other.data_.number; } else if (kind_ == SymbolKind) { new (&data_.pointer) Pointer(runtime.cloneSymbol(other.data_.pointer.ptr_)); + } else if (kind_ == BigIntKind) { + new (&data_.pointer) Pointer(runtime.cloneBigInt(other.data_.pointer.ptr_)); } else if (kind_ == StringKind) { new (&data_.pointer) Pointer(runtime.cloneString(other.data_.pointer.ptr_)); } else if (kind_ >= ObjectKind) { @@ -269,6 +269,10 @@ bool Value::strictEquals(Runtime& runtime, const Value& a, const Value& b) { return runtime.strictEquals( static_cast(a.data_.pointer), static_cast(b.data_.pointer)); + case BigIntKind: + return runtime.strictEquals( + static_cast(a.data_.pointer), + static_cast(b.data_.pointer)); case StringKind: return runtime.strictEquals( static_cast(a.data_.pointer), @@ -281,6 +285,15 @@ bool Value::strictEquals(Runtime& runtime, const Value& a, const Value& b) { return false; } +bool Value::asBool() const { + if (!isBool()) { + throw JSINativeException( + "Value is " + kindToString(*this) + ", expected a boolean"); + } + + return getBool(); +} + double Value::asNumber() const { if (!isNumber()) { throw JSINativeException( @@ -327,6 +340,24 @@ Symbol Value::asSymbol(Runtime& rt) && { return std::move(*this).getSymbol(rt); } +BigInt Value::asBigInt(Runtime& rt) const& { + if (!isBigInt()) { + throw JSError( + rt, "Value is " + kindToString(*this, &rt) + ", expected a BigInt"); + } + + return getBigInt(rt); +} + +BigInt Value::asBigInt(Runtime& rt) && { + if (!isBigInt()) { + throw JSError( + rt, "Value is " + kindToString(*this, &rt) + ", expected a BigInt"); + } + + return std::move(*this).getBigInt(rt); +} + String Value::asString(Runtime& rt) const& { if (!isString()) { throw JSError( diff --git a/ReactCommon/jsi/jsi/jsi.h b/ReactCommon/jsi/jsi/jsi.h index 937c0611db66ee..4dc4a8fe5dc0e2 100644 --- a/ReactCommon/jsi/jsi/jsi.h +++ b/ReactCommon/jsi/jsi/jsi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -68,6 +68,7 @@ class Runtime; class Pointer; class PropNameID; class Symbol; +class BigInt; class String; class Object; class WeakObject; @@ -127,6 +128,13 @@ class JSI_EXPORT HostObject { virtual std::vector getPropertyNames(Runtime& rt); }; +/// Native state (and destructor) that can be attached to any JS object +/// using setNativeState. +class JSI_EXPORT NativeState { + public: + virtual ~NativeState(); +}; + /// Represents a JS runtime. Movable, but not copyable. Note that /// this object may not be thread-aware, but cannot be used safely from /// multiple threads at once. The application is responsible for @@ -240,6 +248,7 @@ class JSI_EXPORT Runtime { friend class Pointer; friend class PropNameID; friend class Symbol; + friend class BigInt; friend class String; friend class Object; friend class WeakObject; @@ -263,6 +272,7 @@ class JSI_EXPORT Runtime { }; virtual PointerValue* cloneSymbol(const Runtime::PointerValue* pv) = 0; + virtual PointerValue* cloneBigInt(const Runtime::PointerValue* pv) = 0; virtual PointerValue* cloneString(const Runtime::PointerValue* pv) = 0; virtual PointerValue* cloneObject(const Runtime::PointerValue* pv) = 0; virtual PointerValue* clonePropNameID(const Runtime::PointerValue* pv) = 0; @@ -274,6 +284,7 @@ class JSI_EXPORT Runtime { const uint8_t* utf8, size_t length) = 0; virtual PropNameID createPropNameIDFromString(const String& str) = 0; + virtual PropNameID createPropNameIDFromSymbol(const Symbol& sym) = 0; virtual std::string utf8(const PropNameID&) = 0; virtual bool compare(const PropNameID&, const PropNameID&) = 0; @@ -292,6 +303,12 @@ class JSI_EXPORT Runtime { virtual std::shared_ptr getHostObject(const jsi::Object&) = 0; virtual HostFunctionType& getHostFunction(const jsi::Function&) = 0; + virtual bool hasNativeState(const jsi::Object&) = 0; + virtual std::shared_ptr getNativeState(const jsi::Object&) = 0; + virtual void setNativeState( + const jsi::Object&, + std::shared_ptr state) = 0; + virtual Value getProperty(const Object&, const PropNameID& name) = 0; virtual Value getProperty(const Object&, const String& name) = 0; virtual bool hasProperty(const Object&, const PropNameID& name) = 0; @@ -336,6 +353,7 @@ class JSI_EXPORT Runtime { virtual void popScope(ScopeState*); virtual bool strictEquals(const Symbol& a, const Symbol& b) const = 0; + virtual bool strictEquals(const BigInt& a, const BigInt& b) const = 0; virtual bool strictEquals(const String& a, const String& b) const = 0; virtual bool strictEquals(const Object& a, const Object& b) const = 0; @@ -406,6 +424,7 @@ class JSI_EXPORT PropNameID : public Pointer { } /// Create a PropNameID from utf8 values. The data is copied. + /// Results are undefined if \p utf8 contains invalid code points. static PropNameID forUtf8(Runtime& runtime, const uint8_t* utf8, size_t length) { return runtime.createPropNameIDFromUtf8(utf8, length); @@ -413,6 +432,7 @@ class JSI_EXPORT PropNameID : public Pointer { /// Create a PropNameID from utf8-encoded octets stored in a /// std::string. The string data is transformed and copied. + /// Results are undefined if \p utf8 contains invalid code points. static PropNameID forUtf8(Runtime& runtime, const std::string& utf8) { return runtime.createPropNameIDFromUtf8( reinterpret_cast(utf8.data()), utf8.size()); @@ -423,6 +443,11 @@ class JSI_EXPORT PropNameID : public Pointer { return runtime.createPropNameIDFromString(str); } + /// Create a PropNameID from a JS symbol. + static PropNameID forSymbol(Runtime& runtime, const jsi::Symbol& sym) { + return runtime.createPropNameIDFromSymbol(sym); + } + // Creates a vector of PropNameIDs constructed from given arguments. template static std::vector names(Runtime& runtime, Args&&... args); @@ -474,6 +499,18 @@ class JSI_EXPORT Symbol : public Pointer { friend class Value; }; +/// Represents a JS BigInt. Movable, not copyable. +class JSI_EXPORT BigInt : public Pointer { + public: + using Pointer::Pointer; + + BigInt(BigInt&& other) = default; + BigInt& operator=(BigInt&& other) = default; + + friend class Runtime; + friend class Value; +}; + /// Represents a JS String. Movable, not copyable. class JSI_EXPORT String : public Pointer { public: @@ -502,14 +539,16 @@ class JSI_EXPORT String : public Pointer { } /// Create a JS string from utf8-encoded octets. The string data is - /// transformed and copied. + /// transformed and copied. Results are undefined if \p utf8 contains invalid + /// code points. static String createFromUtf8(Runtime& runtime, const uint8_t* utf8, size_t length) { return runtime.createStringFromUtf8(utf8, length); } /// Create a JS string from utf8-encoded octets stored in a - /// std::string. The string data is transformed and copied. + /// std::string. The string data is transformed and copied. Results are + /// undefined if \p utf8 contains invalid code points. static String createFromUtf8(Runtime& runtime, const std::string& utf8) { return runtime.createStringFromUtf8( reinterpret_cast(utf8.data()), utf8.length()); @@ -685,6 +724,25 @@ class JSI_EXPORT Object : public Pointer { template std::shared_ptr asHostObject(Runtime& runtime) const; + /// \return whether this object has native state of type T previously set by + /// \c setNativeState. + template + bool hasNativeState(Runtime& runtime) const; + + /// \return a shared_ptr to the state previously set by \c setNativeState. + /// If \c hasNativeState is false, this will assert. Note that this does a + /// type check and will assert if the native state isn't of type \c T + template + std::shared_ptr getNativeState(Runtime& runtime) const; + + /// Set the internal native state property of this object, overwriting any old + /// value. Creates a new shared_ptr to the object managed by \p state, which + /// will live until the value at this property becomes unreachable. + /// + /// Throws a type error if this object is a proxy or host object. + void setNativeState(Runtime& runtime, std::shared_ptr state) + const; + /// \return same as \c getProperty(name).asObject(), except with /// a better exception message. Object getPropertyAsObject(Runtime& runtime, const char* name) const; @@ -963,6 +1021,7 @@ class JSI_EXPORT Value { /* implicit */ Value(T&& other) : Value(kindOf(other)) { static_assert( std::is_base_of::value || + std::is_base_of::value || std::is_base_of::value || std::is_base_of::value, "Value cannot be implicitly move-constructed from this type"); @@ -982,7 +1041,12 @@ class JSI_EXPORT Value { /// Copies a Symbol lvalue into a new JS value. Value(Runtime& runtime, const Symbol& sym) : Value(SymbolKind) { - new (&data_.pointer) String(runtime.cloneSymbol(sym.ptr_)); + new (&data_.pointer) Symbol(runtime.cloneSymbol(sym.ptr_)); + } + + /// Copies a BigInt lvalue into a new JS value. + Value(Runtime& runtime, const BigInt& bigint) : Value(BigIntKind) { + new (&data_.pointer) BigInt(runtime.cloneBigInt(bigint.ptr_)); } /// Copies a String lvalue into a new JS value. @@ -1054,6 +1118,10 @@ class JSI_EXPORT Value { return kind_ == StringKind; } + bool isBigInt() const { + return kind_ == BigIntKind; + } + bool isSymbol() const { return kind_ == SymbolKind; } @@ -1068,6 +1136,10 @@ class JSI_EXPORT Value { return data_.boolean; } + /// \return the boolean value, or throws JSIException if not a + /// boolean. + bool asBool() const; + /// \return the number value, or asserts if not a number. double getNumber() const { assert(isNumber()); @@ -1098,6 +1170,26 @@ class JSI_EXPORT Value { Symbol asSymbol(Runtime& runtime) const&; Symbol asSymbol(Runtime& runtime) &&; + /// \return the BigInt value, or asserts if not a bigint. + BigInt getBigInt(Runtime& runtime) const& { + assert(isBigInt()); + return BigInt(runtime.cloneBigInt(data_.pointer.ptr_)); + } + + /// \return the BigInt value, or asserts if not a bigint. + /// Can be used on rvalue references to avoid cloning more bigints. + BigInt getBigInt(Runtime&) && { + assert(isBigInt()); + auto ptr = data_.pointer.ptr_; + data_.pointer.ptr_ = nullptr; + return static_cast(ptr); + } + + /// \return the BigInt value, or throws JSIException if not a + /// bigint + BigInt asBigInt(Runtime& runtime) const&; + BigInt asBigInt(Runtime& runtime) &&; + /// \return the String value, or asserts if not a string. String getString(Runtime& runtime) const& { assert(isString()); @@ -1150,6 +1242,7 @@ class JSI_EXPORT Value { BooleanKind, NumberKind, SymbolKind, + BigIntKind, StringKind, ObjectKind, PointerKind = SymbolKind, @@ -1176,6 +1269,9 @@ class JSI_EXPORT Value { constexpr static ValueKind kindOf(const Symbol&) { return SymbolKind; } + constexpr static ValueKind kindOf(const BigInt&) { + return BigIntKind; + } constexpr static ValueKind kindOf(const String&) { return StringKind; } @@ -1238,11 +1334,13 @@ class JSI_EXPORT JSIException : public std::exception { JSIException(std::string what) : what_(std::move(what)){}; public: + JSIException(const JSIException&) = default; + virtual const char* what() const noexcept override { return what_.c_str(); } - virtual ~JSIException(); + virtual ~JSIException() override; protected: std::string what_; @@ -1254,6 +1352,8 @@ class JSI_EXPORT JSINativeException : public JSIException { public: JSINativeException(std::string what) : JSIException(std::move(what)) {} + JSINativeException(const JSINativeException&) = default; + virtual ~JSINativeException(); }; @@ -1283,6 +1383,8 @@ class JSI_EXPORT JSError : public JSIException { /// but necessary to avoid ambiguity with the above. JSError(std::string what, Runtime& rt, Value&& value); + JSError(const JSError&) = default; + virtual ~JSError(); const std::string& getStack() const { diff --git a/ReactCommon/jsi/jsi/jsilib-posix.cpp b/ReactCommon/jsi/jsi/jsilib-posix.cpp index 87b1bdf364d347..b47d0d4ab81be4 100644 --- a/ReactCommon/jsi/jsi/jsilib-posix.cpp +++ b/ReactCommon/jsi/jsi/jsilib-posix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/jsilib-windows.cpp b/ReactCommon/jsi/jsi/jsilib-windows.cpp index 8db80e72fafaf1..98de15e65af8ce 100644 --- a/ReactCommon/jsi/jsi/jsilib-windows.cpp +++ b/ReactCommon/jsi/jsi/jsilib-windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/jsilib.h b/ReactCommon/jsi/jsi/jsilib.h index d99b66dc94066c..c94de89f6a766a 100644 --- a/ReactCommon/jsi/jsi/jsilib.h +++ b/ReactCommon/jsi/jsi/jsilib.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,7 +15,7 @@ namespace jsi { class FileBuffer : public Buffer { public: FileBuffer(const std::string& path); - ~FileBuffer(); + ~FileBuffer() override; size_t size() const override { return size_; diff --git a/ReactCommon/jsi/jsi/test/testlib.cpp b/ReactCommon/jsi/jsi/test/testlib.cpp index e605b6acead953..395d48b9e8338e 100644 --- a/ReactCommon/jsi/jsi/test/testlib.cpp +++ b/ReactCommon/jsi/jsi/test/testlib.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -849,6 +849,8 @@ TEST_P(JSITest, ValueTest) { EXPECT_EQ(eval("'str'").getString(rt).utf8(rt), "str"); EXPECT_TRUE(eval("[]").getObject(rt).isArray(rt)); + EXPECT_TRUE(eval("true").asBool()); + EXPECT_THROW(eval("123").asBool(), JSIException); EXPECT_EQ(eval("456").asNumber(), 456); EXPECT_THROW(eval("'word'").asNumber(), JSIException); EXPECT_EQ( @@ -1423,7 +1425,7 @@ TEST_P(JSITest, MultilevelDecoratedHostObject) { EXPECT_EQ(1, RD2::numGets); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( Runtimes, JSITest, ::testing::ValuesIn(runtimeGenerators())); diff --git a/ReactCommon/jsi/jsi/test/testlib.h b/ReactCommon/jsi/jsi/test/testlib.h index 8d9392694005cd..9f30fb2d77de5e 100644 --- a/ReactCommon/jsi/jsi/test/testlib.h +++ b/ReactCommon/jsi/jsi/test/testlib.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsi/jsi/threadsafe.h b/ReactCommon/jsi/jsi/threadsafe.h index eddbce403d6088..cb10a335f6c3d7 100644 --- a/ReactCommon/jsi/jsi/threadsafe.h +++ b/ReactCommon/jsi/jsi/threadsafe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsiexecutor/Android.mk b/ReactCommon/jsiexecutor/Android.mk deleted file mode 100644 index e0661538e6664c..00000000000000 --- a/ReactCommon/jsiexecutor/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsireact - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jsireact/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 - -LOCAL_STATIC_LIBRARIES := reactnative reactperflogger -LOCAL_SHARED_LIBRARIES := libfolly_json glog libjsi - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/jsiexecutor/BUCK b/ReactCommon/jsiexecutor/BUCK index ab3a5f50d5a68c..24cbabd821fa1f 100644 --- a/ReactCommon/jsiexecutor/BUCK +++ b/ReactCommon/jsiexecutor/BUCK @@ -22,7 +22,10 @@ cxx_library( ], fbobjc_force_static = True, fbobjc_header_path_prefix = "", - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", diff --git a/ReactCommon/jsiexecutor/CMakeLists.txt b/ReactCommon/jsiexecutor/CMakeLists.txt new file mode 100644 index 00000000000000..68597560a0c69c --- /dev/null +++ b/ReactCommon/jsiexecutor/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -O3) + +add_library(jsireact + STATIC + jsireact/JSIExecutor.cpp + jsireact/JSINativeModules.cpp) + +target_include_directories(jsireact PUBLIC .) + +target_link_libraries(jsireact + reactnative + reactperflogger + folly_runtime + glog + jsi) diff --git a/ReactCommon/jsiexecutor/React-jsiexecutor.podspec b/ReactCommon/jsiexecutor/React-jsiexecutor.podspec index 1151d99ad2e38a..05cdcb3f16e582 100644 --- a/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +++ b/ReactCommon/jsiexecutor/React-jsiexecutor.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "jsireact/*.{cpp,h}" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags diff --git a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index f1d16bacb399ab..b6f3f26ad132f7 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h index 615172ed711c64..f06d0d32fd0928 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h +++ b/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp index 0bf27d402e9eec..2dadd43e287638 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp +++ b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h index a1dff88ec9f43e..c6aaacfa41cc50 100644 --- a/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h +++ b/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsinspector/Android.mk b/ReactCommon/jsinspector/Android.mk deleted file mode 100644 index 4ac55536236532..00000000000000 --- a/ReactCommon/jsinspector/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsinspector - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS += -fexceptions - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/jsinspector/BUCK b/ReactCommon/jsinspector/BUCK index 7fde000686f7aa..24e63a862a7067 100644 --- a/ReactCommon/jsinspector/BUCK +++ b/ReactCommon/jsinspector/BUCK @@ -1,6 +1,6 @@ load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob") load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "APPLE", "CXX", "FBCODE", "WINDOWS") -load("//tools/build_defs/oss:rn_defs.bzl", "rn_xplat_cxx_library") +load("//tools/build_defs/oss:rn_defs.bzl", "get_hermes_shared_library_preprocessor_flags", "rn_xplat_cxx_library") EXPORTED_HEADERS = [ "InspectorInterfaces.h", @@ -27,8 +27,12 @@ rn_xplat_cxx_library( prefix = "jsinspector", ), fbandroid_preferred_linkage = "shared", - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS), + preprocessor_flags = get_hermes_shared_library_preprocessor_flags(), visibility = [ "PUBLIC", ], diff --git a/ReactCommon/jsinspector/CMakeLists.txt b/ReactCommon/jsinspector/CMakeLists.txt new file mode 100644 index 00000000000000..511afcb9a43d52 --- /dev/null +++ b/ReactCommon/jsinspector/CMakeLists.txt @@ -0,0 +1,14 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions) + +file(GLOB jsinspector_SRC CONFIGURE_DEPENDS *.cpp) +add_library(jsinspector SHARED ${jsinspector_SRC}) + +target_include_directories(jsinspector PUBLIC ${REACT_COMMON_DIR}) diff --git a/ReactCommon/jsinspector/InspectorInterfaces.cpp b/ReactCommon/jsinspector/InspectorInterfaces.cpp index ed918c97db6566..fbd38e13e3df53 100644 --- a/ReactCommon/jsinspector/InspectorInterfaces.cpp +++ b/ReactCommon/jsinspector/InspectorInterfaces.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsinspector/InspectorInterfaces.h b/ReactCommon/jsinspector/InspectorInterfaces.h index 345434be2f676d..77fd6e1d546a10 100644 --- a/ReactCommon/jsinspector/InspectorInterfaces.h +++ b/ReactCommon/jsinspector/InspectorInterfaces.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/jsinspector/React-jsinspector.podspec b/ReactCommon/jsinspector/React-jsinspector.podspec index a29430de12e985..a1d6f7f2c3c60a 100644 --- a/ReactCommon/jsinspector/React-jsinspector.podspec +++ b/ReactCommon/jsinspector/React-jsinspector.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "*.{cpp,h}" s.header_dir = 'jsinspector' diff --git a/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK b/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK index 2a9f6a05bb329b..781884811ad82f 100644 --- a/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK +++ b/ReactCommon/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK @@ -4,6 +4,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "rn_android_library", "rn_prebuilt_ja rn_android_library( name = "powermock2", autoglob = False, + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":javassist-prebuilt", @@ -22,6 +23,7 @@ rn_android_library( rn_android_library( name = "powermock-reflect", autoglob = False, + language = "JAVA", visibility = ["PUBLIC"], exported_deps = [ ":byte-buddy", diff --git a/ReactCommon/logger/Android.mk b/ReactCommon/logger/Android.mk deleted file mode 100644 index 09a29bd3e15856..00000000000000 --- a/ReactCommon/logger/Android.mk +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := logger - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS += -fexceptions - -LOCAL_SHARED_LIBRARIES := glog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) diff --git a/ReactCommon/logger/BUCK b/ReactCommon/logger/BUCK index 59976e3cb06433..09b5f65e1a7309 100644 --- a/ReactCommon/logger/BUCK +++ b/ReactCommon/logger/BUCK @@ -27,7 +27,10 @@ rn_xplat_cxx_library( prefix = "logger", ), fbandroid_preferred_linkage = "shared", - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS), visibility = [ "PUBLIC", diff --git a/ReactCommon/logger/CMakeLists.txt b/ReactCommon/logger/CMakeLists.txt new file mode 100644 index 00000000000000..4746c147ac313f --- /dev/null +++ b/ReactCommon/logger/CMakeLists.txt @@ -0,0 +1,16 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions) + +file(GLOB logger_SRC CONFIGURE_DEPENDS *.cpp) +add_library(logger SHARED ${logger_SRC}) + +target_include_directories(logger PUBLIC .) + +target_link_libraries(logger glog) diff --git a/ReactCommon/logger/React-logger.podspec b/ReactCommon/logger/React-logger.podspec index 39ae857e5e366f..62b5148965a7b1 100644 --- a/ReactCommon/logger/React-logger.podspec +++ b/ReactCommon/logger/React-logger.podspec @@ -1,5 +1,5 @@ # coding: utf-8 -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -18,7 +18,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -28,7 +28,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.source = source s.source_files = "*.{cpp,h}" s.exclude_files = "SampleCxxModule.*" diff --git a/ReactCommon/logger/react_native_log.cpp b/ReactCommon/logger/react_native_log.cpp index 3b0310432c0767..ba89efcd1fd17f 100644 --- a/ReactCommon/logger/react_native_log.cpp +++ b/ReactCommon/logger/react_native_log.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/logger/react_native_log.h b/ReactCommon/logger/react_native_log.h index c64f2025559800..9ac23eeaacae31 100644 --- a/ReactCommon/logger/react_native_log.h +++ b/ReactCommon/logger/react_native_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/microprofiler/.clang-tidy b/ReactCommon/microprofiler/.clang-tidy deleted file mode 100644 index c98fd78ff64baa..00000000000000 --- a/ReactCommon/microprofiler/.clang-tidy +++ /dev/null @@ -1,5 +0,0 @@ ---- -Checks: '> -clang-diagnostic-*, -' -... diff --git a/ReactCommon/microprofiler/BUCK b/ReactCommon/microprofiler/BUCK deleted file mode 100644 index d01a92546fc4ac..00000000000000 --- a/ReactCommon/microprofiler/BUCK +++ /dev/null @@ -1,27 +0,0 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "GLOG_DEP", "cxx_library") - -cxx_library( - name = "microprofiler", - srcs = [ - "MicroProfiler.cpp", - ], - header_namespace = "microprofiler", - exported_headers = [ - "MicroProfiler.h", - ], - compiler_flags = [ - "-Wall", - "-Werror", - "-std=c++14", - "-fexceptions", - "-fno-data-sections", - ], - force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], - visibility = [ - "PUBLIC", - ], - deps = [ - GLOG_DEP, - ], -) diff --git a/ReactCommon/microprofiler/MicroProfiler.cpp b/ReactCommon/microprofiler/MicroProfiler.cpp deleted file mode 100644 index 15fd0164603936..00000000000000 --- a/ReactCommon/microprofiler/MicroProfiler.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "MicroProfiler.h" - -// iOS doesn't support 'thread_local'. If we reimplement this to use -// pthread_setspecific we can get rid of this -#if defined(__APPLE__) -#define MICRO_PROFILER_STUB_IMPLEMENTATION 1 -#elif !defined(MICRO_PROFILER_STUB_IMPLEMENTATION) -#define MICRO_PROFILER_STUB_IMPLEMENTATION 0 -#endif - -namespace facebook { -namespace react { - -#if !MICRO_PROFILER_STUB_IMPLEMENTATION -struct TraceData { - TraceData(); - ~TraceData(); - - void addTime( - MicroProfilerName name, - uint_fast64_t time, - uint_fast32_t internalClockCalls); - - std::thread::id threadId_; - uint_fast64_t startTime_; - std::atomic_uint_fast64_t times_[MicroProfilerName::__LENGTH__] = {}; - std::atomic_uint_fast32_t calls_[MicroProfilerName::__LENGTH__] = {}; - std::atomic_uint_fast32_t - childProfileSections_[MicroProfilerName::__LENGTH__] = {}; -}; - -struct ProfilingImpl { - std::mutex mutex_; - std::vector allTraceData_; - bool isProfiling_ = false; - uint_fast64_t startTime_; - uint_fast64_t endTime_; - uint_fast64_t clockOverhead_; - uint_fast64_t profileSectionOverhead_; -}; - -static ProfilingImpl profiling; -thread_local TraceData myTraceData; -thread_local uint_fast32_t profileSections = 0; - -static uint_fast64_t nowNs() { - struct timespec time; - clock_gettime(CLOCK_REALTIME, &time); - return uint_fast64_t(1000000000) * time.tv_sec + time.tv_nsec; -} - -static uint_fast64_t diffNs(uint_fast64_t start, uint_fast64_t end) { - return end - start; -} - -static std::string formatTimeNs(uint_fast64_t timeNs) { - std::ostringstream out; - out.precision(2); - if (timeNs < 1000) { - out << timeNs << "ns"; - } else if (timeNs < 1000000) { - out << timeNs / 1000.0 << "us"; - } else { - out << std::fixed << timeNs / 1000000.0 << "ms"; - } - return out.str(); -} - -MicroProfilerSection::MicroProfilerSection(MicroProfilerName name) - : isProfiling_(profiling.isProfiling_), - name_(name), - startNumProfileSections_(profileSections) { - if (!isProfiling_) { - return; - } - profileSections++; - startTime_ = nowNs(); -} -MicroProfilerSection::~MicroProfilerSection() { - if (!isProfiling_ || !profiling.isProfiling_) { - return; - } - auto endTime = nowNs(); - auto endNumProfileSections = profileSections; - myTraceData.addTime( - name_, - endTime - startTime_, - endNumProfileSections - startNumProfileSections_ - 1); -} - -TraceData::TraceData() : threadId_(std::this_thread::get_id()) { - std::lock_guard lock(profiling.mutex_); - profiling.allTraceData_.push_back(this); -} - -TraceData::~TraceData() { - std::lock_guard lock(profiling.mutex_); - auto &infos = profiling.allTraceData_; - infos.erase(std::remove(infos.begin(), infos.end(), this), infos.end()); -} - -void TraceData::addTime( - MicroProfilerName name, - uint_fast64_t time, - uint_fast32_t childprofileSections) { - times_[name] += time; - calls_[name]++; - childProfileSections_[name] += childprofileSections; -} - -static void printReport() { - LOG(ERROR) << "======= MICRO PROFILER REPORT ======="; - LOG(ERROR) << "- Total Time: " - << formatTimeNs(diffNs(profiling.startTime_, profiling.endTime_)); - LOG(ERROR) << "- Clock Overhead: " << formatTimeNs(profiling.clockOverhead_); - LOG(ERROR) << "- Profiler Section Overhead: " - << formatTimeNs(profiling.profileSectionOverhead_); - for (auto info : profiling.allTraceData_) { - LOG(ERROR) << "--- Thread ID 0x" << std::hex << info->threadId_ << " ---"; - for (int i = 0; i < MicroProfilerName::__LENGTH__; i++) { - if (info->times_[i] > 0) { - auto totalTime = info->times_[i].load(); - auto calls = info->calls_[i].load(); - auto clockOverhead = profiling.clockOverhead_ * calls + - profiling.profileSectionOverhead_ * - info->childProfileSections_[i].load(); - if (totalTime < clockOverhead) { - LOG(ERROR) << "- " - << MicroProfiler::profilingNameToString( - static_cast(i)) - << ": " - << "ERROR: Total time was " << totalTime - << "ns but clock overhead was calculated to be " - << clockOverhead << "ns!"; - } else { - auto correctedTime = totalTime - clockOverhead; - auto timePerCall = correctedTime / calls; - LOG(ERROR) << "- " - << MicroProfiler::profilingNameToString( - static_cast(i)) - << ": " << formatTimeNs(correctedTime) << " (" << calls - << " calls, " << formatTimeNs(timePerCall) << "/call)"; - } - } - } - } -} - -static void clearProfiling() { - CHECK(!profiling.isProfiling_) - << "Trying to clear profiling but profiling was already started!"; - for (auto info : profiling.allTraceData_) { - for (unsigned int i = 0; i < MicroProfilerName::__LENGTH__; i++) { - info->times_[i] = 0; - info->calls_[i] = 0; - info->childProfileSections_[i] = 0; - } - } -} - -static uint_fast64_t calculateClockOverhead() { - int numCalls = 1000000; - uint_fast64_t start = nowNs(); - for (int i = 0; i < numCalls; i++) { - nowNs(); - } - uint_fast64_t end = nowNs(); - return (end - start) / numCalls; -} - -static uint_fast64_t calculateProfileSectionOverhead() { - int numCalls = 1000000; - uint_fast64_t start = nowNs(); - profiling.isProfiling_ = true; - for (int i = 0; i < numCalls; i++) { - MICRO_PROFILER_SECTION(static_cast(0)); - } - uint_fast64_t end = nowNs(); - profiling.isProfiling_ = false; - return (end - start) / numCalls; -} - -void MicroProfiler::startProfiling() { - CHECK(!profiling.isProfiling_) - << "Trying to start profiling but profiling was already started!"; - - profiling.clockOverhead_ = calculateClockOverhead(); - profiling.profileSectionOverhead_ = calculateProfileSectionOverhead(); - - std::lock_guard lock(profiling.mutex_); - clearProfiling(); - - profiling.startTime_ = nowNs(); - profiling.isProfiling_ = true; -} - -void MicroProfiler::stopProfiling() { - CHECK(profiling.isProfiling_) - << "Trying to stop profiling but profiling hasn't been started!"; - - profiling.isProfiling_ = false; - profiling.endTime_ = nowNs(); - - std::lock_guard lock(profiling.mutex_); - - printReport(); - - clearProfiling(); -} - -bool MicroProfiler::isProfiling() { - return profiling.isProfiling_; -} - -void MicroProfiler::runInternalBenchmark() { - MicroProfiler::startProfiling(); - for (int i = 0; i < 1000000; i++) { - MICRO_PROFILER_SECTION_NAMED(outer, __INTERNAL_BENCHMARK_OUTER); - { MICRO_PROFILER_SECTION_NAMED(inner, __INTERNAL_BENCHMARK_INNER); } - } - MicroProfiler::stopProfiling(); -} -#else -void MicroProfiler::startProfiling() { - CHECK(false) - << "This platform has a stub implementation of the micro profiler and cannot collect traces"; -} -void MicroProfiler::stopProfiling() {} -bool MicroProfiler::isProfiling() { - return false; -} -void MicroProfiler::runInternalBenchmark() {} -#endif - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/microprofiler/MicroProfiler.h b/ReactCommon/microprofiler/MicroProfiler.h deleted file mode 100644 index 3c6861173a7275..00000000000000 --- a/ReactCommon/microprofiler/MicroProfiler.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -// #define WITH_MICRO_PROFILER 1 - -#ifdef WITH_MICRO_PROFILER -#define MICRO_PROFILER_SECTION(name) MicroProfilerSection __b(name) -#define MICRO_PROFILER_SECTION_NAMED(var_name, name) \ - MicroProfilerSection var_name(name) -#else -#define MICRO_PROFILER_SECTION(name) -#define MICRO_PROFILER_SECTION_NAMED(var_name, name) -#endif - -namespace facebook { -namespace react { - -enum MicroProfilerName { - __INTERNAL_BENCHMARK_INNER, - __INTERNAL_BENCHMARK_OUTER, - __LENGTH__, -}; - -/** - * MicroProfiler is a performance profiler for measuring the cumulative impact - * of a large number of small-ish calls. This is normally a problem for standard - * profilers like Systrace because the overhead of the profiler itself skews the - * timings you are able to collect. This is especially a problem when doing - * nested calls to profiled functions, as the parent calls will contain the - * overhead of their profiling plus the overhead of all their childrens' - * profiling. - * - * MicroProfiler attempts to be low overhead by 1) aggregating timings in memory - * and 2) trying to remove estimated profiling overhead from the returned - * timings. - * - * To remove estimated overhead, at the beginning of each trace we calculate the - * average cost of profiling a no-op code section, as well as invoking the - * average cost of invoking the system clock. The former is subtracted out for - * each child profiler section that is invoked within a parent profiler section. - * The latter is subtracted from each section, child or not. - * - * After MicroProfiler::stopProfiling() is called, a table of tracing data is - * emitted to glog (which shows up in logcat on Android). - */ -struct MicroProfiler { - static const char *profilingNameToString(MicroProfilerName name) { - switch (name) { - case __INTERNAL_BENCHMARK_INNER: - return "__INTERNAL_BENCHMARK_INNER"; - case __INTERNAL_BENCHMARK_OUTER: - return "__INTERNAL_BENCHMARK_OUTER"; - case __LENGTH__: - throw std::runtime_error("__LENGTH__ has no name"); - default: - throw std::runtime_error( - "Trying to convert unknown MicroProfilerName to string"); - } - } - - static void startProfiling(); - static void stopProfiling(); - static bool isProfiling(); - static void runInternalBenchmark(); -}; - -class MicroProfilerSection { - public: - MicroProfilerSection(MicroProfilerName name); - ~MicroProfilerSection(); - - private: - bool isProfiling_; - MicroProfilerName name_; - uint_fast64_t startTime_; - uint_fast32_t startNumProfileSections_; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/bridging/AString.h b/ReactCommon/react/bridging/AString.h new file mode 100644 index 00000000000000..cad91246ae4673 --- /dev/null +++ b/ReactCommon/react/bridging/AString.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include + +namespace facebook::react { + +template <> +struct Bridging { + static std::string fromJs(jsi::Runtime &rt, const jsi::String &value) { + return value.utf8(rt); + } + + static jsi::String toJs(jsi::Runtime &rt, const std::string &value) { + return jsi::String::createFromUtf8(rt, value); + } +}; + +template <> +struct Bridging { + static jsi::String toJs(jsi::Runtime &rt, std::string_view value) { + return jsi::String::createFromUtf8( + rt, reinterpret_cast(value.data()), value.length()); + } +}; + +template <> +struct Bridging : Bridging {}; + +template +struct Bridging : Bridging {}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Array.h b/ReactCommon/react/bridging/Array.h new file mode 100644 index 00000000000000..330e2e1a4f8b6f --- /dev/null +++ b/ReactCommon/react/bridging/Array.h @@ -0,0 +1,108 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace facebook::react { + +namespace array_detail { + +template +struct BridgingStatic { + static jsi::Array toJs( + jsi::Runtime &rt, + const T &array, + const std::shared_ptr &jsInvoker) { + return toJs(rt, array, jsInvoker, std::make_index_sequence{}); + } + + private: + template + static jsi::Array toJs( + facebook::jsi::Runtime &rt, + const T &array, + const std::shared_ptr &jsInvoker, + std::index_sequence) { + return jsi::Array::createWithElements( + rt, bridging::toJs(rt, std::get(array), jsInvoker)...); + } +}; + +template +struct BridgingDynamic { + static jsi::Array toJs( + jsi::Runtime &rt, + const T &list, + const std::shared_ptr &jsInvoker) { + jsi::Array result(rt, list.size()); + size_t index = 0; + + for (const auto &item : list) { + result.setValueAtIndex(rt, index++, bridging::toJs(rt, item, jsInvoker)); + } + + return result; + } +}; + +} // namespace array_detail + +template +struct Bridging> + : array_detail::BridgingStatic, N> {}; + +template +struct Bridging> + : array_detail::BridgingStatic, 2> {}; + +template +struct Bridging> + : array_detail::BridgingStatic, sizeof...(Types)> {}; + +template +struct Bridging> : array_detail::BridgingDynamic> { +}; + +template +struct Bridging> + : array_detail::BridgingDynamic> {}; + +template +struct Bridging> : array_detail::BridgingDynamic> {}; + +template +struct Bridging> + : array_detail::BridgingDynamic> { + static std::vector fromJs( + facebook::jsi::Runtime &rt, + const jsi::Array &array, + const std::shared_ptr &jsInvoker) { + size_t length = array.length(rt); + + std::vector vector; + vector.reserve(length); + + for (size_t i = 0; i < length; i++) { + vector.push_back( + bridging::fromJs(rt, array.getValueAtIndex(rt, i), jsInvoker)); + } + + return vector; + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/BUCK b/ReactCommon/react/bridging/BUCK new file mode 100644 index 00000000000000..72e1dac38a84c3 --- /dev/null +++ b/ReactCommon/react/bridging/BUCK @@ -0,0 +1,57 @@ +load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "IOS", "MACOSX", "fb_xplat_cxx_test", "react_native_xplat_shared_library_target", "react_native_xplat_target", "rn_xplat_cxx_library") + +rn_xplat_cxx_library( + name = "bridging", + srcs = glob(["*.cpp"]), + header_namespace = "react/bridging", + exported_headers = glob(["*.h"]), + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], + platforms = (ANDROID, APPLE, CXX), + tests = [":tests"], + visibility = ["PUBLIC"], + deps = [ + "//xplat/folly:headers_only_do_not_use", + ], + exported_deps = [ + react_native_xplat_target("butter:butter"), + react_native_xplat_target("callinvoker:callinvoker"), + react_native_xplat_shared_library_target("jsi:jsi"), + ], +) + +rn_xplat_cxx_library( + name = "testlib", + header_namespace = "react/bridging", + exported_headers = glob(["tests/*.h"]), + platforms = (ANDROID, APPLE, CXX), + visibility = ["PUBLIC"], + exported_deps = [ + ":bridging", + "//xplat/third-party/gmock:gtest", + ], +) + +fb_xplat_cxx_test( + name = "tests", + srcs = glob(["tests/*.cpp"]), + headers = glob(["tests/*.h"]), + apple_sdks = (IOS, MACOSX), + compiler_flags = [ + "-fexceptions", + "-frtti", + "-std=c++17", + "-Wall", + ], + contacts = ["oncall+react_native@xmail.facebook.com"], + platforms = (ANDROID, APPLE, CXX), + deps = [ + ":bridging", + "//xplat/hermes/API:HermesAPI", + "//xplat/third-party/gmock:gtest", + ], +) diff --git a/ReactCommon/react/bridging/Base.h b/ReactCommon/react/bridging/Base.h new file mode 100644 index 00000000000000..56006f35bf2554 --- /dev/null +++ b/ReactCommon/react/bridging/Base.h @@ -0,0 +1,154 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include +#include + +#include +#include +#include + +namespace facebook::react { + +template +struct Bridging; + +template <> +struct Bridging { + // Highly generic code may result in "casting" to void. + static void fromJs(jsi::Runtime &, const jsi::Value &) {} +}; + +namespace bridging { +namespace detail { + +template +struct function_wrapper; + +template +struct function_wrapper { + using type = folly::Function; +}; + +template +struct function_wrapper { + using type = folly::Function; +}; + +template +struct bridging_wrapper { + using type = remove_cvref_t; +}; + +// Convert lambda types to move-only function types since we can't specialize +// Bridging templates for arbitrary lambdas. +template +struct bridging_wrapper< + T, + std::void_t::operator())>> + : function_wrapper::operator())> {}; + +} // namespace detail + +template +using bridging_t = typename detail::bridging_wrapper::type; + +template , int> = 0> +auto fromJs(jsi::Runtime &rt, T &&value, const std::shared_ptr &) + -> decltype(static_cast(convert(rt, std::forward(value)))) { + return convert(rt, std::forward(value)); +} + +template +auto fromJs(jsi::Runtime &rt, T &&value, const std::shared_ptr &) + -> decltype(Bridging>::fromJs( + rt, + convert(rt, std::forward(value)))) { + return Bridging>::fromJs( + rt, convert(rt, std::forward(value))); +} + +template +auto fromJs( + jsi::Runtime &rt, + T &&value, + const std::shared_ptr &jsInvoker) + -> decltype(Bridging>::fromJs( + rt, + convert(rt, std::forward(value)), + jsInvoker)) { + return Bridging>::fromJs( + rt, convert(rt, std::forward(value)), jsInvoker); +} + +template , int> = 0> +auto toJs( + jsi::Runtime &rt, + T &&value, + const std::shared_ptr & = nullptr) + -> decltype(convert(rt, std::forward(value))) { + return convert(rt, std::forward(value)); +} + +template +auto toJs( + jsi::Runtime &rt, + T &&value, + const std::shared_ptr & = nullptr) + -> decltype(Bridging>::toJs(rt, std::forward(value))) { + return Bridging>::toJs(rt, std::forward(value)); +} + +template +auto toJs( + jsi::Runtime &rt, + T &&value, + const std::shared_ptr &jsInvoker) + -> decltype(Bridging>::toJs( + rt, + std::forward(value), + jsInvoker)) { + return Bridging>::toJs(rt, std::forward(value), jsInvoker); +} + +template +inline constexpr bool supportsFromJs = false; + +template +inline constexpr bool supportsFromJs< + T, + Arg, + std::void_t( + std::declval(), + std::declval(), + nullptr))>> = true; + +template +inline constexpr bool supportsToJs = false; + +template +inline constexpr bool supportsToJs< + T, + Ret, + std::void_t(), + std::declval(), + nullptr))>> = + std::is_convertible_v< + decltype(toJs( + std::declval(), + std::declval(), + nullptr)), + Ret>; + +} // namespace bridging +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Bool.h b/ReactCommon/react/bridging/Bool.h new file mode 100644 index 00000000000000..b720e120aeeb7b --- /dev/null +++ b/ReactCommon/react/bridging/Bool.h @@ -0,0 +1,25 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace facebook::react { + +template <> +struct Bridging { + static bool fromJs(jsi::Runtime &rt, const jsi::Value &value) { + return value.asBool(); + } + + static jsi::Value toJs(jsi::Runtime &, bool value) { + return value; + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Bridging.h b/ReactCommon/react/bridging/Bridging.h new file mode 100644 index 00000000000000..26cf99b5208302 --- /dev/null +++ b/ReactCommon/react/bridging/Bridging.h @@ -0,0 +1,19 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/ReactCommon/react/bridging/CMakeLists.txt b/ReactCommon/react/bridging/CMakeLists.txt new file mode 100644 index 00000000000000..88d3aba2fae641 --- /dev/null +++ b/ReactCommon/react/bridging/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"ReactNative\") + +file(GLOB react_bridging_SRC CONFIGURE_DEPENDS *.cpp) + +add_library(react_bridging STATIC ${react_bridging_SRC}) + +target_include_directories(react_bridging PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_bridging jsi) diff --git a/ReactCommon/react/bridging/CallbackWrapper.h b/ReactCommon/react/bridging/CallbackWrapper.h new file mode 100644 index 00000000000000..fc2980cb925385 --- /dev/null +++ b/ReactCommon/react/bridging/CallbackWrapper.h @@ -0,0 +1,103 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +#include + +namespace facebook { +namespace react { + +// Helper for passing jsi::Function arg to other methods. +class CallbackWrapper : public LongLivedObject { + private: + CallbackWrapper( + jsi::Function &&callback, + jsi::Runtime &runtime, + std::shared_ptr jsInvoker) + : longLivedObjectCollection_(), + callback_(std::move(callback)), + runtime_(runtime), + jsInvoker_(std::move(jsInvoker)) {} + + CallbackWrapper( + std::shared_ptr longLivedObjectCollection, + jsi::Function &&callback, + jsi::Runtime &runtime, + std::shared_ptr jsInvoker) + : longLivedObjectCollection_(longLivedObjectCollection), + callback_(std::move(callback)), + runtime_(runtime), + jsInvoker_(std::move(jsInvoker)) {} + + // Use a weak_ptr to avoid a retain cycle: LongLivedObjectCollection owns all + // CallbackWrappers. So, CallbackWrapper cannot own its + // LongLivedObjectCollection. + std::weak_ptr longLivedObjectCollection_; + jsi::Function callback_; + jsi::Runtime &runtime_; + std::shared_ptr jsInvoker_; + + public: + static std::weak_ptr createWeak( + jsi::Function &&callback, + jsi::Runtime &runtime, + std::shared_ptr jsInvoker) { + auto wrapper = std::shared_ptr( + new CallbackWrapper(std::move(callback), runtime, jsInvoker)); + LongLivedObjectCollection::get().add(wrapper); + return wrapper; + } + + static std::weak_ptr createWeak( + std::shared_ptr longLivedObjectCollection, + jsi::Function &&callback, + jsi::Runtime &runtime, + std::shared_ptr jsInvoker) { + auto wrapper = std::shared_ptr(new CallbackWrapper( + longLivedObjectCollection, std::move(callback), runtime, jsInvoker)); + longLivedObjectCollection->add(wrapper); + return wrapper; + } + + // Delete the enclosed jsi::Function + void destroy() { + allowRelease(); + } + + jsi::Function &callback() { + return callback_; + } + + jsi::Runtime &runtime() { + return runtime_; + } + + CallInvoker &jsInvoker() { + return *(jsInvoker_); + } + + std::shared_ptr jsInvokerPtr() { + return jsInvoker_; + } + + void allowRelease() override { + if (auto longLivedObjectCollection = longLivedObjectCollection_.lock()) { + if (longLivedObjectCollection != nullptr) { + longLivedObjectCollection->remove(this); + return; + } + } + LongLivedObject::allowRelease(); + } +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/bridging/Class.h b/ReactCommon/react/bridging/Class.h new file mode 100644 index 00000000000000..d0cc976f543340 --- /dev/null +++ b/ReactCommon/react/bridging/Class.h @@ -0,0 +1,92 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace facebook::react::bridging { + +template < + typename T, + typename C, + typename R, + typename... Args, + typename... JSArgs> +T callFromJs( + jsi::Runtime &rt, + R (C::*method)(jsi::Runtime &, Args...), + const std::shared_ptr &jsInvoker, + C *instance, + JSArgs &&...args) { + static_assert( + sizeof...(Args) == sizeof...(JSArgs), "Incorrect arguments length"); + static_assert( + (supportsFromJs && ...), "Incompatible arguments"); + + if constexpr (std::is_void_v) { + (instance->*method)( + rt, fromJs(rt, std::forward(args), jsInvoker)...); + + } else if constexpr (std::is_void_v) { + static_assert( + std::is_same_v, + "Void functions may only return undefined"); + + (instance->*method)( + rt, fromJs(rt, std::forward(args), jsInvoker)...); + return jsi::Value(); + + } else if constexpr (is_jsi_v) { + static_assert(supportsToJs, "Incompatible return type"); + + return toJs( + rt, + (instance->*method)( + rt, fromJs(rt, std::forward(args), jsInvoker)...), + jsInvoker); + + } else if constexpr (is_optional_v) { + static_assert( + is_optional_v + ? supportsToJs + : supportsToJs, + "Incompatible return type"); + + auto result = toJs( + rt, + (instance->*method)( + rt, fromJs(rt, std::forward(args), jsInvoker)...), + jsInvoker); + + if constexpr (std::is_same_v) { + if (result.isNull() || result.isUndefined()) { + return std::nullopt; + } + } + + return convert(rt, std::move(result)); + + } else { + static_assert(std::is_convertible_v, "Incompatible return type"); + + return (instance->*method)( + rt, fromJs(rt, std::forward(args), jsInvoker)...); + } +} + +template +constexpr size_t getParameterCount(R (*)(Args...)) { + return sizeof...(Args); +} + +template +constexpr size_t getParameterCount(R (C::*)(Args...)) { + return sizeof...(Args); +} + +} // namespace facebook::react::bridging diff --git a/ReactCommon/react/bridging/Convert.h b/ReactCommon/react/bridging/Convert.h new file mode 100644 index 00000000000000..d2e0f8ed223e95 --- /dev/null +++ b/ReactCommon/react/bridging/Convert.h @@ -0,0 +1,162 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include + +namespace facebook::react::bridging { + +// std::remove_cvref_t is not available until C++20. +template +using remove_cvref_t = std::remove_cv_t>; + +template +inline constexpr bool is_jsi_v = + std::is_same_v> || + std::is_same_v> || + std::is_base_of_v>; + +template +struct is_optional : std::false_type {}; + +template +struct is_optional> : std::true_type {}; + +template +inline constexpr bool is_optional_v = is_optional::value; + +template +struct Converter; + +template +struct ConverterBase { + using BaseT = remove_cvref_t; + + ConverterBase(jsi::Runtime &rt, T &&value) + : rt_(rt), value_(std::forward(value)) {} + + operator BaseT() && { + if constexpr (std::is_lvalue_reference_v) { + // Copy the reference into a Value that then can be moved from. + auto value = jsi::Value(rt_, value_); + + if constexpr (std::is_same_v) { + return std::move(value); + } else if constexpr (std::is_same_v) { + return std::move(value).getString(rt_); + } else if constexpr (std::is_same_v) { + return std::move(value).getObject(rt_); + } else if constexpr (std::is_same_v) { + return std::move(value).getObject(rt_).getArray(rt_); + } else if constexpr (std::is_same_v) { + return std::move(value).getObject(rt_).getFunction(rt_); + } + } else { + return std::move(value_); + } + } + + template < + typename U, + std::enable_if_t< + std::is_lvalue_reference_v && + // Ensure non-reference type can be converted to the desired type. + std::is_convertible_v, U>, + int> = 0> + operator U() && { + return Converter(rt_, std::move(*this).operator BaseT()); + } + + template < + typename U, + std::enable_if_t && std::is_same_v, int> = 0> + operator U() && = delete; // Prevent unwanted upcasting of JSI values. + + protected: + jsi::Runtime &rt_; + T value_; +}; + +template +struct Converter : public ConverterBase { + using ConverterBase::ConverterBase; +}; + +template <> +struct Converter : public ConverterBase { + using ConverterBase::ConverterBase; + + operator jsi::String() && { + return std::move(value_).asString(rt_); + } + + operator jsi::Object() && { + return std::move(value_).asObject(rt_); + } + + operator jsi::Array() && { + return std::move(value_).asObject(rt_).asArray(rt_); + } + + operator jsi::Function() && { + return std::move(value_).asObject(rt_).asFunction(rt_); + } +}; + +template <> +struct Converter : public ConverterBase { + using ConverterBase::ConverterBase; + + operator jsi::Array() && { + return std::move(value_).asArray(rt_); + } + + operator jsi::Function() && { + return std::move(value_).asFunction(rt_); + } +}; + +template +struct Converter> : public ConverterBase { + Converter(jsi::Runtime &rt, std::optional value) + : ConverterBase(rt, value ? std::move(*value) : jsi::Value::null()) {} + + operator std::optional() && { + if (value_.isNull() || value_.isUndefined()) { + return {}; + } + return std::move(value_); + } +}; + +template , int> = 0> +auto convert(jsi::Runtime &rt, T &&value) { + return Converter(rt, std::forward(value)); +} + +template < + typename T, + std::enable_if_t || std::is_scalar_v, int> = 0> +auto convert(jsi::Runtime &rt, std::optional value) { + return Converter>(rt, std::move(value)); +} + +template , int> = 0> +auto convert(jsi::Runtime &rt, T &&value) { + return value; +} + +template +auto convert(jsi::Runtime &rt, Converter &&converter) { + return std::move(converter); +} + +} // namespace facebook::react::bridging diff --git a/ReactCommon/react/bridging/Error.h b/ReactCommon/react/bridging/Error.h new file mode 100644 index 00000000000000..eed77305d70fd8 --- /dev/null +++ b/ReactCommon/react/bridging/Error.h @@ -0,0 +1,51 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace facebook::react { + +class Error { + public: + // TODO (T114055466): Retain stack trace (at least caller location) + Error(std::string message) : message_(std::move(message)) {} + + Error(const char *message) : Error(std::string(message)) {} + + const std::string &message() const { + return message_; + } + + private: + std::string message_; +}; + +template <> +struct Bridging { + static jsi::JSError fromJs(jsi::Runtime &rt, const jsi::Value &value) { + return jsi::JSError(rt, jsi::Value(rt, value)); + } + + static jsi::JSError fromJs(jsi::Runtime &rt, jsi::Value &&value) { + return jsi::JSError(rt, std::move(value)); + } + + static jsi::Value toJs(jsi::Runtime &rt, std::string message) { + return jsi::Value(rt, jsi::JSError(rt, std::move(message)).value()); + } +}; + +template <> +struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, const Error &error) { + return jsi::Value(rt, jsi::JSError(rt, error.message()).value()); + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Function.h b/ReactCommon/react/bridging/Function.h new file mode 100644 index 00000000000000..fdac94bb6fd3b1 --- /dev/null +++ b/ReactCommon/react/bridging/Function.h @@ -0,0 +1,214 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +#include + +namespace facebook::react { + +template +class SyncCallback; + +template +class AsyncCallback { + public: + AsyncCallback( + jsi::Runtime &runtime, + jsi::Function function, + std::shared_ptr jsInvoker) + : callback_(std::make_shared>( + runtime, + std::move(function), + std::move(jsInvoker))) {} + + AsyncCallback(const AsyncCallback &) = default; + AsyncCallback &operator=(const AsyncCallback &) = default; + + void operator()(Args... args) const { + call(std::forward(args)...); + } + + void call(Args... args) const { + auto wrapper = callback_->wrapper_.lock(); + if (!wrapper) { + throw std::runtime_error("Failed to call invalidated async callback"); + } + + auto argsTuple = std::make_tuple(std::forward(args)...); + + wrapper->jsInvoker().invokeAsync( + [callback = callback_, + argsPtr = std::make_shared( + std::move(argsTuple))] { callback->apply(std::move(*argsPtr)); }); + } + + private: + friend Bridging; + + std::shared_ptr> callback_; +}; + +template +class SyncCallback { + public: + SyncCallback( + jsi::Runtime &rt, + jsi::Function function, + std::shared_ptr jsInvoker) + : wrapper_(CallbackWrapper::createWeak( + std::move(function), + rt, + std::move(jsInvoker))) {} + + // Disallow moving to prevent function from get called on another thread. + SyncCallback(SyncCallback &&) = delete; + SyncCallback &operator=(SyncCallback &&) = delete; + + ~SyncCallback() { + if (auto wrapper = wrapper_.lock()) { + wrapper->destroy(); + } + } + + R operator()(Args... args) const { + return call(std::forward(args)...); + } + + R call(Args... args) const { + auto wrapper = wrapper_.lock(); + if (!wrapper) { + throw std::runtime_error("Failed to call invalidated sync callback"); + } + + auto &callback = wrapper->callback(); + auto &rt = wrapper->runtime(); + auto jsInvoker = wrapper->jsInvokerPtr(); + + if constexpr (std::is_void_v) { + callback.call( + rt, bridging::toJs(rt, std::forward(args), jsInvoker)...); + } else { + return bridging::fromJs( + rt, + callback.call( + rt, bridging::toJs(rt, std::forward(args), jsInvoker)...), + jsInvoker); + } + } + + private: + friend AsyncCallback; + friend Bridging; + + R apply(std::tuple &&args) const { + return apply(std::move(args), std::index_sequence_for{}); + } + + template + R apply(std::tuple &&args, std::index_sequence) const { + return call(std::move(std::get(args))...); + } + + // Held weakly so lifetime is managed by LongLivedObjectCollection. + std::weak_ptr wrapper_; +}; + +template +struct Bridging> { + static AsyncCallback fromJs( + jsi::Runtime &rt, + jsi::Function &&value, + const std::shared_ptr &jsInvoker) { + return AsyncCallback(rt, std::move(value), jsInvoker); + } + + static jsi::Function toJs( + jsi::Runtime &rt, + const AsyncCallback &value) { + return value.callback_->function_.getFunction(rt); + } +}; + +template +struct Bridging> { + static SyncCallback fromJs( + jsi::Runtime &rt, + jsi::Function &&value, + const std::shared_ptr &jsInvoker) { + return SyncCallback(rt, std::move(value), jsInvoker); + } + + static jsi::Function toJs( + jsi::Runtime &rt, + const SyncCallback &value) { + return value.function_.getFunction(rt); + } +}; + +template +struct Bridging> { + using Func = folly::Function; + using IndexSequence = std::index_sequence_for; + + static constexpr size_t kArgumentCount = sizeof...(Args); + + static jsi::Function toJs( + jsi::Runtime &rt, + Func fn, + const std::shared_ptr &jsInvoker) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "BridgedFunction"), + kArgumentCount, + [fn = std::make_shared(std::move(fn)), jsInvoker]( + jsi::Runtime &rt, + const jsi::Value &, + const jsi::Value *args, + size_t count) -> jsi::Value { + if (count < kArgumentCount) { + throw jsi::JSError(rt, "Incorrect number of arguments"); + } + + if constexpr (std::is_void_v) { + callFromJs(*fn, rt, args, jsInvoker, IndexSequence{}); + return jsi::Value(); + } else { + return bridging::toJs( + rt, + callFromJs(*fn, rt, args, jsInvoker, IndexSequence{}), + jsInvoker); + } + }); + } + + private: + template + static R callFromJs( + Func &fn, + jsi::Runtime &rt, + const jsi::Value *args, + const std::shared_ptr &jsInvoker, + std::index_sequence) { + return fn(bridging::fromJs(rt, args[Index], jsInvoker)...); + } +}; + +template +struct Bridging> + : Bridging> {}; + +template +struct Bridging : Bridging> {}; + +template +struct Bridging : Bridging> {}; + +} // namespace facebook::react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp b/ReactCommon/react/bridging/LongLivedObject.cpp similarity index 86% rename from ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp rename to ReactCommon/react/bridging/LongLivedObject.cpp index 40908d3c07ecb2..dc6d44dbe61eda 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp +++ b/ReactCommon/react/bridging/LongLivedObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -41,6 +41,11 @@ void LongLivedObjectCollection::clear() const { collection_.clear(); } +size_t LongLivedObjectCollection::size() const { + std::lock_guard lock(collectionMutex_); + return collection_.size(); +} + // LongLivedObject LongLivedObject::LongLivedObject() {} LongLivedObject::~LongLivedObject() {} diff --git a/ReactCommon/react/bridging/LongLivedObject.h b/ReactCommon/react/bridging/LongLivedObject.h new file mode 100644 index 00000000000000..cfb10086d09f60 --- /dev/null +++ b/ReactCommon/react/bridging/LongLivedObject.h @@ -0,0 +1,58 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +/** + * A simple wrapper class that can be registered to a collection that keep it + * alive for extended period of time. This object can be removed from the + * collection when needed. + * + * The subclass of this class must be created using std::make_shared(). + * After creation, add it to the `LongLivedObjectCollection`. + * When done with the object, call `allowRelease()` to allow the OS to release + * it. + */ +class LongLivedObject { + public: + virtual void allowRelease(); + + protected: + LongLivedObject(); + virtual ~LongLivedObject(); +}; + +/** + * A singleton, thread-safe, write-only collection for the `LongLivedObject`s. + */ +class LongLivedObjectCollection { + public: + static LongLivedObjectCollection &get(); + + LongLivedObjectCollection(); + LongLivedObjectCollection(LongLivedObjectCollection const &) = delete; + void operator=(LongLivedObjectCollection const &) = delete; + + void add(std::shared_ptr o) const; + void remove(const LongLivedObject *o) const; + void clear() const; + size_t size() const; + + private: + mutable std::unordered_set> collection_; + mutable std::mutex collectionMutex_; +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/bridging/Number.h b/ReactCommon/react/bridging/Number.h new file mode 100644 index 00000000000000..4857b9eec24e17 --- /dev/null +++ b/ReactCommon/react/bridging/Number.h @@ -0,0 +1,47 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace facebook::react { + +template <> +struct Bridging { + static double fromJs(jsi::Runtime &, const jsi::Value &value) { + return value.asNumber(); + } + + static jsi::Value toJs(jsi::Runtime &, double value) { + return value; + } +}; + +template <> +struct Bridging { + static float fromJs(jsi::Runtime &, const jsi::Value &value) { + return (float)value.asNumber(); + } + + static jsi::Value toJs(jsi::Runtime &, float value) { + return (double)value; + } +}; + +template <> +struct Bridging { + static int32_t fromJs(jsi::Runtime &, const jsi::Value &value) { + return (int32_t)value.asNumber(); + } + + static jsi::Value toJs(jsi::Runtime &, int32_t value) { + return value; + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Object.h b/ReactCommon/react/bridging/Object.h new file mode 100644 index 00000000000000..aefc375470fa2d --- /dev/null +++ b/ReactCommon/react/bridging/Object.h @@ -0,0 +1,100 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +#include +#include +#include + +namespace facebook::react { + +template <> +struct Bridging { + static jsi::WeakObject fromJs(jsi::Runtime &rt, const jsi::Object &value) { + return jsi::WeakObject(rt, value); + } + + static jsi::Value toJs(jsi::Runtime &rt, jsi::WeakObject &value) { + return value.lock(rt); + } +}; + +template +struct Bridging< + std::shared_ptr, + std::enable_if_t>> { + static std::shared_ptr fromJs(jsi::Runtime &rt, const jsi::Object &value) { + return value.asHostObject(rt); + } + + static jsi::Object toJs(jsi::Runtime &rt, std::shared_ptr value) { + return jsi::Object::createFromHostObject(rt, std::move(value)); + } +}; + +namespace map_detail { + +template +struct Bridging { + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result; + auto propertyNames = value.getPropertyNames(rt); + auto length = propertyNames.length(rt); + + for (size_t i = 0; i < length; i++) { + auto propertyName = propertyNames.getValueAtIndex(rt, i); + + result.emplace( + bridging::fromJs(rt, propertyName, jsInvoker), + bridging::fromJs( + rt, value.getProperty(rt, propertyName.asString(rt)), jsInvoker)); + } + + return result; + } + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &map, + const std::shared_ptr &jsInvoker) { + auto resultObject = jsi::Object(rt); + + for (const auto &[key, value] : map) { + resultObject.setProperty( + rt, + jsi::PropNameID::forUtf8(rt, key), + bridging::toJs(rt, value, jsInvoker)); + } + + return resultObject; + } +}; + +} // namespace map_detail + +#ifdef BUTTER_USE_FOLLY_CONTAINERS +template +struct Bridging> + : map_detail::Bridging> {}; +#endif + +template +struct Bridging> + : map_detail::Bridging> {}; + +template +struct Bridging> + : map_detail::Bridging> {}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Promise.h b/ReactCommon/react/bridging/Promise.h new file mode 100644 index 00000000000000..00fb0151610040 --- /dev/null +++ b/ReactCommon/react/bridging/Promise.h @@ -0,0 +1,102 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +#include +#include + +namespace facebook::react { + +template +class AsyncPromise { + public: + AsyncPromise(jsi::Runtime &rt, const std::shared_ptr &jsInvoker) + : state_(std::make_shared()) { + auto constructor = rt.global().getPropertyAsFunction(rt, "Promise"); + + auto promise = constructor.callAsConstructor( + rt, + bridging::toJs( + rt, + // Safe to capture this since this is called synchronously. + [this](AsyncCallback resolve, AsyncCallback reject) { + state_->resolve = std::move(resolve); + state_->reject = std::move(reject); + }, + jsInvoker)); + + auto promiseHolder = std::make_shared(promise.asObject(rt)); + LongLivedObjectCollection::get().add(promiseHolder); + + // The shared state can retain the promise holder weakly now. + state_->promiseHolder = promiseHolder; + } + + void resolve(T value) { + std::lock_guard lock(state_->mutex); + + if (state_->resolve) { + state_->resolve->call(std::move(value)); + state_->resolve.reset(); + state_->reject.reset(); + } + } + + void reject(Error error) { + std::lock_guard lock(state_->mutex); + + if (state_->reject) { + state_->reject->call(std::move(error)); + state_->reject.reset(); + state_->resolve.reset(); + } + } + + jsi::Object get(jsi::Runtime &rt) const { + if (auto holder = state_->promiseHolder.lock()) { + return jsi::Value(rt, holder->promise).asObject(rt); + } else { + throw jsi::JSError(rt, "Failed to get invalidated promise"); + } + } + + private: + struct PromiseHolder : LongLivedObject { + PromiseHolder(jsi::Object p) : promise(std::move(p)) {} + + jsi::Object promise; + }; + + struct SharedState { + ~SharedState() { + if (auto holder = promiseHolder.lock()) { + holder->allowRelease(); + } + } + + std::mutex mutex; + std::weak_ptr promiseHolder; + std::optional> resolve; + std::optional> reject; + }; + + std::shared_ptr state_; +}; + +template +struct Bridging> { + static jsi::Object toJs(jsi::Runtime &rt, const AsyncPromise &promise) { + return promise.get(rt); + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/Value.h b/ReactCommon/react/bridging/Value.h new file mode 100644 index 00000000000000..07d949858397ff --- /dev/null +++ b/ReactCommon/react/bridging/Value.h @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include + +namespace facebook::react { + +template <> +struct Bridging { + static std::nullptr_t fromJs(jsi::Runtime &rt, const jsi::Value &value) { + if (value.isNull() || value.isUndefined()) { + return nullptr; + } else { + throw jsi::JSError(rt, "Cannot convert value to nullptr"); + } + } + + static std::nullptr_t toJs(jsi::Runtime &, std::nullptr_t) { + return nullptr; + } +}; + +template +struct Bridging> { + static std::optional fromJs( + jsi::Runtime &rt, + const jsi::Value &value, + const std::shared_ptr &jsInvoker) { + if (value.isNull() || value.isUndefined()) { + return {}; + } + return bridging::fromJs(rt, value, jsInvoker); + } + + template + static std::optional fromJs( + jsi::Runtime &rt, + const std::optional &value, + const std::shared_ptr &jsInvoker) { + if (value) { + return bridging::fromJs(rt, *value, jsInvoker); + } + return {}; + } + + static jsi::Value toJs( + jsi::Runtime &rt, + const std::optional &value, + const std::shared_ptr &jsInvoker) { + if (value) { + return bridging::toJs(rt, *value, jsInvoker); + } + return jsi::Value::null(); + } +}; + +template +struct Bridging< + std::shared_ptr, + std::enable_if_t>> { + static jsi::Value toJs( + jsi::Runtime &rt, + const std::shared_ptr &ptr, + const std::shared_ptr &jsInvoker) { + if (ptr) { + return bridging::toJs(rt, *ptr, jsInvoker); + } + return jsi::Value::null(); + } +}; + +template +struct Bridging> { + static jsi::Value toJs( + jsi::Runtime &rt, + const std::unique_ptr &ptr, + const std::shared_ptr &jsInvoker) { + if (ptr) { + return bridging::toJs(rt, *ptr, jsInvoker); + } + return jsi::Value::null(); + } +}; + +template +struct Bridging> { + static jsi::Value toJs( + jsi::Runtime &rt, + const std::weak_ptr &weakPtr, + const std::shared_ptr &jsInvoker) { + if (auto ptr = weakPtr.lock()) { + return bridging::toJs(rt, *ptr, jsInvoker); + } + return jsi::Value::null(); + } +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/tests/BridgingTest.cpp b/ReactCommon/react/bridging/tests/BridgingTest.cpp new file mode 100644 index 00000000000000..f213ba5c0d516d --- /dev/null +++ b/ReactCommon/react/bridging/tests/BridgingTest.cpp @@ -0,0 +1,407 @@ +/* + * 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. + */ + +#include "BridgingTest.h" + +namespace facebook::react { + +using namespace std::literals; + +TEST_F(BridgingTest, jsiTest) { + jsi::Value value = true; + jsi::Value string = jsi::String::createFromAscii(rt, "hello"); + jsi::Value object = jsi::Object(rt); + jsi::Value array = jsi::Array::createWithElements(rt, value, object); + jsi::Value func = function("() => {}"); + + // The bridging mechanism needs to know how to copy and downcast values. + EXPECT_NO_THROW(bridging::fromJs(rt, value, invoker)); + EXPECT_NO_THROW(bridging::fromJs(rt, string, invoker)); + EXPECT_NO_THROW(bridging::fromJs(rt, object, invoker)); + EXPECT_NO_THROW(bridging::fromJs(rt, array, invoker)); + EXPECT_NO_THROW(bridging::fromJs(rt, func, invoker)); + + // Should throw when attempting an invalid cast. + EXPECT_JSI_THROW(bridging::fromJs(rt, value, invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, array, invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, object, invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, string, invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, func, invoker)); + + // Should be able to generically no-op convert JSI. + EXPECT_NO_THROW(bridging::toJs(rt, value, invoker)); + EXPECT_NO_THROW(bridging::toJs(rt, string.asString(rt), invoker)); + EXPECT_NO_THROW(bridging::toJs(rt, object.asObject(rt), invoker)); + EXPECT_NO_THROW(bridging::toJs(rt, array.asObject(rt).asArray(rt), invoker)); + EXPECT_NO_THROW( + bridging::toJs(rt, func.asObject(rt).asFunction(rt), invoker)); +} + +TEST_F(BridgingTest, boolTest) { + EXPECT_TRUE(bridging::fromJs(rt, jsi::Value(true), invoker)); + EXPECT_FALSE(bridging::fromJs(rt, jsi::Value(false), invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, jsi::Value(1), invoker)); + + EXPECT_TRUE(bridging::toJs(rt, true).asBool()); + EXPECT_FALSE(bridging::toJs(rt, false).asBool()); +} + +TEST_F(BridgingTest, numberTest) { + EXPECT_EQ(1, bridging::fromJs(rt, jsi::Value(1), invoker)); + EXPECT_FLOAT_EQ(1.2f, bridging::fromJs(rt, jsi::Value(1.2), invoker)); + EXPECT_DOUBLE_EQ(1.2, bridging::fromJs(rt, jsi::Value(1.2), invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, jsi::Value(true), invoker)); + + EXPECT_EQ(1, static_cast(bridging::toJs(rt, 1).asNumber())); + EXPECT_FLOAT_EQ( + 1.2f, static_cast(bridging::toJs(rt, 1.2f).asNumber())); + EXPECT_DOUBLE_EQ(1.2, bridging::toJs(rt, 1.2).asNumber()); +} + +TEST_F(BridgingTest, stringTest) { + auto string = jsi::String::createFromAscii(rt, "hello"); + + EXPECT_EQ("hello"s, bridging::fromJs(rt, string, invoker)); + EXPECT_JSI_THROW(bridging::fromJs(rt, jsi::Value(1), invoker)); + + EXPECT_TRUE( + jsi::String::strictEquals(rt, string, bridging::toJs(rt, "hello"))); + EXPECT_TRUE( + jsi::String::strictEquals(rt, string, bridging::toJs(rt, "hello"s))); + EXPECT_TRUE( + jsi::String::strictEquals(rt, string, bridging::toJs(rt, "hello"sv))); +} + +TEST_F(BridgingTest, objectTest) { + auto object = jsi::Object(rt); + object.setProperty(rt, "foo", "bar"); + + auto omap = + bridging::fromJs>(rt, object, invoker); + auto umap = bridging::fromJs>( + rt, object, invoker); + auto bmap = bridging::fromJs>( + rt, object, invoker); + + EXPECT_EQ(1, omap.size()); + EXPECT_EQ(1, umap.size()); + EXPECT_EQ(1, bmap.size()); + EXPECT_EQ("bar"s, omap["foo"]); + EXPECT_EQ("bar"s, umap["foo"]); + EXPECT_EQ("bar"s, bmap["foo"]); + + EXPECT_EQ( + "bar"s, + bridging::toJs(rt, omap, invoker) + .getProperty(rt, "foo") + .asString(rt) + .utf8(rt)); + EXPECT_EQ( + "bar"s, + bridging::toJs(rt, umap, invoker) + .getProperty(rt, "foo") + .asString(rt) + .utf8(rt)); + EXPECT_EQ( + "bar"s, + bridging::toJs(rt, bmap, invoker) + .getProperty(rt, "foo") + .asString(rt) + .utf8(rt)); +} + +TEST_F(BridgingTest, hostObjectTest) { + struct TestHostObject : public jsi::HostObject { + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name) override { + if (name.utf8(rt) == "test") { + return jsi::Value(1); + } + return jsi::Value::undefined(); + } + }; + + auto hostobject = std::make_shared(); + auto object = bridging::toJs(rt, hostobject); + + EXPECT_EQ(1, object.getProperty(rt, "test").asNumber()); + EXPECT_EQ( + hostobject, bridging::fromJs(rt, object, invoker)); +} + +TEST_F(BridgingTest, weakbjectTest) { + auto object = jsi::Object(rt); + auto weakobject = jsi::WeakObject(rt, object); + + EXPECT_TRUE(jsi::Object::strictEquals( + rt, + object, + bridging::fromJs(rt, object, invoker) + .lock(rt) + .asObject(rt))); + + EXPECT_TRUE(jsi::Object::strictEquals( + rt, object, bridging::toJs(rt, weakobject).asObject(rt))); +} + +TEST_F(BridgingTest, arrayTest) { + auto vec = std::vector({"foo"s, "bar"s}); + auto array = jsi::Array::createWithElements(rt, "foo", "bar"); + + EXPECT_EQ( + vec, bridging::fromJs>(rt, array, invoker)); + + EXPECT_EQ(vec.size(), bridging::toJs(rt, vec, invoker).size(rt)); + for (size_t i = 0; i < vec.size(); i++) { + EXPECT_EQ( + vec[i], + bridging::toJs(rt, vec, invoker) + .getValueAtIndex(rt, i) + .asString(rt) + .utf8(rt)); + } + + EXPECT_EQ(2, bridging::toJs(rt, std::make_pair(1, "2"), invoker).size(rt)); + EXPECT_EQ(2, bridging::toJs(rt, std::make_tuple(1, "2"), invoker).size(rt)); + EXPECT_EQ(2, bridging::toJs(rt, std::array{1, 2}, invoker).size(rt)); + EXPECT_EQ(2, bridging::toJs(rt, std::deque{1, 2}, invoker).size(rt)); + EXPECT_EQ(2, bridging::toJs(rt, std::list{1, 2}, invoker).size(rt)); + EXPECT_EQ( + 2, + bridging::toJs(rt, std::initializer_list{1, 2}, invoker).size(rt)); +} + +TEST_F(BridgingTest, functionTest) { + auto object = jsi::Object(rt); + object.setProperty(rt, "foo", "bar"); + + auto lambda = [](std::map map, std::string key) { + return map[key]; + }; + + auto func = bridging::toJs(rt, lambda, invoker); + + EXPECT_EQ( + "bar"s, + func.call(rt, object, jsi::String::createFromAscii(rt, "foo")) + .asString(rt) + .utf8(rt)); + + // Should throw if not enough arguments are passed or are the wrong types. + EXPECT_JSI_THROW(func.call(rt, object)); + EXPECT_JSI_THROW(func.call(rt, object, jsi::Value(1))); + + // Test with non-capturing lambda converted to function pointer. + func = bridging::toJs(rt, +lambda, invoker); + + EXPECT_EQ( + "bar"s, + func.call(rt, object, jsi::String::createFromAscii(rt, "foo")) + .asString(rt) + .utf8(rt)); +} + +TEST_F(BridgingTest, syncCallbackTest) { + auto fn = function("(a, b) => a + b"); + auto cb = bridging::fromJs>( + rt, fn, invoker); + auto foo = "foo"s; + + EXPECT_EQ("foo1"s, cb(foo, 1)); // Tests lvalue string + EXPECT_EQ("bar2", cb("bar", 2)); // Tests rvalue C string + EXPECT_TRUE(fn.isFunction(rt)); // Ensure the function wasn't invalidated. +} + +TEST_F(BridgingTest, asyncCallbackTest) { + std::string output; + + auto func = std::function([&](auto str) { output = str; }); + + auto cb = bridging::fromJs>( + rt, function("(func, str) => func(str)"), invoker); + + cb(func, "hello"); + + flushQueue(); // Run scheduled async work + + EXPECT_EQ("hello"s, output); +} + +TEST_F(BridgingTest, promiseTest) { + auto func = function( + "(promise, obj) => {" + " promise.then(" + " (res) => { obj.res = res; }," + " (err) => { obj.err = err; }" + " )" + "}"); + + auto promise = AsyncPromise>(rt, invoker); + auto output = jsi::Object(rt); + + func.call(rt, bridging::toJs(rt, promise, invoker), output); + promise.resolve({"foo"s, "bar"s}); + flushQueue(); + + EXPECT_EQ(1, output.getPropertyNames(rt).size(rt)); + EXPECT_EQ(2, output.getProperty(rt, "res").asObject(rt).asArray(rt).size(rt)); + EXPECT_NO_THROW(promise.resolve({"ignored"})); + EXPECT_NO_THROW(promise.reject("ignored")); + + promise = AsyncPromise>(rt, invoker); + output = jsi::Object(rt); + + func.call(rt, bridging::toJs(rt, promise, invoker), output); + promise.reject("fail"); + flushQueue(); + + EXPECT_EQ(1, output.getPropertyNames(rt).size(rt)); + EXPECT_EQ( + "fail"s, + output.getProperty(rt, "err") + .asObject(rt) + .getProperty(rt, "message") + .asString(rt) + .utf8(rt)); + EXPECT_NO_THROW(promise.resolve({"ignored"})); + EXPECT_NO_THROW(promise.reject("ignored")); +} + +TEST_F(BridgingTest, optionalTest) { + EXPECT_EQ( + 1, bridging::fromJs>(rt, jsi::Value(1), invoker)); + EXPECT_EQ( + 1, + bridging::fromJs>( + rt, std::make_optional(jsi::Value(1)), invoker)); + EXPECT_EQ( + "hi"s, + bridging::fromJs>( + rt, + std::make_optional(jsi::String::createFromAscii(rt, "hi")), + invoker)); + EXPECT_FALSE( + bridging::fromJs>(rt, jsi::Value::undefined(), invoker) + .has_value()); + EXPECT_FALSE( + bridging::fromJs>(rt, jsi::Value::null(), invoker) + .has_value()); + + EXPECT_TRUE(bridging::toJs(rt, std::optional(), invoker).isNull()); + EXPECT_EQ(1, bridging::toJs(rt, std::optional(1), invoker).asNumber()); +} + +TEST_F(BridgingTest, pointerTest) { + auto str = "hi"s; + auto unique = std::make_unique(str); + auto shared = std::make_shared(str); + auto weak = std::weak_ptr(shared); + + EXPECT_EQ(str, bridging::toJs(rt, unique, invoker).asString(rt).utf8(rt)); + EXPECT_EQ(str, bridging::toJs(rt, shared, invoker).asString(rt).utf8(rt)); + EXPECT_EQ(str, bridging::toJs(rt, weak, invoker).asString(rt).utf8(rt)); + + shared.reset(); + + EXPECT_TRUE(bridging::toJs(rt, weak, invoker).isNull()); +} + +TEST_F(BridgingTest, supportTest) { + // Ensure sure can convert some basic types, including primitives that can be + // trivially converted to JSI values. + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs, jsi::Array>)); + EXPECT_TRUE((bridging::supportsFromJs, jsi::Array &>)); + EXPECT_TRUE( + (bridging::supportsFromJs, jsi::Object>)); + EXPECT_TRUE( + (bridging::supportsFromJs, jsi::Object &>)); + + // Ensure incompatible conversions will fail. + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs, jsi::String>)); + EXPECT_FALSE((bridging::supportsFromJs, jsi::String &>)); + + // Ensure copying and up/down casting JSI values is also supported. + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + EXPECT_TRUE((bridging::supportsFromJs)); + + // Ensure incorrect casts will fail. + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + EXPECT_FALSE((bridging::supportsFromJs)); + + // Ensure we can convert some basic types to JSI values. + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs>)); + EXPECT_TRUE((bridging::supportsToJs, jsi::Array>)); + EXPECT_TRUE((bridging::supportsToJs>)); + EXPECT_TRUE( + (bridging::supportsToJs, jsi::Object>)); + EXPECT_TRUE((bridging::supportsToJs)); + EXPECT_TRUE((bridging::supportsToJs)); + + // Ensure invalid conversions to JSI values are not supported. + EXPECT_FALSE((bridging::supportsToJs)); + EXPECT_FALSE((bridging::supportsToJs)); + EXPECT_FALSE((bridging::supportsToJs)); + EXPECT_FALSE((bridging::supportsToJs)); + EXPECT_FALSE((bridging::supportsToJs)); + EXPECT_FALSE((bridging::supportsToJs, jsi::Function>)); +} + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/tests/BridgingTest.h b/ReactCommon/react/bridging/tests/BridgingTest.h new file mode 100644 index 00000000000000..aa8ed839da5991 --- /dev/null +++ b/ReactCommon/react/bridging/tests/BridgingTest.h @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +#define EXPECT_JSI_THROW(expr) EXPECT_THROW((expr), facebook::jsi::JSIException) + +namespace facebook::react { + +class TestCallInvoker : public CallInvoker { + public: + void invokeAsync(std::function &&fn) override { + queue_.push_back(std::move(fn)); + } + + void invokeSync(std::function &&) override { + FAIL() << "JSCallInvoker does not support invokeSync()"; + } + + private: + friend class BridgingTest; + + std::list> queue_; +}; + +class BridgingTest : public ::testing::Test { + protected: + BridgingTest() + : invoker(std::make_shared()), + runtime(hermes::makeHermesRuntime( + ::hermes::vm::RuntimeConfig::Builder() + // Make promises work with Hermes microtasks. + .withMicrotaskQueue(true) + .build())), + rt(*runtime) {} + + ~BridgingTest() { + LongLivedObjectCollection::get().clear(); + } + + void TearDown() override { + flushQueue(); + + // After flushing the invoker queue, we shouldn't leak memory. + EXPECT_EQ(0, LongLivedObjectCollection::get().size()); + } + + jsi::Value eval(const std::string &js) { + return rt.global().getPropertyAsFunction(rt, "eval").call(rt, js); + } + + jsi::Function function(const std::string &js) { + return eval(("(" + js + ")").c_str()).getObject(rt).getFunction(rt); + } + + void flushQueue() { + while (!invoker->queue_.empty()) { + invoker->queue_.front()(); + invoker->queue_.pop_front(); + rt.drainMicrotasks(); // Run microtasks every cycle. + } + } + + std::shared_ptr invoker; + std::unique_ptr runtime; + jsi::Runtime &rt; +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/bridging/tests/ClassTest.cpp b/ReactCommon/react/bridging/tests/ClassTest.cpp new file mode 100644 index 00000000000000..06c37820fab7af --- /dev/null +++ b/ReactCommon/react/bridging/tests/ClassTest.cpp @@ -0,0 +1,97 @@ +/* + * 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. + */ + +#include "BridgingTest.h" + +namespace facebook::react { + +using namespace std::literals; + +struct TestClass { + TestClass(std::shared_ptr invoker) : invoker_(invoker) {} + + double add(jsi::Runtime &, int a, float b) { + return a + b; + } + + jsi::Object getObject(jsi::Runtime &, jsi::Object obj) { + return obj; + } + + AsyncPromise getPromise(jsi::Runtime &rt, std::string result) { + auto promise = AsyncPromise(rt, invoker_); + promise.resolve(result); + return promise; + } + + std::string + callFunc(jsi::Runtime &, SyncCallback func, int num) { + return func(num); + } + + void callAsync(jsi::Runtime &, AsyncCallback<> callback) { + callback(); + } + + private: + std::shared_ptr invoker_; +}; + +TEST_F(BridgingTest, callFromJsTest) { + auto instance = TestClass(invoker); + + EXPECT_EQ( + 3.0, + bridging::callFromJs( + rt, &TestClass::add, invoker, &instance, 1, 2.0)); + + auto object = jsi::Object(rt); + + EXPECT_TRUE(jsi::Object::strictEquals( + rt, + object, + bridging::callFromJs( + rt, &TestClass::getObject, invoker, &instance, object))); + + auto promise = bridging::callFromJs( + rt, + &TestClass::getPromise, + invoker, + &instance, + jsi::String::createFromAscii(rt, "hi")); + auto then = promise.getPropertyAsFunction(rt, "then"); + + std::string result; + then.callWithThis( + rt, + promise, + bridging::toJs( + rt, [&](std::string res) { result = res; }, invoker)); + + flushQueue(); + EXPECT_EQ("hi"s, result); + + auto func = function("(num) => String(num)"); + + EXPECT_EQ( + "1"s, + bridging::callFromJs( + rt, &TestClass::callFunc, invoker, &instance, func, 1) + .utf8(rt)); + + bool called = false; + func = bridging::toJs( + rt, [&] { called = true; }, invoker); + + bridging::callFromJs( + rt, &TestClass::callAsync, invoker, &instance, func); + + flushQueue(); + EXPECT_TRUE(called); +} + +} // namespace facebook::react diff --git a/ReactCommon/react/config/Android.mk b/ReactCommon/react/config/Android.mk deleted file mode 100644 index c7b63c9699ebab..00000000000000 --- a/ReactCommon/react/config/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := reactconfig - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/config/BUCK b/ReactCommon/react/config/BUCK index 1d81785820c46f..767c3a8b0125b6 100644 --- a/ReactCommon/react/config/BUCK +++ b/ReactCommon/react/config/BUCK @@ -23,7 +23,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -35,7 +38,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", ], diff --git a/ReactCommon/react/config/CMakeLists.txt b/ReactCommon/react/config/CMakeLists.txt new file mode 100644 index 00000000000000..fea8855cb9cc78 --- /dev/null +++ b/ReactCommon/react/config/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -Wall + -DLOG_TAG=\"Fabric\") + +file(GLOB react_config_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_config SHARED ${react_config_SRC}) + +target_include_directories(react_config PUBLIC ${REACT_COMMON_DIR}) diff --git a/ReactCommon/react/config/ReactNativeConfig.cpp b/ReactCommon/react/config/ReactNativeConfig.cpp index 5bf8f145da26b9..abb33118d31014 100644 --- a/ReactCommon/react/config/ReactNativeConfig.cpp +++ b/ReactCommon/react/config/ReactNativeConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/config/ReactNativeConfig.h b/ReactCommon/react/config/ReactNativeConfig.h index 328dc54a3bfb37..63a8f2fe43636d 100644 --- a/ReactCommon/react/config/ReactNativeConfig.h +++ b/ReactCommon/react/config/ReactNativeConfig.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/debug/Android.mk b/ReactCommon/react/debug/Android.mk deleted file mode 100644 index 8dcbe4f224a8e5..00000000000000 --- a/ReactCommon/react/debug/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_debug - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libfolly_json - -LOCAL_LDLIBS := -llog - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall -llog - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) diff --git a/ReactCommon/react/debug/BUCK b/ReactCommon/react/debug/BUCK index 603c6146e528a5..756cd3dcfa0a5c 100644 --- a/ReactCommon/react/debug/BUCK +++ b/ReactCommon/react/debug/BUCK @@ -42,7 +42,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -53,7 +56,7 @@ rn_xplat_cxx_library( visibility = ["PUBLIC"], deps = [ "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", ], diff --git a/ReactCommon/react/debug/CMakeLists.txt b/ReactCommon/react/debug/CMakeLists.txt new file mode 100644 index 00000000000000..c325fcead16bd9 --- /dev/null +++ b/ReactCommon/react/debug/CMakeLists.txt @@ -0,0 +1,22 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -Wall + -DLOG_TAG=\"Fabric\") + + +file(GLOB react_debug_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_debug SHARED ${react_debug_SRC}) + +target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_debug log folly_runtime) diff --git a/ReactCommon/react/debug/flags.h b/ReactCommon/react/debug/flags.h index dc09ab36d40a3e..62d1cc445746a1 100644 --- a/ReactCommon/react/debug/flags.h +++ b/ReactCommon/react/debug/flags.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/debug/react_native_assert.cpp b/ReactCommon/react/debug/react_native_assert.cpp index ad31536726f450..abcdc5e8fbc015 100644 --- a/ReactCommon/react/debug/react_native_assert.cpp +++ b/ReactCommon/react/debug/react_native_assert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/debug/react_native_assert.h b/ReactCommon/react/debug/react_native_assert.h index fc3f97b7bbfc6b..b152858b809f05 100644 --- a/ReactCommon/react/debug/react_native_assert.h +++ b/ReactCommon/react/debug/react_native_assert.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -55,7 +55,7 @@ void react_native_assert_fail( #define react_native_assert(cond) \ if (!(cond)) { \ LOG(ERROR) << "react_native_assert failure: " << #cond; \ - google::FlushLogFiles(google::INFO); \ + google::FlushLogFiles(google::GLOG_INFO); \ assert(cond); \ } diff --git a/ReactCommon/react/nativemodule/core/Android.mk b/ReactCommon/react/nativemodule/core/Android.mk deleted file mode 100644 index bb2a0d79c7749c..00000000000000 --- a/ReactCommon/react/nativemodule/core/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_nativemodule_core - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/ReactCommon $(LOCAL_PATH)/platform/android/ReactCommon - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) $(wildcard $(LOCAL_PATH)/platform/android/ReactCommon/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/platform/android/ - -LOCAL_SHARED_LIBRARIES := libfbjni libfolly_json libreactnativejni libreact_debug libjsi - -LOCAL_STATIC_LIBRARIES := libreactperflogger - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,reactperflogger) diff --git a/ReactCommon/react/nativemodule/core/BUCK b/ReactCommon/react/nativemodule/core/BUCK index b0e29b37c244ac..1f46f068049151 100644 --- a/ReactCommon/react/nativemodule/core/BUCK +++ b/ReactCommon/react/nativemodule/core/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "FBJNI_TARGET", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags", "react_native_target", "react_native_xplat_shared_library_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob") +load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "FBJNI_TARGET", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags", "react_native_target", "react_native_xplat_shared_library_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob") rn_xplat_cxx_library( name = "core", @@ -55,8 +55,11 @@ rn_xplat_cxx_library( "platform/ios/**/*.mm", ], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], - platforms = (ANDROID, APPLE), + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], + platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", "-DWITH_FBSYSTRACE=1", @@ -67,7 +70,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", @@ -78,6 +81,7 @@ rn_xplat_cxx_library( react_native_xplat_target("reactperflogger:reactperflogger"), ], exported_deps = [ + react_native_xplat_target("react/bridging:bridging"), react_native_xplat_shared_library_target("jsi:jsi"), ], ) diff --git a/ReactCommon/react/nativemodule/core/CMakeLists.txt b/ReactCommon/react/nativemodule/core/CMakeLists.txt new file mode 100644 index 00000000000000..841ee87087ce0d --- /dev/null +++ b/ReactCommon/react/nativemodule/core/CMakeLists.txt @@ -0,0 +1,32 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"ReactNative\") + + +file(GLOB react_nativemodule_core_SRC CONFIGURE_DEPENDS + ReactCommon/*.cpp + platform/android/ReactCommon/*.cpp) +add_library(react_nativemodule_core + SHARED + ${react_nativemodule_core_SRC}) + +target_include_directories(react_nativemodule_core + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/platform/android/ + ) + +target_link_libraries(react_nativemodule_core + fbjni + folly_runtime + jsi + react_bridging + react_debug + reactperflogger + reactnativejni) diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h b/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h index 5173b73d01623b..1e1fa0cdb5d7c3 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,51 +7,5 @@ #pragma once -#include -#include -#include - -namespace facebook { -namespace react { - -/** - * A simple wrapper class that can be registered to a collection that keep it - * alive for extended period of time. This object can be removed from the - * collection when needed. - * - * The subclass of this class must be created using std::make_shared(). - * After creation, add it to the `LongLivedObjectCollection`. - * When done with the object, call `allowRelease()` to allow the OS to release - * it. - */ -class LongLivedObject { - public: - virtual void allowRelease(); - - protected: - LongLivedObject(); - virtual ~LongLivedObject(); -}; - -/** - * A singleton, thread-safe, write-only collection for the `LongLivedObject`s. - */ -class LongLivedObjectCollection { - public: - static LongLivedObjectCollection &get(); - - LongLivedObjectCollection(); - LongLivedObjectCollection(LongLivedObjectCollection const &) = delete; - void operator=(LongLivedObjectCollection const &) = delete; - - void add(std::shared_ptr o) const; - void remove(const LongLivedObject *o) const; - void clear() const; - - private: - mutable std::unordered_set> collection_; - mutable std::mutex collectionMutex_; -}; - -} // namespace react -} // namespace facebook +// This header is left here for compatibility reasons. +#include diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.cpp index 77dedb3665b62b..82d87674643206 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -60,7 +60,7 @@ CxxModule::Callback makeTurboCxxModuleCallback( TurboCxxModule::TurboCxxModule( std::unique_ptr cxxModule, std::shared_ptr jsInvoker) - : TurboModule(cxxModule->getName(), jsInvoker), + : TurboModule(cxxModule->getName(), std::move(jsInvoker)), cxxMethods_(cxxModule->getMethods()), cxxModule_(std::move(cxxModule)) {} @@ -69,10 +69,12 @@ jsi::Value TurboCxxModule::get( const jsi::PropNameID &propName) { std::string propNameUtf8 = propName.utf8(runtime); + auto result = jsi::Value::undefined(); + if (propNameUtf8 == "getConstants") { // This is special cased because `getConstants()` is already a part of // CxxModule. - return jsi::Function::createFromHostFunction( + result = jsi::Function::createFromHostFunction( runtime, propName, 0, @@ -89,30 +91,45 @@ jsi::Value TurboCxxModule::get( } return result; }); + } else { + for (auto &method : cxxMethods_) { + if (method.name == propNameUtf8) { + result = jsi::Function::createFromHostFunction( + runtime, + propName, + 0, + [this, propNameUtf8]( + jsi::Runtime &rt, + const jsi::Value &thisVal, + const jsi::Value *args, + size_t count) { + return invokeMethod(rt, propNameUtf8, args, count); + }); + } + } } - for (auto &method : cxxMethods_) { - if (method.name == propNameUtf8) { - return jsi::Function::createFromHostFunction( - runtime, - propName, - 0, - [this, propNameUtf8]( - jsi::Runtime &rt, - const jsi::Value &thisVal, - const jsi::Value *args, - size_t count) { - return invokeMethod(rt, VoidKind, propNameUtf8, args, count); - }); - } + // If we have a JS wrapper, cache the result of this lookup + if (jsRepresentation_) { + jsRepresentation_->setProperty(runtime, propName, result); } - return jsi::Value::undefined(); + return result; +} + +std::vector TurboCxxModule::getPropertyNames( + jsi::Runtime &runtime) { + std::vector result; + result.reserve(cxxMethods_.size() + 1); + result.push_back(jsi::PropNameID::forUtf8(runtime, "getConstants")); + for (auto it = cxxMethods_.begin(); it != cxxMethods_.end(); it++) { + result.push_back(jsi::PropNameID::forUtf8(runtime, it->name)); + } + return result; } jsi::Value TurboCxxModule::invokeMethod( jsi::Runtime &runtime, - TurboModuleMethodValueKind valueKind, const std::string &methodName, const jsi::Value *args, size_t count) { diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h index e419553aa5f8cd..03d19a37eb7363 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,13 +29,15 @@ class JSI_EXPORT TurboCxxModule : public TurboModule { std::unique_ptr cxxModule, std::shared_ptr jsInvoker); - virtual facebook::jsi::Value get( + facebook::jsi::Value get( facebook::jsi::Runtime &runtime, const facebook::jsi::PropNameID &propName) override; + std::vector getPropertyNames( + facebook::jsi::Runtime &runtime) override; + jsi::Value invokeMethod( jsi::Runtime &runtime, - TurboModuleMethodValueKind valueKind, const std::string &methodName, const jsi::Value *args, size_t count); diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp index f7045b3c89f50c..89ac90bcd8362a 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,37 +7,33 @@ #include "TurboModule.h" -using namespace facebook; - namespace facebook { namespace react { TurboModule::TurboModule( - const std::string &name, + std::string name, std::shared_ptr jsInvoker) - : name_(name), jsInvoker_(jsInvoker) {} - -TurboModule::~TurboModule() {} + : name_(std::move(name)), jsInvoker_(std::move(jsInvoker)) {} jsi::Value TurboModule::get( jsi::Runtime &runtime, - const jsi::PropNameID &propName) { - std::string propNameUtf8 = propName.utf8(runtime); - auto p = methodMap_.find(propNameUtf8); - if (p == methodMap_.end()) { - // Method was not found, let JS decide what to do. - return jsi::Value::undefined(); - } - MethodMetadata meta = p->second; - return jsi::Function::createFromHostFunction( + const jsi::PropNameID &propName, + const MethodMetadata &meta) { + auto result = jsi::Function::createFromHostFunction( runtime, propName, static_cast(meta.argCount), [this, meta]( - facebook::jsi::Runtime &rt, - const facebook::jsi::Value &thisVal, - const facebook::jsi::Value *args, + jsi::Runtime &rt, + const jsi::Value &thisVal, + const jsi::Value *args, size_t count) { return meta.invoker(rt, *this, args, count); }); + // If we have a JS wrapper, cache the result of this lookup + // We don't cache misses, to allow for methodMap_ to dynamically be extended + if (jsRepresentation_) { + jsRepresentation_->setProperty(runtime, propName, result); + } + return result; } } // namespace react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h index 0772986a76ab66..866a0b4d4921d5 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -32,22 +32,47 @@ enum TurboModuleMethodValueKind { PromiseKind, }; +class TurboCxxModule; +class TurboModuleBinding; + /** * Base HostObject class for every module to be exposed to JS */ class JSI_EXPORT TurboModule : public facebook::jsi::HostObject { public: - TurboModule(const std::string &name, std::shared_ptr jsInvoker); - virtual ~TurboModule(); + TurboModule(std::string name, std::shared_ptr jsInvoker); - virtual facebook::jsi::Value get( + // Note: keep this method declared inline to avoid conflicts + // between RTTI and non-RTTI compilation units + facebook::jsi::Value get( facebook::jsi::Runtime &runtime, - const facebook::jsi::PropNameID &propName) override; + const facebook::jsi::PropNameID &propName) override { + { + std::string propNameUtf8 = propName.utf8(runtime); + auto p = methodMap_.find(propNameUtf8); + if (p == methodMap_.end()) { + // Method was not found, let JS decide what to do. + return facebook::jsi::Value::undefined(); + } else { + return get(runtime, propName, p->second); + } + } + } + + std::vector getPropertyNames( + facebook::jsi::Runtime &runtime) override { + std::vector result; + result.reserve(methodMap_.size()); + for (auto it = methodMap_.cbegin(); it != methodMap_.cend(); ++it) { + result.push_back(jsi::PropNameID::forUtf8(runtime, it->first)); + } + return result; + } + protected: const std::string name_; std::shared_ptr jsInvoker_; - protected: struct MethodMetadata { size_t argCount; facebook::jsi::Value (*invoker)( @@ -56,8 +81,17 @@ class JSI_EXPORT TurboModule : public facebook::jsi::HostObject { const facebook::jsi::Value *args, size_t count); }; - std::unordered_map methodMap_; + + private: + friend class TurboCxxModule; + friend class TurboModuleBinding; + std::unique_ptr jsRepresentation_; + + facebook::jsi::Value get( + facebook::jsi::Runtime &runtime, + const facebook::jsi::PropNameID &propName, + const MethodMetadata &meta); }; /** diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp index 9c339edf36b900..03c65ef2890f7e 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,45 +22,18 @@ namespace react { * Public API to install the TurboModule system. */ -TurboModuleBinding::TurboModuleBinding( - const TurboModuleProviderFunctionType &&moduleProvider) - : moduleProvider_(std::move(moduleProvider)), - longLivedObjectCollection_(nullptr), - disableGlobalLongLivedObjectCollection_(false) {} - TurboModuleBinding::TurboModuleBinding( const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection) : moduleProvider_(std::move(moduleProvider)), - longLivedObjectCollection_(longLivedObjectCollection), - disableGlobalLongLivedObjectCollection_(true) {} - -void TurboModuleBinding::install( - jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider) { - runtime.global().setProperty( - runtime, - "__turboModuleProxy", - jsi::Function::createFromHostFunction( - runtime, - jsi::PropNameID::forAscii(runtime, "__turboModuleProxy"), - 1, - - // Create a TurboModuleBinding that uses the global - // LongLivedObjectCollection - [binding = - std::make_shared(std::move(moduleProvider))]( - jsi::Runtime &rt, - const jsi::Value &thisVal, - const jsi::Value *args, - size_t count) { - return binding->jsProxy(rt, thisVal, args, count); - })); -} + longLivedObjectCollection_(std::move(longLivedObjectCollection)), + bindingMode_(bindingMode) {} void TurboModuleBinding::install( jsi::Runtime &runtime, const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection) { runtime.global().setProperty( runtime, @@ -69,42 +42,27 @@ void TurboModuleBinding::install( runtime, jsi::PropNameID::forAscii(runtime, "__turboModuleProxy"), 1, - // Create a TurboModuleBinding that doesn't use the global - // LongLivedObjectCollection - [binding = std::make_shared( - std::move(moduleProvider), longLivedObjectCollection)]( + [binding = TurboModuleBinding( + std::move(moduleProvider), + bindingMode, + std::move(longLivedObjectCollection))]( jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, - size_t count) { - return binding->jsProxy(rt, thisVal, args, count); + size_t count) mutable { + return binding.getModule(rt, thisVal, args, count); })); } TurboModuleBinding::~TurboModuleBinding() { - if (longLivedObjectCollection_ != nullptr) { + if (longLivedObjectCollection_) { longLivedObjectCollection_->clear(); - return; - } - - if (disableGlobalLongLivedObjectCollection_) { - return; - } - - LongLivedObjectCollection::get().clear(); -} - -std::shared_ptr TurboModuleBinding::getModule( - const std::string &name) { - std::shared_ptr module = nullptr; - { - SystraceSection s("TurboModuleBinding::getModule", "module", name); - module = moduleProvider_(name); + } else { + LongLivedObjectCollection::get().clear(); } - return module; } -jsi::Value TurboModuleBinding::jsProxy( +jsi::Value TurboModuleBinding::getModule( jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *args, @@ -114,14 +72,41 @@ jsi::Value TurboModuleBinding::jsProxy( "__turboModuleProxy must be called with at least 1 argument"); } std::string moduleName = args[0].getString(runtime).utf8(runtime); - jsi::Value nullSchema = jsi::Value::undefined(); - std::shared_ptr module = getModule(moduleName); - if (module == nullptr) { + std::shared_ptr module; + { + SystraceSection s( + "TurboModuleBinding::moduleProvider", "module", moduleName); + module = moduleProvider_(moduleName); + } + if (module) { + // Default behaviour + if (bindingMode_ == TurboModuleBindingMode::HostObject) { + return jsi::Object::createFromHostObject(runtime, std::move(module)); + } + + auto &jsRepresentation = module->jsRepresentation_; + if (!jsRepresentation) { + jsRepresentation = std::make_unique(runtime); + if (bindingMode_ == TurboModuleBindingMode::Prototype) { + // Option 1: create plain object, with it's prototype mapped back to the + // hostobject. Any properties accessed are stored on the plain object + auto hostObject = + jsi::Object::createFromHostObject(runtime, std::move(module)); + jsRepresentation->setProperty( + runtime, "__proto__", std::move(hostObject)); + } else { + // Option 2: eagerly install all hostfunctions at this point, avoids + // prototype + for (auto &propName : module->getPropertyNames(runtime)) { + module->get(runtime, propName); + } + } + } + return jsi::Value(runtime, *jsRepresentation); + } else { return jsi::Value::null(); } - - return jsi::Object::createFromHostObject(runtime, std::move(module)); } } // namespace react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h index 87679af06bf29e..1791d4e272edcc 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,6 +18,12 @@ namespace react { class JSCallInvoker; +enum class TurboModuleBindingMode : uint8_t { + HostObject = 0, + Prototype = 1, + Eager = 2, +}; + /** * Represents the JavaScript binding for the TurboModule system. */ @@ -27,31 +33,24 @@ class TurboModuleBinding { * Installs TurboModuleBinding into JavaScript runtime. * Thread synchronization must be enforced externally. */ - static void install( - jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider); static void install( jsi::Runtime &runtime, const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection); - TurboModuleBinding(const TurboModuleProviderFunctionType &&moduleProvider); + private: TurboModuleBinding( const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection); virtual ~TurboModuleBinding(); - /** - * Get an TurboModule instance for the given module name. - */ - std::shared_ptr getModule(const std::string &name); - - private: /** * A lookup function exposed to JS to get an instance of a TurboModule * for the given name. */ - jsi::Value jsProxy( + jsi::Value getModule( jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *args, @@ -59,7 +58,7 @@ class TurboModuleBinding { TurboModuleProviderFunctionType moduleProvider_; std::shared_ptr longLivedObjectCollection_; - bool disableGlobalLongLivedObjectCollection_; + TurboModuleBindingMode bindingMode_; }; } // namespace react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.cpp index a55e632ffca787..fc030ab94d69de 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.h index 2f7fcf8c8b2dd3..e0b1b013f8595a 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp index 871bff431ddf49..cf9726aa020a82 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h index 0dc08136a610d3..92e10268daf0d1 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,9 +13,8 @@ #include #include -#include - -using namespace facebook; +#include +#include namespace facebook { namespace react { @@ -40,86 +39,6 @@ jsi::Value createPromiseAsJSIValue( jsi::Runtime &rt, const PromiseSetupFunctionType func); -// Helper for passing jsi::Function arg to other methods. -class CallbackWrapper : public LongLivedObject { - private: - CallbackWrapper( - jsi::Function &&callback, - jsi::Runtime &runtime, - std::shared_ptr jsInvoker) - : longLivedObjectCollection_(), - callback_(std::move(callback)), - runtime_(runtime), - jsInvoker_(std::move(jsInvoker)) {} - - CallbackWrapper( - std::shared_ptr longLivedObjectCollection, - jsi::Function &&callback, - jsi::Runtime &runtime, - std::shared_ptr jsInvoker) - : longLivedObjectCollection_(longLivedObjectCollection), - callback_(std::move(callback)), - runtime_(runtime), - jsInvoker_(std::move(jsInvoker)) {} - - // Use a weak_ptr to avoid a retain cycle: LongLivedObjectCollection owns all - // CallbackWrappers. So, CallbackWrapper cannot own its - // LongLivedObjectCollection. - std::weak_ptr longLivedObjectCollection_; - jsi::Function callback_; - jsi::Runtime &runtime_; - std::shared_ptr jsInvoker_; - - public: - static std::weak_ptr createWeak( - jsi::Function &&callback, - jsi::Runtime &runtime, - std::shared_ptr jsInvoker) { - auto wrapper = std::shared_ptr( - new CallbackWrapper(std::move(callback), runtime, jsInvoker)); - LongLivedObjectCollection::get().add(wrapper); - return wrapper; - } - - static std::weak_ptr createWeak( - std::shared_ptr longLivedObjectCollection, - jsi::Function &&callback, - jsi::Runtime &runtime, - std::shared_ptr jsInvoker) { - auto wrapper = std::shared_ptr(new CallbackWrapper( - longLivedObjectCollection, std::move(callback), runtime, jsInvoker)); - longLivedObjectCollection->add(wrapper); - return wrapper; - } - - // Delete the enclosed jsi::Function - void destroy() { - allowRelease(); - } - - jsi::Function &callback() { - return callback_; - } - - jsi::Runtime &runtime() { - return runtime_; - } - - CallInvoker &jsInvoker() { - return *(jsInvoker_); - } - - void allowRelease() override { - if (auto longLivedObjectCollection = longLivedObjectCollection_.lock()) { - if (longLivedObjectCollection != nullptr) { - longLivedObjectCollection->remove(this); - return; - } - } - LongLivedObject::allowRelease(); - } -}; - class RAIICallbackWrapperDestroyer { public: RAIICallbackWrapperDestroyer(std::weak_ptr callbackWrapper) diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index 18abcc3085b3b1..92e4c2bceb4f67 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -22,11 +23,11 @@ #include "JavaTurboModule.h" -namespace TMPL = facebook::react::TurboModulePerfLogger; - namespace facebook { namespace react { +namespace TMPL = TurboModulePerfLogger; + JavaTurboModule::JavaTurboModule(const InitParams ¶ms) : TurboModule(params.moduleName, params.jsInvoker), instance_(jni::make_global(params.instance)), @@ -54,11 +55,18 @@ JavaTurboModule::~JavaTurboModule() { } namespace { + +struct JNIArgs { + JNIArgs(size_t count) : args_(count) {} + std::vector args_; + std::vector globalRefs_; +}; + jni::local_ref createJavaCallbackFromJSIFunction( - JSCallbackRetainer retainJSCallback, + const JSCallbackRetainer &retainJSCallback, jsi::Function &&function, jsi::Runtime &rt, - std::shared_ptr jsInvoker) { + const std::shared_ptr &jsInvoker) { auto weakWrapper = retainJSCallback != nullptr ? retainJSCallback(std::move(function), rt, jsInvoker) : react::CallbackWrapper::createWeak(std::move(function), rt, jsInvoker); @@ -119,13 +127,6 @@ jni::local_ref createJavaCallbackFromJSIFunction( return JCxxCallbackImpl::newObjectCxxArgs(fn); } -template -std::string to_string(T v) { - std::ostringstream stream; - stream << v; - return stream.str(); -} - // This is used for generating short exception strings. std::string stringifyJSIValue(const jsi::Value &v, jsi::Runtime *rt = nullptr) { if (v.isUndefined()) { @@ -141,7 +142,7 @@ std::string stringifyJSIValue(const jsi::Value &v, jsi::Runtime *rt = nullptr) { } if (v.isNumber()) { - return "a number (" + to_string(v.getNumber()) + ")"; + return "a number (" + std::to_string(v.getNumber()) + ")"; } if (v.isString()) { @@ -162,7 +163,7 @@ class JavaTurboModuleArgumentConversionException : public std::runtime_error { const jsi::Value *arg, jsi::Runtime *rt) : std::runtime_error( - "Expected argument " + to_string(index) + " of method \"" + + "Expected argument " + std::to_string(index) + " of method \"" + methodName + "\" to be a " + expectedType + ", but got " + stringifyJSIValue(*arg, rt)) {} }; @@ -175,7 +176,7 @@ class JavaTurboModuleInvalidArgumentTypeException : public std::runtime_error { const std::string &methodName) : std::runtime_error( "Called method \"" + methodName + "\" with unsupported type " + - actualType + " at argument " + to_string(argIndex)) {} + actualType + " at argument " + std::to_string(argIndex)) {} }; class JavaTurboModuleInvalidArgumentCountException : public std::runtime_error { @@ -186,9 +187,9 @@ class JavaTurboModuleInvalidArgumentCountException : public std::runtime_error { int expectedArgCount) : std::runtime_error( "TurboModule method \"" + methodName + "\" called with " + - to_string(actualArgCount) + + std::to_string(actualArgCount) + " arguments (expected argument count: " + - to_string(expectedArgCount) + ").") {} + std::to_string(expectedArgCount) + ").") {} }; /** @@ -240,22 +241,20 @@ int32_t getUniqueId() { return counter++; } -} // namespace - -// fnjni already does this conversion, but since we are using plain JNI, this +// fbjni already does this conversion, but since we are using plain JNI, this // needs to be done again // TODO (axe) Reuse existing implementation as needed - the exist in // MethodInvoker.cpp -JNIArgs JavaTurboModule::convertJSIArgsToJNIArgs( +JNIArgs convertJSIArgsToJNIArgs( JNIEnv *env, jsi::Runtime &rt, - std::string methodName, - std::vector methodArgTypes, + const std::string &methodName, + const std::vector &methodArgTypes, const jsi::Value *args, size_t count, - std::shared_ptr jsInvoker, + const std::shared_ptr &jsInvoker, TurboModuleMethodValueKind valueKind, - JSCallbackRetainer retainJSCallback) { + const JSCallbackRetainer &retainJSCallback) { unsigned int expectedArgumentCount = valueKind == PromiseKind ? methodArgTypes.size() - 1 : methodArgTypes.size(); @@ -281,11 +280,8 @@ JNIArgs JavaTurboModule::convertJSIArgsToJNIArgs( return obj; }; - jclass booleanClass = nullptr; - jclass doubleClass = nullptr; - for (unsigned int argIndex = 0; argIndex < count; argIndex += 1) { - std::string type = methodArgTypes.at(argIndex); + const std::string &type = methodArgTypes.at(argIndex); const jsi::Value *arg = &args[argIndex]; jvalue *jarg = &jargs[argIndex]; @@ -295,7 +291,6 @@ JNIArgs JavaTurboModule::convertJSIArgsToJNIArgs( throw JavaTurboModuleArgumentConversionException( "number", argIndex, methodName, arg, &rt); } - jarg->d = arg->getNumber(); continue; } @@ -305,108 +300,64 @@ JNIArgs JavaTurboModule::convertJSIArgsToJNIArgs( throw JavaTurboModuleArgumentConversionException( "boolean", argIndex, methodName, arg, &rt); } - jarg->z = (jboolean)arg->getBool(); continue; } - if (!(type == "Ljava/lang/Double;" || type == "Ljava/lang/Boolean;" || - type == "Ljava/lang/String;" || - type == "Lcom/facebook/react/bridge/ReadableArray;" || - type == "Lcom/facebook/react/bridge/Callback;" || - type == "Lcom/facebook/react/bridge/ReadableMap;")) { - throw JavaTurboModuleInvalidArgumentTypeException( - type, argIndex, methodName); - } - if (arg->isNull() || arg->isUndefined()) { jarg->l = nullptr; - continue; - } - - if (type == "Ljava/lang/Double;") { + } else if (type == "Ljava/lang/Double;") { if (!arg->isNumber()) { throw JavaTurboModuleArgumentConversionException( "number", argIndex, methodName, arg, &rt); } - - if (doubleClass == nullptr) { - doubleClass = env->FindClass("java/lang/Double"); - } - - jmethodID doubleConstructor = - env->GetMethodID(doubleClass, "", "(D)V"); jarg->l = makeGlobalIfNecessary( - env->NewObject(doubleClass, doubleConstructor, arg->getNumber())); - continue; - } - - if (type == "Ljava/lang/Boolean;") { + jni::JDouble::valueOf(arg->getNumber()).release()); + } else if (type == "Ljava/lang/Boolean;") { if (!arg->isBool()) { throw JavaTurboModuleArgumentConversionException( "boolean", argIndex, methodName, arg, &rt); } - - if (booleanClass == nullptr) { - booleanClass = env->FindClass("java/lang/Boolean"); - } - - jmethodID booleanConstructor = - env->GetMethodID(booleanClass, "", "(Z)V"); jarg->l = makeGlobalIfNecessary( - env->NewObject(booleanClass, booleanConstructor, arg->getBool())); - continue; - } - - if (type == "Ljava/lang/String;") { + jni::JBoolean::valueOf(arg->getBool()).release()); + } else if (type == "Ljava/lang/String;") { if (!arg->isString()) { throw JavaTurboModuleArgumentConversionException( "string", argIndex, methodName, arg, &rt); } - jarg->l = makeGlobalIfNecessary( env->NewStringUTF(arg->getString(rt).utf8(rt).c_str())); - continue; - } - - if (type == "Lcom/facebook/react/bridge/ReadableArray;") { - if (!(arg->isObject() && arg->getObject(rt).isArray(rt))) { - throw JavaTurboModuleArgumentConversionException( - "Array", argIndex, methodName, arg, &rt); - } - - auto dynamicFromValue = jsi::dynamicFromValue(rt, *arg); - auto jParams = - ReadableNativeArray::newObjectCxxArgs(std::move(dynamicFromValue)); - jarg->l = makeGlobalIfNecessary(jParams.release()); - continue; - } - - if (type == "Lcom/facebook/react/bridge/Callback;") { + } else if (type == "Lcom/facebook/react/bridge/Callback;") { if (!(arg->isObject() && arg->getObject(rt).isFunction(rt))) { throw JavaTurboModuleArgumentConversionException( "Function", argIndex, methodName, arg, &rt); } - jsi::Function fn = arg->getObject(rt).getFunction(rt); jarg->l = makeGlobalIfNecessary( createJavaCallbackFromJSIFunction( retainJSCallback, std::move(fn), rt, jsInvoker) .release()); - continue; - } - - if (type == "Lcom/facebook/react/bridge/ReadableMap;") { + } else if (type == "Lcom/facebook/react/bridge/ReadableArray;") { + if (!(arg->isObject() && arg->getObject(rt).isArray(rt))) { + throw JavaTurboModuleArgumentConversionException( + "Array", argIndex, methodName, arg, &rt); + } + auto dynamicFromValue = jsi::dynamicFromValue(rt, *arg); + auto jParams = + ReadableNativeArray::newObjectCxxArgs(std::move(dynamicFromValue)); + jarg->l = makeGlobalIfNecessary(jParams.release()); + } else if (type == "Lcom/facebook/react/bridge/ReadableMap;") { if (!(arg->isObject())) { throw JavaTurboModuleArgumentConversionException( "Object", argIndex, methodName, arg, &rt); } - auto dynamicFromValue = jsi::dynamicFromValue(rt, *arg); auto jParams = ReadableNativeMap::createWithContents(std::move(dynamicFromValue)); jarg->l = makeGlobalIfNecessary(jParams.release()); - continue; + } else { + throw JavaTurboModuleInvalidArgumentTypeException( + type, argIndex, methodName); } } @@ -430,13 +381,16 @@ jsi::Value convertFromJMapToValue(JNIEnv *env, jsi::Runtime &rt, jobject arg) { return jsi::valueFromDynamic(rt, result->cthis()->consume()); } +} // namespace + jsi::Value JavaTurboModule::invokeJavaMethod( jsi::Runtime &runtime, TurboModuleMethodValueKind valueKind, const std::string &methodNameStr, const std::string &methodSignature, const jsi::Value *args, - size_t argCount) { + size_t argCount, + jmethodID &methodID) { const char *methodName = methodNameStr.c_str(); const char *moduleName = name_.c_str(); @@ -485,12 +439,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod( */ jni::JniLocalScope scope(env, estimatedLocalRefCount); - jclass cls = env->GetObjectClass(instance); - jmethodID methodID = - env->GetMethodID(cls, methodName, methodSignature.c_str()); - - auto checkJNIErrorForMethodCall = - [methodName, moduleName, isMethodSync]() -> void { + auto checkJNIErrorForMethodCall = [&]() -> void { try { FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); } catch (...) { @@ -503,9 +452,14 @@ jsi::Value JavaTurboModule::invokeJavaMethod( } }; - // If the method signature doesn't match, show a redbox here instead of - // crashing later. - checkJNIErrorForMethodCall(); + if (!methodID) { + jclass cls = env->GetObjectClass(instance); + methodID = env->GetMethodID(cls, methodName, methodSignature.c_str()); + + // If the method signature doesn't match, show a redbox here instead of + // crashing later. + checkJNIErrorForMethodCall(); + } // TODO(T43933641): Refactor to remove this special-casing if (methodNameStr == "getConstants") { @@ -555,81 +509,73 @@ jsi::Value JavaTurboModule::invokeJavaMethod( methodSignature.substr(methodSignature.find_last_of(')') + 1); if (returnType == "Ljava/lang/Boolean;") { auto returnObject = - (jobject)env->CallObjectMethodA(instance, methodID, jargs.data()); + env->CallObjectMethodA(instance, methodID, jargs.data()); checkJNIErrorForMethodCall(); TMPL::syncMethodCallExecutionEnd(moduleName, methodName); TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); - jsi::Value returnValue = jsi::Value::null(); - if (returnObject != nullptr) { - jclass booleanClass = env->FindClass("java/lang/Boolean"); - jmethodID booleanValueMethod = - env->GetMethodID(booleanClass, "booleanValue", "()Z"); - bool returnBoolean = - (bool)env->CallBooleanMethod(returnObject, booleanValueMethod); - checkJNIErrorForMethodCall(); - returnValue = jsi::Value(returnBoolean); + auto returnValue = jsi::Value::null(); + if (returnObject) { + auto booleanObj = jni::adopt_local( + static_cast(returnObject)); + returnValue = jsi::Value(static_cast(booleanObj->value())); } TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); TMPL::syncMethodCallEnd(moduleName, methodName); return returnValue; - } - - bool returnBoolean = - (bool)env->CallBooleanMethodA(instance, methodID, jargs.data()); - checkJNIErrorForMethodCall(); + } else { + bool returnBoolean = + (bool)env->CallBooleanMethodA(instance, methodID, jargs.data()); + checkJNIErrorForMethodCall(); - TMPL::syncMethodCallExecutionEnd(moduleName, methodName); - TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); + TMPL::syncMethodCallExecutionEnd(moduleName, methodName); + TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); - jsi::Value returnValue = jsi::Value(returnBoolean); + jsi::Value returnValue = jsi::Value(returnBoolean); - TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); - TMPL::syncMethodCallEnd(moduleName, methodName); + TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); + TMPL::syncMethodCallEnd(moduleName, methodName); - return returnValue; + return returnValue; + } } case NumberKind: { std::string returnType = methodSignature.substr(methodSignature.find_last_of(')') + 1); if (returnType == "Ljava/lang/Double;") { auto returnObject = - (jobject)env->CallObjectMethodA(instance, methodID, jargs.data()); + env->CallObjectMethodA(instance, methodID, jargs.data()); checkJNIErrorForMethodCall(); TMPL::syncMethodCallExecutionEnd(moduleName, methodName); TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); - jsi::Value returnValue = jsi::Value::null(); - if (returnObject != nullptr) { - jclass doubleClass = env->FindClass("java/lang/Double"); - jmethodID doubleValueMethod = - env->GetMethodID(doubleClass, "doubleValue", "()D"); - double returnDouble = - (double)env->CallDoubleMethod(returnObject, doubleValueMethod); - checkJNIErrorForMethodCall(); - returnValue = jsi::Value(returnDouble); + auto returnValue = jsi::Value::null(); + if (returnObject) { + auto doubleObj = jni::adopt_local( + static_cast(returnObject)); + returnValue = jsi::Value(doubleObj->value()); } TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); TMPL::syncMethodCallEnd(moduleName, methodName); return returnValue; - } - - double returnDouble = - (double)env->CallDoubleMethodA(instance, methodID, jargs.data()); - checkJNIErrorForMethodCall(); + } else { + double returnDouble = + (double)env->CallDoubleMethodA(instance, methodID, jargs.data()); + checkJNIErrorForMethodCall(); - TMPL::syncMethodCallExecutionEnd(moduleName, methodName); - TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); + TMPL::syncMethodCallExecutionEnd(moduleName, methodName); + TMPL::syncMethodCallReturnConversionStart(moduleName, methodName); - jsi::Value returnValue = jsi::Value(returnDouble); + jsi::Value returnValue = jsi::Value(returnDouble); - TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); - TMPL::syncMethodCallEnd(moduleName, methodName); - return returnValue; + TMPL::syncMethodCallReturnConversionEnd(moduleName, methodName); + TMPL::syncMethodCallEnd(moduleName, methodName); + return returnValue; + } } case StringKind: { auto returnString = @@ -654,7 +600,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod( } case ObjectKind: { auto returnObject = - (jobject)env->CallObjectMethodA(instance, methodID, jargs.data()); + env->CallObjectMethodA(instance, methodID, jargs.data()); checkJNIErrorForMethodCall(); TMPL::syncMethodCallExecutionEnd(moduleName, methodName); diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h index 4c5975844763ec..e420e46d147d62 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,22 +11,15 @@ #include #include -#include +#include #include -#include -#include #include +#include #include namespace facebook { namespace react { -struct JNIArgs { - JNIArgs(size_t count) : args_(count) {} - std::vector args_; - std::vector globalRefs_; -}; - struct JTurboModule : jni::JavaClass { static auto constexpr kJavaDescriptor = "Lcom/facebook/react/turbomodule/core/interfaces/TurboModule;"; @@ -35,7 +28,7 @@ struct JTurboModule : jni::JavaClass { using JSCallbackRetainer = std::function( jsi::Function &&callback, jsi::Runtime &runtime, - std::shared_ptr jsInvoker)>; + const std::shared_ptr &jsInvoker)>; class JSI_EXPORT JavaTurboModule : public TurboModule { public: @@ -57,23 +50,13 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { const std::string &methodName, const std::string &methodSignature, const jsi::Value *args, - size_t argCount); + size_t argCount, + jmethodID &cachedMethodID); private: jni::global_ref instance_; std::shared_ptr nativeInvoker_; JSCallbackRetainer retainJSCallback_; - - JNIArgs convertJSIArgsToJNIArgs( - JNIEnv *env, - jsi::Runtime &rt, - std::string methodName, - std::vector methodArgTypes, - const jsi::Value *args, - size_t count, - std::shared_ptr jsInvoker, - TurboModuleMethodValueKind valueKind, - JSCallbackRetainer retainJSCallbacks); }; } // namespace react diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h index 38dbd2bee4b7f3..a4bbb8b6e6c932 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm index 54a856a25a768a..c88429c67a8c53 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h index 1cc512c992c2c2..1d16b084213f57 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,7 +16,6 @@ #import #import #import -#import #import #import @@ -27,6 +26,7 @@ namespace facebook { namespace react { +class CallbackWrapper; class Instance; typedef std::weak_ptr ( diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm index c6e53547a65e1d..1ee5908fb2bd70 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,6 +27,7 @@ #import #import +using namespace facebook; using namespace facebook::react; static int32_t getUniqueId() @@ -625,7 +626,8 @@ static RCTResponseSenderBlock convertJSIFunctionToCallback( if ([objCArg isKindOfClass:[NSDictionary class]] && hasMethodArgConversionSelector(methodNameNSString, i)) { SEL methodArgConversionSelector = getMethodArgConversionSelector(methodNameNSString, i); - // Message dispatch logic from old infra (link: https://git.io/fjf3U) + // Message dispatch logic from old infra (link: + // https://github.com/facebook/react-native/commit/6783694158057662fd7b11fc123c339b2b21bfe6#diff-263fc157dfce55895cdc16495b55d190R350) RCTManagedPointer *(*convert)(id, SEL, id) = (__typeof__(convert))objc_msgSend; RCTManagedPointer *box = convert([RCTCxxConvert class], methodArgConversionSelector, objCArg); diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h index 2b9c4731940179..8ac86f431c2484 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index a63c805609de64..dffe85b24c0504 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,7 +27,9 @@ #import #import #import +#import +using namespace facebook; using namespace facebook::react; /** @@ -437,10 +439,15 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName __block id module = nil; if ([moduleClass conformsToProtocol:@protocol(RCTTurboModule)]) { + __weak __typeof(self) weakSelf = self; dispatch_block_t work = ^{ - module = [self _createAndSetUpRCTTurboModule:moduleClass - moduleName:moduleName - moduleId:moduleHolder->getModuleId()]; + auto strongSelf = weakSelf; + if (!strongSelf) { + return; + } + module = [strongSelf _createAndSetUpRCTTurboModule:moduleClass + moduleName:moduleName + moduleId:moduleHolder->getModuleId()]; }; if ([self _requiresMainQueueSetup:moduleClass]) { @@ -515,6 +522,19 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName std::lock_guard delegateGuard(_turboModuleManagerDelegateMutex); module = [_delegate getModuleInstanceFromClass:moduleClass]; } + + /** + * If the application is unable to create the TurboModule object from its class: + * abort TurboModule creation, and early return nil. + */ + if (!module) { + RCTLogError( + @"TurboModuleManager delegate %@ returned nil TurboModule object for module with name=\"%s\" and class=%@", + NSStringFromClass([_delegate class]), + moduleName, + NSStringFromClass(moduleClass)); + return nil; + } } else { module = [moduleClass new]; } @@ -697,18 +717,14 @@ - (BOOL)_requiresMainQueueSetup:(Class)moduleClass BOOL requiresMainQueueSetup = hasConstantsToExport || hasCustomInit; if (requiresMainQueueSetup) { - const char *methodName = ""; - if (hasConstantsToExport) { - methodName = "constantsToExport"; - } else if (hasCustomInit) { - methodName = "init"; - } RCTLogWarn( @"Module %@ requires main queue setup since it overrides `%s` but doesn't implement " "`requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules " "on a background thread unless explicitly opted-out of.", moduleClass, - methodName); + hasConstantsToExport ? "constantsToExport" + : hasCustomInit ? "init" + : ""); } return requiresMainQueueSetup; @@ -761,12 +777,14 @@ - (void)installJSBindingWithRuntimeExecutor:(facebook::react::RuntimeExecutor)ru if (RCTGetTurboModuleCleanupMode() == kRCTGlobalScope || RCTGetTurboModuleCleanupMode() == kRCTGlobalScopeUsingRetainJSCallback) { runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider)](jsi::Runtime &runtime) { - react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider)); + react::TurboModuleBinding::install( + runtime, std::move(turboModuleProvider), TurboModuleBindingMode::HostObject, nullptr); }); } else if (RCTGetTurboModuleCleanupMode() == kRCTTurboModuleManagerScope) { runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider), longLivedObjectCollection = _longLivedObjectCollection](jsi::Runtime &runtime) { - react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider), longLivedObjectCollection); + react::TurboModuleBinding::install( + runtime, std::move(turboModuleProvider), TurboModuleBindingMode::HostObject, longLivedObjectCollection); }); } } diff --git a/ReactCommon/react/nativemodule/samples/BUCK b/ReactCommon/react/nativemodule/samples/BUCK index d3ef2a8d956dca..b11b13c7488eed 100644 --- a/ReactCommon/react/nativemodule/samples/BUCK +++ b/ReactCommon/react/nativemodule/samples/BUCK @@ -56,7 +56,10 @@ rn_xplat_cxx_library( "platform/ios/**/*.mm", ], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -78,6 +81,7 @@ rn_android_library( name = "impl", srcs = glob(["platform/android/*.java"]), autoglob = False, + language = "JAVA", required_for_source_only_abi = True, visibility = [ "PUBLIC", diff --git a/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.cpp b/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.cpp index a9267d59a53073..d45de55ac6a8a6 100644 --- a/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.cpp +++ b/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.h b/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.h index 3255b45005c13a..400ee7e3d692a8 100644 --- a/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.h +++ b/ReactCommon/react/nativemodule/samples/ReactCommon/NativeSampleTurboCxxModuleSpecJSI.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.cpp b/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.cpp index 5d56c59d7ece20..a3d04f9438dfb6 100644 --- a/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.cpp +++ b/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.h b/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.h index c1ebb682362c64..5c41f71ae4f9e6 100644 --- a/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.h +++ b/ReactCommon/react/nativemodule/samples/ReactCommon/SampleTurboCxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/android/Android.mk b/ReactCommon/react/nativemodule/samples/platform/android/Android.mk deleted file mode 100644 index a000332e34c3e9..00000000000000 --- a/ReactCommon/react/nativemodule/samples/platform/android/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := sampleturbomodule -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core libjsi -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/react/nativemodule/samples/platform/android/CMakeLists.txt b/ReactCommon/react/nativemodule/samples/platform/android/CMakeLists.txt new file mode 100644 index 00000000000000..84d080c08398a6 --- /dev/null +++ b/ReactCommon/react/nativemodule/samples/platform/android/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"ReactNative\") + +file(GLOB sampleturbomodule_SRC CONFIGURE_DEPENDS ReactCommon/*.cpp) +add_library(sampleturbomodule STATIC ${sampleturbomodule_SRC}) + +target_include_directories(sampleturbomodule PUBLIC .) + +target_link_libraries(sampleturbomodule + fbjni + jsi + react_nativemodule_core) diff --git a/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java b/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java index f992e5d6ae1c67..1dd66decb687e9 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java +++ b/ReactCommon/react/nativemodule/samples/platform/android/NativeSampleTurboModuleSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp b/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp index 676a79ee5e76c0..d8001bfb178b9e 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp +++ b/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,8 +18,10 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) - .invokeJavaMethod(rt, VoidKind, "voidFunc", "()V", args, count); + .invokeJavaMethod( + rt, VoidKind, "voidFunc", "()V", args, count, cachedMethodId); } static facebook::jsi::Value @@ -28,8 +30,10 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getBool( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) - .invokeJavaMethod(rt, BooleanKind, "getBool", "(Z)Z", args, count); + .invokeJavaMethod( + rt, BooleanKind, "getBool", "(Z)Z", args, count, cachedMethodId); } static facebook::jsi::Value @@ -38,8 +42,10 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getNumber( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) - .invokeJavaMethod(rt, NumberKind, "getNumber", "(D)D", args, count); + .invokeJavaMethod( + rt, NumberKind, "getNumber", "(D)D", args, count, cachedMethodId); } static facebook::jsi::Value @@ -48,6 +54,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getString( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -55,7 +62,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getString( "getString", "(Ljava/lang/String;)Ljava/lang/String;", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -64,6 +72,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getArray( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -71,7 +80,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getArray( "getArray", "(Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/bridge/WritableArray;", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -80,6 +90,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getObject( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -87,7 +98,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getObject( "getObject", "(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -96,8 +108,10 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) - .invokeJavaMethod(rt, NumberKind, "getRootTag", "(D)D", args, count); + .invokeJavaMethod( + rt, NumberKind, "getRootTag", "(D)D", args, count, cachedMethodId); } static facebook::jsi::Value @@ -106,6 +120,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValue( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -113,7 +128,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValue( "getValue", "(DLjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -122,6 +138,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -129,7 +146,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback( "getValueWithCallback", "(Lcom/facebook/react/bridge/Callback;)V", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -138,6 +156,7 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( rt, @@ -145,7 +164,8 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise( "getValueWithPromise", "(ZLcom/facebook/react/bridge/Promise;)V", args, - count); + count, + cachedMethodId); } static facebook::jsi::Value @@ -154,9 +174,16 @@ __hostFunction_NativeSampleTurboModuleSpecJSI_getConstants( TurboModule &turboModule, const facebook::jsi::Value *args, size_t count) { + static jmethodID cachedMethodId = nullptr; return static_cast(turboModule) .invokeJavaMethod( - rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count); + rt, + ObjectKind, + "getConstants", + "()Ljava/util/Map;", + args, + count, + cachedMethodId); } NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI( @@ -197,7 +224,7 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI( } std::shared_ptr SampleTurboModuleSpec_ModuleProvider( - const std::string moduleName, + const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == "SampleTurboModule") { return std::make_shared(params); diff --git a/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.h b/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.h index 6baefae6d890d9..0754f9a9bba676 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.h +++ b/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,7 +25,7 @@ class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public JavaTurboModule { }; std::shared_ptr SampleTurboModuleSpec_ModuleProvider( - const std::string moduleName, + const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react diff --git a/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java b/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java index f919eb5bd2dd07..84a0f6dd086981 100644 --- a/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java +++ b/ReactCommon/react/nativemodule/samples/platform/android/SampleTurboModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h index b14289e1cd1baa..ab91dbeaf893e1 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm index 7337f63d51814f..d3edbda6813242 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTNativeSampleTurboModuleSpec.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.h b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.h index b39a9f8170afa8..318ba46aadfd6f 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.mm b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.mm index 8306c561744e29..72162e1c656b95 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.mm +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboCxxModule.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.h b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.h index 7f66c69c314e98..76e080b0197e28 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm index fc742b492fa6a6..11e57479cf6dfa 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm +++ b/ReactCommon/react/nativemodule/samples/platform/ios/RCTSampleTurboModule.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp index a66b01ef2c16b2..e46412e86b6137 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp +++ b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h index a3aa44062f5728..d09e688b2cdd4f 100644 --- a/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h +++ b/ReactCommon/react/nativemodule/samples/platform/ios/SampleTurboCxxModuleLegacyImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/.clang-tidy b/ReactCommon/react/renderer/.clang-tidy index c98fd78ff64baa..f413d1fc8587d5 100644 --- a/ReactCommon/react/renderer/.clang-tidy +++ b/ReactCommon/react/renderer/.clang-tidy @@ -1,5 +1,44 @@ --- +InheritParentConfig: true Checks: '> clang-diagnostic-*, +modernize-avoid-bind, +modernize-avoid-c-arrays, +modernize-deprecated-headers, +modernize-deprecated-ios-base-aliases, +modernize-loop-convert, +modernize-make-shared, +modernize-redundant-void-arg, +modernize-return-braced-init-list, +modernize-use-auto, +modernize-make-unique, +modernize-pass-by-value, +modernize-raw-string-literal, +modernize-replace-auto-ptr, +modernize-use-bool-literals, +modernize-replace-random-shuffle, +modernize-unary-static-assert, +modernize-use-emplace, +modernize-shrink-to-fit, +modernize-use-equals-default, +modernize-use-default-member-init, +modernize-use-nullptr, +modernize-use-noexcept, +modernize-use-equals-delete, +modernize-use-override, +modernize-use-using, +modernize-use-transparent-functors, +performance-faster-string-find, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +performance-inefficient-string-concatenation, +performance-inefficient-vector-operation, +performance-move-const-arg, +performance-move-constructor-init, +performance-noexcept-move-constructor, +performance-type-promotion-in-math-fn, +performance-unnecessary-copy-initialization, +performance-unnecessary-value-param, ' ... diff --git a/ReactCommon/react/renderer/animations/Android.mk b/ReactCommon/react/renderer/animations/Android.mk deleted file mode 100644 index c637dbb0d6005e..00000000000000 --- a/ReactCommon/react/renderer/animations/Android.mk +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_animations - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libreact_render_graphics libglog_init glog libruntimeexecutor libyoga librrc_view libreact_render_uimanager libfolly_futures libreact_render_componentregistry libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug libreact_render_mounting libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) -$(call import-module,runtimeexecutor) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/animations/BUCK b/ReactCommon/react/renderer/animations/BUCK index 72a29efdfc0fc7..8c4ad8f448f3a0 100644 --- a/ReactCommon/react/renderer/animations/BUCK +++ b/ReactCommon/react/renderer/animations/BUCK @@ -37,7 +37,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -49,7 +52,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/animations/CMakeLists.txt b/ReactCommon/react/renderer/animations/CMakeLists.txt new file mode 100644 index 00000000000000..75e3bc4c3632f3 --- /dev/null +++ b/ReactCommon/react/renderer/animations/CMakeLists.txt @@ -0,0 +1,32 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_animations_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_animations SHARED ${react_render_animations_SRC}) + +target_include_directories(react_render_animations PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_animations + folly_runtime + glog + glog_init + jsi + react_config + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_mounting + react_render_uimanager + rrc_view + runtimeexecutor + yoga +) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationCallbackWrapper.h b/ReactCommon/react/renderer/animations/LayoutAnimationCallbackWrapper.h index 2b0b6c167b6b05..f4e1ebf0ac415b 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationCallbackWrapper.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationCallbackWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index 8933bbe2c508f3..8ff9569a845e9d 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,10 +47,10 @@ void LayoutAnimationDriver::animationMutationsForFrame( : layoutAnimationConfig.updateConfig)); // Interpolate - std::pair progress = + auto progress = calculateAnimationProgress(now, animation, mutationConfig); - double animationTimeProgressLinear = progress.first; - double animationInterpolationFactor = progress.second; + auto animationTimeProgressLinear = progress.first; + auto animationInterpolationFactor = progress.second; auto mutatedShadowView = createInterpolatedShadowView( animationInterpolationFactor, baselineShadowView, finalShadowView); diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h index 428eb08ecad981..b495413042fa20 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 13e2f11155fe6e..332790447e8c28 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,8 @@ #include "LayoutAnimationKeyFrameManager.h" #include +#include +#include #include #include @@ -85,8 +87,8 @@ void PrintMutationInstructionRelative( } #endif -static inline float -interpolateFloats(float coefficient, float oldValue, float newValue) { +static inline Float +interpolateFloats(Float coefficient, Float oldValue, Float newValue) { return oldValue + (newValue - oldValue) * coefficient; } @@ -96,7 +98,7 @@ LayoutAnimationKeyFrameManager::LayoutAnimationKeyFrameManager( RuntimeExecutor runtimeExecutor, ContextContainer::Shared &contextContainer, LayoutAnimationStatusDelegate *delegate) - : runtimeExecutor_(runtimeExecutor), + : runtimeExecutor_(std::move(runtimeExecutor)), contextContainer_(contextContainer), layoutAnimationStatusDelegate_(delegate), now_([]() { @@ -172,7 +174,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const { return shouldAnimateFrame(); } -better::optional +std::optional LayoutAnimationKeyFrameManager::pullTransaction( SurfaceId surfaceId, MountingTransaction::Number transactionNumber, @@ -250,7 +252,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( surfaceId, mutations, conflictingAnimations); // Are we animating this list of mutations? - better::optional currentAnimation{}; + std::optional currentAnimation{}; { std::lock_guard lock(currentAnimationMutex_); if (currentAnimation_) { @@ -259,7 +261,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( } } - if (currentAnimation.hasValue()) { + if (currentAnimation.has_value()) { LayoutAnimation animation = std::move(currentAnimation).value(); animation.surfaceId = surfaceId; animation.startTime = now; @@ -271,9 +273,9 @@ LayoutAnimationKeyFrameManager::pullTransaction( // TODO: to prevent this step we could tag Remove/Insert mutations as // being moves on the Differ level, since we know that there? We could use // TinyMap here, but it's not exposed by Differentiator (yet). - better::set insertedTags; - better::set deletedTags; - better::set reparentedTags; // tags that are deleted and recreated + butter::set insertedTags; + butter::set deletedTags; + butter::set reparentedTags; // tags that are deleted and recreated std::unordered_map movedTags; for (const auto &mutation : mutations) { if (mutation.type == ShadowViewMutation::Type::Insert) { @@ -303,6 +305,10 @@ LayoutAnimationKeyFrameManager::pullTransaction( std::vector keyFramesToAnimate; auto const layoutAnimationConfig = animation.layoutAnimationConfig; for (auto const &mutation : mutations) { + if (mutation.type == ShadowViewMutation::Type::RemoveDeleteTree) { + continue; + } + ShadowView baselineShadowView = (mutation.type == ShadowViewMutation::Type::Delete || mutation.type == ShadowViewMutation::Type::Remove || @@ -320,7 +326,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( continue; } - better::optional executeMutationImmediately{}; + std::optional executeMutationImmediately{}; bool isRemoveReinserted = mutation.type == ShadowViewMutation::Type::Remove && @@ -702,7 +708,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( keyFramesToAnimate.push_back(keyFrame); } - if (executeMutationImmediately.hasValue()) { + if (executeMutationImmediately.has_value()) { PrintMutationInstruction( "Queue Up For Immediate Execution", *executeMutationImmediately); immediateMutations.push_back(*executeMutationImmediately); @@ -1063,7 +1069,7 @@ LayoutAnimationKeyFrameManager::pullTransaction( void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation( LayoutAnimation layoutAnimation) const { - currentAnimation_ = better::optional{layoutAnimation}; + currentAnimation_ = std::optional{layoutAnimation}; } void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate( @@ -1074,7 +1080,7 @@ void LayoutAnimationKeyFrameManager::setLayoutAnimationStatusDelegate( void LayoutAnimationKeyFrameManager::setClockNow( std::function now) { - now_ = now; + now_ = std::move(now); } void LayoutAnimationKeyFrameManager::enableSkipInvalidatedKeyFrames() { @@ -1114,7 +1120,7 @@ LayoutAnimationKeyFrameManager::getComponentDescriptorForShadowView( } ShadowView LayoutAnimationKeyFrameManager::createInterpolatedShadowView( - double progress, + Float progress, ShadowView const &startingView, ShadowView const &finalView) const { react_native_assert(startingView.tag > 0); @@ -1223,6 +1229,16 @@ void LayoutAnimationKeyFrameManager::queueFinalMutationsForCompletedKeyFrame( mutationsList.push_back(ShadowViewMutation::RemoveMutation( finalMutation.parentShadowView, prev, finalMutation.index)); break; + case ShadowViewMutation::Type::RemoveDeleteTree: + // Note: Currently, there is a guarantee that if RemoveDeleteTree + // operations are generated, we /also/ generate corresponding + // Remove/Delete operations that are marked as "redundant". + // LayoutAnimations will process the redundant operations here, and + // ignore this mega-op. In the future for perf reasons it would be + // nice to remove the redundant operations entirely but we would need + // to find a way to make the RemoveDeleteTree operation work with + // LayoutAnimations (that might not be possible). + break; case ShadowViewMutation::Type::Update: mutationsList.push_back(ShadowViewMutation::UpdateMutation( prev, finalMutation.newChildShadowView)); @@ -1308,7 +1324,7 @@ void LayoutAnimationKeyFrameManager:: // First, collect all final mutations that could impact this immediate // mutation. - std::vector candidateMutations{}; + std::vector candidateMutations{}; for (auto inflightAnimationIt = inflightAnimations_.rbegin() + (skipLastAnimation ? 1 : 0); @@ -1322,11 +1338,7 @@ void LayoutAnimationKeyFrameManager:: continue; } - for (auto it = inflightAnimation.keyFrames.begin(); - it != inflightAnimation.keyFrames.end(); - it++) { - auto &animatedKeyFrame = *it; - + for (auto const &animatedKeyFrame : inflightAnimation.keyFrames) { if (animatedKeyFrame.invalidated) { continue; } @@ -1337,7 +1349,8 @@ void LayoutAnimationKeyFrameManager:: continue; } - for (auto &delayedMutation : animatedKeyFrame.finalMutationsForKeyFrame) { + for (auto const &delayedMutation : + animatedKeyFrame.finalMutationsForKeyFrame) { if (delayedMutation.type != ShadowViewMutation::Type::Remove) { continue; } @@ -1375,7 +1388,7 @@ void LayoutAnimationKeyFrameManager:: candidateMutations.begin(), candidateMutations.end(), [&changed, &mutation, &adjustedDelta, &isRemoveMutation]( - ShadowViewMutation *candidateMutation) { + ShadowViewMutation const *candidateMutation) { bool indexConflicts = (candidateMutation->index < mutation.index || (isRemoveMutation && @@ -1430,11 +1443,7 @@ void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation( continue; } - for (auto it = inflightAnimation.keyFrames.begin(); - it != inflightAnimation.keyFrames.end(); - it++) { - auto &animatedKeyFrame = *it; - + for (auto &animatedKeyFrame : inflightAnimation.keyFrames) { if (animatedKeyFrame.invalidated) { continue; } @@ -1519,6 +1528,10 @@ void LayoutAnimationKeyFrameManager::getAndEraseConflictingAnimations( std::vector &conflictingAnimations) const { ShadowViewMutationList localConflictingMutations{}; for (auto const &mutation : mutations) { + if (mutation.type == ShadowViewMutation::Type::RemoveDeleteTree) { + continue; + } + bool mutationIsCreateOrDelete = mutation.type == ShadowViewMutation::Type::Create || mutation.type == ShadowViewMutation::Type::Delete; @@ -1616,7 +1629,7 @@ void LayoutAnimationKeyFrameManager::deleteAnimationsForStoppedSurfaces() // Execute stopSurface on any ongoing animations if (inflightAnimationsExistInitially) { - better::set surfaceIdsToStop{}; + butter::set surfaceIdsToStop{}; { std::lock_guard lock(surfaceIdsToStopMutex_); surfaceIdsToStop = surfaceIdsToStop_; diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 528fe052dad195..56d283a3f22038 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,8 +8,7 @@ #pragma once #include -#include -#include +#include #include #include #include @@ -20,6 +19,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -67,7 +68,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, // This is used to "hijack" the diffing process to figure out which mutations // should be animated. The mutations returned by this function will be // executed immediately. - better::optional pullTransaction( + std::optional pullTransaction( SurfaceId surfaceId, MountingTransaction::Number number, TransactionTelemetry const &telemetry, @@ -95,7 +96,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, protected: SharedComponentDescriptorRegistry componentDescriptorRegistry_; - mutable better::optional currentAnimation_{}; + mutable std::optional currentAnimation_{}; mutable std::mutex currentAnimationMutex_; /** @@ -120,7 +121,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, * @return */ ShadowView createInterpolatedShadowView( - double progress, + Float progress, ShadowView const &startingView, ShadowView const &finalView) const; @@ -148,7 +149,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, mutable std::mutex layoutAnimationStatusDelegateMutex_; mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{}; mutable std::mutex surfaceIdsToStopMutex_; - mutable better::set surfaceIdsToStop_{}; + mutable butter::set surfaceIdsToStop_{}; bool skipInvalidatedKeyFrames_{false}; /* diff --git a/ReactCommon/react/renderer/animations/conversions.h b/ReactCommon/react/renderer/animations/conversions.h index 9fdb7a5e08a68b..021399b9f7f701 100644 --- a/ReactCommon/react/renderer/animations/conversions.h +++ b/ReactCommon/react/renderer/animations/conversions.h @@ -1,19 +1,19 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ -#include +#include #include -#include +#include namespace facebook { namespace react { -static inline better::optional parseAnimationType( +static inline std::optional parseAnimationType( std::string param) { if (param == "spring") { return AnimationType::Spring; @@ -38,7 +38,7 @@ static inline better::optional parseAnimationType( return {}; } -static inline better::optional parseAnimationProperty( +static inline std::optional parseAnimationProperty( std::string param) { if (param == "opacity") { return AnimationProperty::Opacity; @@ -57,7 +57,7 @@ static inline better::optional parseAnimationProperty( return {}; } -static inline better::optional parseAnimationConfig( +static inline std::optional parseAnimationConfig( folly::dynamic const &config, double defaultDuration, bool parsePropertyType) { @@ -115,8 +115,8 @@ static inline better::optional parseAnimationConfig( double duration = defaultDuration; double delay = 0; - double springDamping = 0.5; - double initialVelocity = 0; + Float springDamping = 0.5; + Float initialVelocity = 0; auto const durationIt = config.find("duration"); if (durationIt != config.items().end()) { @@ -144,7 +144,7 @@ static inline better::optional parseAnimationConfig( if (springDampingIt != config.items().end() && springDampingIt->second.isDouble()) { if (springDampingIt->second.isDouble()) { - springDamping = springDampingIt->second.asDouble(); + springDamping = (Float)springDampingIt->second.asDouble(); } else { LOG(ERROR) << "Error parsing animation config: field `springDamping` must be a number"; @@ -155,7 +155,7 @@ static inline better::optional parseAnimationConfig( auto const initialVelocityIt = config.find("initialVelocity"); if (initialVelocityIt != config.items().end()) { if (initialVelocityIt->second.isDouble()) { - initialVelocity = initialVelocityIt->second.asDouble(); + initialVelocity = (Float)initialVelocityIt->second.asDouble(); } else { LOG(ERROR) << "Error parsing animation config: field `initialVelocity` must be a number"; @@ -163,7 +163,7 @@ static inline better::optional parseAnimationConfig( } } - return better::optional(AnimationConfig{ + return std::optional(AnimationConfig{ *animationType, animationProperty, duration, @@ -173,8 +173,8 @@ static inline better::optional parseAnimationConfig( } // Parse animation config from JS -static inline better::optional -parseLayoutAnimationConfig(folly::dynamic const &config) { +static inline std::optional parseLayoutAnimationConfig( + folly::dynamic const &config) { if (config.empty() || !config.isObject()) { return {}; } @@ -187,17 +187,17 @@ parseLayoutAnimationConfig(folly::dynamic const &config) { const auto createConfigIt = config.find("create"); const auto createConfig = createConfigIt == config.items().end() - ? better::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(createConfigIt->second, duration, true); const auto updateConfigIt = config.find("update"); const auto updateConfig = updateConfigIt == config.items().end() - ? better::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(updateConfigIt->second, duration, false); const auto deleteConfigIt = config.find("delete"); const auto deleteConfig = deleteConfigIt == config.items().end() - ? better::optional(AnimationConfig{}) + ? std::optional(AnimationConfig{}) : parseAnimationConfig(deleteConfigIt->second, duration, true); if (!createConfig || !updateConfig || !deleteConfig) { diff --git a/ReactCommon/react/renderer/animations/primitives.h b/ReactCommon/react/renderer/animations/primitives.h index 757c72c466ba63..91cd7e32490117 100644 --- a/ReactCommon/react/renderer/animations/primitives.h +++ b/ReactCommon/react/renderer/animations/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -43,8 +44,8 @@ struct AnimationConfig { 0; // these are perhaps better represented as uint64_t, but they // come from JS as doubles double delay = 0; - double springDamping = 0; - double initialVelocity = 0; + Float springDamping = 0; + Float initialVelocity = 0; }; // This corresponds exactly with JS. diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index 33e72268f1f689..ea6a5e600a98f7 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -29,8 +30,6 @@ // #include // #include -#include "LayoutAnimationDriver.h" - MockClock::time_point MockClock::time_ = {}; namespace facebook { @@ -65,7 +64,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Create a RuntimeExecutor RuntimeExecutor runtimeExecutor = - [](std::function fn) {}; + [](std::function const &) {}; // Create component descriptor registry for animation driver auto providerRegistry = @@ -121,8 +120,8 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto currentRootNode = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{singleRootChildNode})})); + std::make_shared( + ShadowNode::ListOfShared{singleRootChildNode})})); // Building an initial view hierarchy. auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); @@ -273,7 +272,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto transaction = animationDriver->pullTransaction(surfaceId, 0, telemetry, {}); // We have something to validate. - if (transaction.hasValue()) { + if (transaction.has_value()) { auto mutations = transaction->getMutations(); // Mutating the view tree. diff --git a/ReactCommon/react/renderer/animations/utils.cpp b/ReactCommon/react/renderer/animations/utils.cpp index 4d12eeab969c31..36b2307e024195 100644 --- a/ReactCommon/react/renderer/animations/utils.cpp +++ b/ReactCommon/react/renderer/animations/utils.cpp @@ -1,17 +1,17 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #include "utils.h" -#include +#include namespace facebook { namespace react { -std::pair calculateAnimationProgress( +std::pair calculateAnimationProgress( uint64_t now, LayoutAnimation const &animation, AnimationConfig const &mutationConfig) { @@ -20,8 +20,8 @@ std::pair calculateAnimationProgress( } uint64_t startTime = animation.startTime; - uint64_t delay = mutationConfig.delay; - uint64_t endTime = startTime + delay + mutationConfig.duration; + auto delay = (uint64_t)mutationConfig.delay; + uint64_t endTime = startTime + delay + (uint64_t)mutationConfig.duration; if (now >= endTime) { return {1, 1}; diff --git a/ReactCommon/react/renderer/animations/utils.h b/ReactCommon/react/renderer/animations/utils.h index 8654cea0a4ae1e..752025ae1376aa 100644 --- a/ReactCommon/react/renderer/animations/utils.h +++ b/ReactCommon/react/renderer/animations/utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,7 @@ #pragma once #include +#include #include namespace facebook { @@ -71,7 +72,7 @@ static inline bool shouldFirstComeBeforeSecondMutation( return false; } -std::pair calculateAnimationProgress( +std::pair calculateAnimationProgress( uint64_t now, LayoutAnimation const &animation, AnimationConfig const &mutationConfig); diff --git a/ReactCommon/react/renderer/attributedstring/Android.mk b/ReactCommon/react/renderer/attributedstring/Android.mk deleted file mode 100644 index c693f05d16ffcc..00000000000000 --- a/ReactCommon/react/renderer/attributedstring/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_attributedstring - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libbetter libreact_render_graphics libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view libreact_utils libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,better) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/attributedstring/AttributedString.cpp b/ReactCommon/react/renderer/attributedstring/AttributedString.cpp index e04c041dbd2f15..124d44c6be3623 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedString.cpp +++ b/ReactCommon/react/renderer/attributedstring/AttributedString.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -38,6 +38,11 @@ bool Fragment::operator==(const Fragment &rhs) const { rhs.parentShadowView.layoutMetrics); } +bool Fragment::isContentEqual(const Fragment &rhs) const { + return std::tie(string, textAttributes) == + std::tie(rhs.string, rhs.textAttributes); +} + bool Fragment::operator!=(const Fragment &rhs) const { return !(*this == rhs); } @@ -126,6 +131,20 @@ bool AttributedString::operator!=(const AttributedString &rhs) const { return !(*this == rhs); } +bool AttributedString::isContentEqual(const AttributedString &rhs) const { + if (fragments_.size() != rhs.fragments_.size()) { + return false; + } + + for (auto i = 0; i < fragments_.size(); i++) { + if (!fragments_[i].isContentEqual(rhs.fragments_[i])) { + return false; + } + } + + return true; +} + #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE diff --git a/ReactCommon/react/renderer/attributedstring/AttributedString.h b/ReactCommon/react/renderer/attributedstring/AttributedString.h index a1058c510bb267..2f1858c6f11c88 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedString.h +++ b/ReactCommon/react/renderer/attributedstring/AttributedString.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -46,6 +46,12 @@ class AttributedString : public Sealable, public DebugStringConvertible { */ bool isAttachment() const; + /* + * Returns whether the underlying text and attributes are equal, + * disregarding layout or other information. + */ + bool isContentEqual(const Fragment &rhs) const; + bool operator==(const Fragment &rhs) const; bool operator!=(const Fragment &rhs) const; }; @@ -56,7 +62,7 @@ class AttributedString : public Sealable, public DebugStringConvertible { int length{0}; }; - using Fragments = better::small_vector; + using Fragments = butter::small_vector; /* * Appends and prepends a `fragment` to the string. @@ -96,6 +102,8 @@ class AttributedString : public Sealable, public DebugStringConvertible { */ bool compareTextAttributesWithoutFrame(const AttributedString &rhs) const; + bool isContentEqual(const AttributedString &rhs) const; + bool operator==(const AttributedString &rhs) const; bool operator!=(const AttributedString &rhs) const; @@ -118,7 +126,11 @@ struct hash { size_t operator()( const facebook::react::AttributedString::Fragment &fragment) const { return folly::hash::hash_combine( - 0, fragment.string, fragment.textAttributes, fragment.parentShadowView); + 0, + fragment.string, + fragment.textAttributes, + fragment.parentShadowView, + fragment.parentShadowView.layoutMetrics); } }; diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp index a73131c9f545d1..d644a5164d347e 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,8 @@ #include +#include + namespace facebook { namespace react { @@ -22,9 +24,10 @@ AttributedStringBox::AttributedStringBox(AttributedString const &value) value_(std::make_shared(value)), opaquePointer_({}){}; -AttributedStringBox::AttributedStringBox( - std::shared_ptr const &opaquePointer) - : mode_(Mode::OpaquePointer), value_({}), opaquePointer_(opaquePointer) {} +AttributedStringBox::AttributedStringBox(std::shared_ptr opaquePointer) + : mode_(Mode::OpaquePointer), + value_({}), + opaquePointer_(std::move(opaquePointer)) {} AttributedStringBox::AttributedStringBox(AttributedStringBox &&other) noexcept : mode_(other.mode_), @@ -51,7 +54,7 @@ std::shared_ptr AttributedStringBox::getOpaquePointer() const { } AttributedStringBox &AttributedStringBox::operator=( - AttributedStringBox &&other) { + AttributedStringBox &&other) noexcept { if (this != &other) { mode_ = other.mode_; value_ = std::move(other.value_); diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h index b8bd96c9caebee..770386aef31a4d 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,7 +35,7 @@ class AttributedStringBox final { * Custom explicit constructors. */ explicit AttributedStringBox(AttributedString const &value); - explicit AttributedStringBox(std::shared_ptr const &opaquePointer); + explicit AttributedStringBox(std::shared_ptr opaquePointer); /* * Movable, Copyable, Assignable. @@ -43,7 +43,7 @@ class AttributedStringBox final { AttributedStringBox(AttributedStringBox const &other) = default; AttributedStringBox(AttributedStringBox &&other) noexcept; AttributedStringBox &operator=(AttributedStringBox const &other) = default; - AttributedStringBox &operator=(AttributedStringBox &&other); + AttributedStringBox &operator=(AttributedStringBox &&other) noexcept; /* * Getters. diff --git a/ReactCommon/react/renderer/attributedstring/BUCK b/ReactCommon/react/renderer/attributedstring/BUCK index 4c79645fcf3ca0..028c78c822b1a5 100644 --- a/ReactCommon/react/renderer/attributedstring/BUCK +++ b/ReactCommon/react/renderer/attributedstring/BUCK @@ -37,7 +37,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -49,7 +52,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", react_native_xplat_target("react/debug:debug"), diff --git a/ReactCommon/react/renderer/attributedstring/CMakeLists.txt b/ReactCommon/react/renderer/attributedstring/CMakeLists.txt new file mode 100644 index 00000000000000..03bc7df962d37c --- /dev/null +++ b/ReactCommon/react/renderer/attributedstring/CMakeLists.txt @@ -0,0 +1,29 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_attributedstring_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_attributedstring SHARED ${react_render_attributedstring_SRC}) + +target_include_directories(react_render_attributedstring PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_attributedstring + butter + folly_runtime + glog + glog_init + react_debug + react_render_core + react_render_debug + react_render_graphics + react_render_mapbuffer + react_utils + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp index d5251fa907b903..773c8d6a38aa34 100644 --- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h index 22f65af3ea4dcf..c71909b89ad15f 100644 --- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index 8c014d5a443cce..3728f0c361259a 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -37,20 +37,20 @@ void TextAttributes::apply(TextAttributes textAttributes) { fontSizeMultiplier = !std::isnan(textAttributes.fontSizeMultiplier) ? textAttributes.fontSizeMultiplier : fontSizeMultiplier; - fontWeight = textAttributes.fontWeight.hasValue() ? textAttributes.fontWeight - : fontWeight; - fontStyle = textAttributes.fontStyle.hasValue() ? textAttributes.fontStyle - : fontStyle; - fontVariant = textAttributes.fontVariant.hasValue() + fontWeight = textAttributes.fontWeight.has_value() ? textAttributes.fontWeight + : fontWeight; + fontStyle = textAttributes.fontStyle.has_value() ? textAttributes.fontStyle + : fontStyle; + fontVariant = textAttributes.fontVariant.has_value() ? textAttributes.fontVariant : fontVariant; - allowFontScaling = textAttributes.allowFontScaling.hasValue() + allowFontScaling = textAttributes.allowFontScaling.has_value() ? textAttributes.allowFontScaling : allowFontScaling; letterSpacing = !std::isnan(textAttributes.letterSpacing) ? textAttributes.letterSpacing : letterSpacing; - textTransform = textAttributes.textTransform.hasValue() + textTransform = textAttributes.textTransform.has_value() ? textAttributes.textTransform : textTransform; @@ -58,9 +58,9 @@ void TextAttributes::apply(TextAttributes textAttributes) { lineHeight = !std::isnan(textAttributes.lineHeight) ? textAttributes.lineHeight : lineHeight; - alignment = textAttributes.alignment.hasValue() ? textAttributes.alignment - : alignment; - baseWritingDirection = textAttributes.baseWritingDirection.hasValue() + alignment = textAttributes.alignment.has_value() ? textAttributes.alignment + : alignment; + baseWritingDirection = textAttributes.baseWritingDirection.has_value() ? textAttributes.baseWritingDirection : baseWritingDirection; @@ -68,15 +68,15 @@ void TextAttributes::apply(TextAttributes textAttributes) { textDecorationColor = textAttributes.textDecorationColor ? textAttributes.textDecorationColor : textDecorationColor; - textDecorationLineType = textAttributes.textDecorationLineType.hasValue() + textDecorationLineType = textAttributes.textDecorationLineType.has_value() ? textAttributes.textDecorationLineType : textDecorationLineType; - textDecorationStyle = textAttributes.textDecorationStyle.hasValue() + textDecorationStyle = textAttributes.textDecorationStyle.has_value() ? textAttributes.textDecorationStyle : textDecorationStyle; // Shadow - textShadowOffset = textAttributes.textShadowOffset.hasValue() + textShadowOffset = textAttributes.textShadowOffset.has_value() ? textAttributes.textShadowOffset.value() : textShadowOffset; textShadowRadius = !std::isnan(textAttributes.textShadowRadius) @@ -87,13 +87,13 @@ void TextAttributes::apply(TextAttributes textAttributes) { : textShadowColor; // Special - isHighlighted = textAttributes.isHighlighted.hasValue() + isHighlighted = textAttributes.isHighlighted.has_value() ? textAttributes.isHighlighted : isHighlighted; - layoutDirection = textAttributes.layoutDirection.hasValue() + layoutDirection = textAttributes.layoutDirection.has_value() ? textAttributes.layoutDirection : layoutDirection; - accessibilityRole = textAttributes.accessibilityRole.hasValue() + accessibilityRole = textAttributes.accessibilityRole.has_value() ? textAttributes.accessibilityRole : accessibilityRole; } diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 56c30652179e2b..82b8547507e574 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,8 +9,8 @@ #include #include +#include -#include #include #include #include @@ -46,38 +46,38 @@ class TextAttributes : public DebugStringConvertible { std::string fontFamily{""}; Float fontSize{std::numeric_limits::quiet_NaN()}; Float fontSizeMultiplier{std::numeric_limits::quiet_NaN()}; - better::optional fontWeight{}; - better::optional fontStyle{}; - better::optional fontVariant{}; - better::optional allowFontScaling{}; + std::optional fontWeight{}; + std::optional fontStyle{}; + std::optional fontVariant{}; + std::optional allowFontScaling{}; Float letterSpacing{std::numeric_limits::quiet_NaN()}; - better::optional textTransform{}; + std::optional textTransform{}; // Paragraph Styles Float lineHeight{std::numeric_limits::quiet_NaN()}; - better::optional alignment{}; - better::optional baseWritingDirection{}; + std::optional alignment{}; + std::optional baseWritingDirection{}; // Decoration SharedColor textDecorationColor{}; - better::optional textDecorationLineType{}; - better::optional textDecorationStyle{}; + std::optional textDecorationLineType{}; + std::optional textDecorationStyle{}; // Shadow // TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute. - better::optional textShadowOffset{}; + std::optional textShadowOffset{}; Float textShadowRadius{std::numeric_limits::quiet_NaN()}; SharedColor textShadowColor{}; // Special - better::optional isHighlighted{}; + std::optional isHighlighted{}; // TODO T59221129: document where this value comes from and how it is set. // It's not clear if this is being used properly, or if it's being set at all. // Currently, it is intentionally *not* being set as part of BaseTextProps // construction. - better::optional layoutDirection{}; - better::optional accessibilityRole{}; + std::optional layoutDirection{}; + std::optional accessibilityRole{}; #pragma mark - Operations diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index 576b8f008bb644..96cbc0c5d7e1de 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -768,7 +768,7 @@ inline void fromRawValue( const PropsParserContext &context, RawValue const &value, AttributedString::Range &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto start = map.find("start"); if (start != map.end()) { @@ -827,11 +827,11 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { auto _textAttributes = folly::dynamic::object(); if (textAttributes.foregroundColor) { _textAttributes( - "foregroundColor", toDynamic(textAttributes.foregroundColor)); + "foregroundColor", toAndroidRepr(textAttributes.foregroundColor)); } if (textAttributes.backgroundColor) { _textAttributes( - "backgroundColor", toDynamic(textAttributes.backgroundColor)); + "backgroundColor", toAndroidRepr(textAttributes.backgroundColor)); } if (!std::isnan(textAttributes.opacity)) { _textAttributes("opacity", textAttributes.opacity); @@ -860,7 +860,7 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { if (!std::isnan(textAttributes.letterSpacing)) { _textAttributes("letterSpacing", textAttributes.letterSpacing); } - if (textAttributes.textTransform.hasValue()) { + if (textAttributes.textTransform.has_value()) { _textAttributes("textTransform", toString(*textAttributes.textTransform)); } if (!std::isnan(textAttributes.lineHeight)) { @@ -876,7 +876,8 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { // Decoration if (textAttributes.textDecorationColor) { _textAttributes( - "textDecorationColor", toDynamic(textAttributes.textDecorationColor)); + "textDecorationColor", + toAndroidRepr(textAttributes.textDecorationColor)); } if (textAttributes.textDecorationLineType.has_value()) { _textAttributes( @@ -894,7 +895,7 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { } if (textAttributes.textShadowColor) { _textAttributes( - "textShadowColor", toDynamic(textAttributes.textShadowColor)); + "textShadowColor", toAndroidRepr(textAttributes.textShadowColor)); } // Special if (textAttributes.isHighlighted.has_value()) { @@ -945,50 +946,50 @@ inline folly::dynamic toDynamic(AttributedString::Range const &range) { } // constants for AttributedString serialization -constexpr static Key AS_KEY_HASH = 0; -constexpr static Key AS_KEY_STRING = 1; -constexpr static Key AS_KEY_FRAGMENTS = 2; -constexpr static Key AS_KEY_CACHE_ID = 3; +constexpr static MapBuffer::Key AS_KEY_HASH = 0; +constexpr static MapBuffer::Key AS_KEY_STRING = 1; +constexpr static MapBuffer::Key AS_KEY_FRAGMENTS = 2; +constexpr static MapBuffer::Key AS_KEY_CACHE_ID = 3; // constants for Fragment serialization -constexpr static Key FR_KEY_STRING = 0; -constexpr static Key FR_KEY_REACT_TAG = 1; -constexpr static Key FR_KEY_IS_ATTACHMENT = 2; -constexpr static Key FR_KEY_WIDTH = 3; -constexpr static Key FR_KEY_HEIGHT = 4; -constexpr static Key FR_KEY_TEXT_ATTRIBUTES = 5; +constexpr static MapBuffer::Key FR_KEY_STRING = 0; +constexpr static MapBuffer::Key FR_KEY_REACT_TAG = 1; +constexpr static MapBuffer::Key FR_KEY_IS_ATTACHMENT = 2; +constexpr static MapBuffer::Key FR_KEY_WIDTH = 3; +constexpr static MapBuffer::Key FR_KEY_HEIGHT = 4; +constexpr static MapBuffer::Key FR_KEY_TEXT_ATTRIBUTES = 5; // constants for Text Attributes serialization -constexpr static Key TA_KEY_FOREGROUND_COLOR = 0; -constexpr static Key TA_KEY_BACKGROUND_COLOR = 1; -constexpr static Key TA_KEY_OPACITY = 2; -constexpr static Key TA_KEY_FONT_FAMILY = 3; -constexpr static Key TA_KEY_FONT_SIZE = 4; -constexpr static Key TA_KEY_FONT_SIZE_MULTIPLIER = 5; -constexpr static Key TA_KEY_FONT_WEIGHT = 6; -constexpr static Key TA_KEY_FONT_STYLE = 7; -constexpr static Key TA_KEY_FONT_VARIANT = 8; -constexpr static Key TA_KEY_ALLOW_FONT_SCALING = 9; -constexpr static Key TA_KEY_LETTER_SPACING = 10; -constexpr static Key TA_KEY_LINE_HEIGHT = 11; -constexpr static Key TA_KEY_ALIGNMENT = 12; -constexpr static Key TA_KEY_BEST_WRITING_DIRECTION = 13; -constexpr static Key TA_KEY_TEXT_DECORATION_COLOR = 14; -constexpr static Key TA_KEY_TEXT_DECORATION_LINE = 15; -constexpr static Key TA_KEY_TEXT_DECORATION_STYLE = 16; -constexpr static Key TA_KEY_TEXT_SHADOW_RAIDUS = 18; -constexpr static Key TA_KEY_TEXT_SHADOW_COLOR = 19; -constexpr static Key TA_KEY_IS_HIGHLIGHTED = 20; -constexpr static Key TA_KEY_LAYOUT_DIRECTION = 21; -constexpr static Key TA_KEY_ACCESSIBILITY_ROLE = 22; +constexpr static MapBuffer::Key TA_KEY_FOREGROUND_COLOR = 0; +constexpr static MapBuffer::Key TA_KEY_BACKGROUND_COLOR = 1; +constexpr static MapBuffer::Key TA_KEY_OPACITY = 2; +constexpr static MapBuffer::Key TA_KEY_FONT_FAMILY = 3; +constexpr static MapBuffer::Key TA_KEY_FONT_SIZE = 4; +constexpr static MapBuffer::Key TA_KEY_FONT_SIZE_MULTIPLIER = 5; +constexpr static MapBuffer::Key TA_KEY_FONT_WEIGHT = 6; +constexpr static MapBuffer::Key TA_KEY_FONT_STYLE = 7; +constexpr static MapBuffer::Key TA_KEY_FONT_VARIANT = 8; +constexpr static MapBuffer::Key TA_KEY_ALLOW_FONT_SCALING = 9; +constexpr static MapBuffer::Key TA_KEY_LETTER_SPACING = 10; +constexpr static MapBuffer::Key TA_KEY_LINE_HEIGHT = 11; +constexpr static MapBuffer::Key TA_KEY_ALIGNMENT = 12; +constexpr static MapBuffer::Key TA_KEY_BEST_WRITING_DIRECTION = 13; +constexpr static MapBuffer::Key TA_KEY_TEXT_DECORATION_COLOR = 14; +constexpr static MapBuffer::Key TA_KEY_TEXT_DECORATION_LINE = 15; +constexpr static MapBuffer::Key TA_KEY_TEXT_DECORATION_STYLE = 16; +constexpr static MapBuffer::Key TA_KEY_TEXT_SHADOW_RADIUS = 18; +constexpr static MapBuffer::Key TA_KEY_TEXT_SHADOW_COLOR = 19; +constexpr static MapBuffer::Key TA_KEY_IS_HIGHLIGHTED = 20; +constexpr static MapBuffer::Key TA_KEY_LAYOUT_DIRECTION = 21; +constexpr static MapBuffer::Key TA_KEY_ACCESSIBILITY_ROLE = 22; // constants for ParagraphAttributes serialization -constexpr static Key PA_KEY_MAX_NUMBER_OF_LINES = 0; -constexpr static Key PA_KEY_ELLIPSIZE_MODE = 1; -constexpr static Key PA_KEY_TEXT_BREAK_STRATEGY = 2; -constexpr static Key PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3; -constexpr static Key PA_KEY_INCLUDE_FONT_PADDING = 4; -constexpr static Key PA_KEY_HYPHENATION_FREQUENCY = 5; +constexpr static MapBuffer::Key PA_KEY_MAX_NUMBER_OF_LINES = 0; +constexpr static MapBuffer::Key PA_KEY_ELLIPSIZE_MODE = 1; +constexpr static MapBuffer::Key PA_KEY_TEXT_BREAK_STRATEGY = 2; +constexpr static MapBuffer::Key PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3; +constexpr static MapBuffer::Key PA_KEY_INCLUDE_FONT_PADDING = 4; +constexpr static MapBuffer::Key PA_KEY_HYPHENATION_FREQUENCY = 5; inline MapBuffer toMapBuffer(const ParagraphAttributes ¶graphAttributes) { auto builder = MapBufferBuilder(); @@ -1036,11 +1037,11 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { auto builder = MapBufferBuilder(); if (textAttributes.foregroundColor) { builder.putInt( - TA_KEY_FOREGROUND_COLOR, toMapBuffer(textAttributes.foregroundColor)); + TA_KEY_FOREGROUND_COLOR, toAndroidRepr(textAttributes.foregroundColor)); } if (textAttributes.backgroundColor) { builder.putInt( - TA_KEY_BACKGROUND_COLOR, toMapBuffer(textAttributes.backgroundColor)); + TA_KEY_BACKGROUND_COLOR, toAndroidRepr(textAttributes.backgroundColor)); } if (!std::isnan(textAttributes.opacity)) { builder.putDouble(TA_KEY_OPACITY, textAttributes.opacity); @@ -1087,7 +1088,7 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { if (textAttributes.textDecorationColor) { builder.putInt( TA_KEY_TEXT_DECORATION_COLOR, - toMapBuffer(textAttributes.textDecorationColor)); + toAndroidRepr(textAttributes.textDecorationColor)); } if (textAttributes.textDecorationLineType.has_value()) { builder.putString( @@ -1103,11 +1104,12 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { // Shadow if (!std::isnan(textAttributes.textShadowRadius)) { builder.putDouble( - TA_KEY_TEXT_SHADOW_RAIDUS, textAttributes.textShadowRadius); + TA_KEY_TEXT_SHADOW_RADIUS, textAttributes.textShadowRadius); } if (textAttributes.textShadowColor) { builder.putInt( - TA_KEY_TEXT_SHADOW_COLOR, toMapBuffer(textAttributes.textShadowColor)); + TA_KEY_TEXT_SHADOW_COLOR, + toAndroidRepr(textAttributes.textShadowColor)); } // Special if (textAttributes.isHighlighted.has_value()) { diff --git a/ReactCommon/react/renderer/attributedstring/primitives.h b/ReactCommon/react/renderer/attributedstring/primitives.h index ebf4616f5e6535..1535210aca2b64 100644 --- a/ReactCommon/react/renderer/attributedstring/primitives.h +++ b/ReactCommon/react/renderer/attributedstring/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringBoxTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringBoxTest.cpp index 493598b2c42cb5..e8c0047f987d42 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringBoxTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringBoxTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp index f0dff668592653..63991131325fd6 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp index 8b44e8b9fc2b94..1019578e8c1bd3 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp index 7fce2b9a7835b4..c753b00d67ac48 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/Android.mk b/ReactCommon/react/renderer/componentregistry/Android.mk deleted file mode 100644 index 06297c72980580..00000000000000 --- a/ReactCommon/react/renderer/componentregistry/Android.mk +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_componentregistry - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libjsi libfolly_futures libfolly_json libreact_render_core libreact_render_debug libreact_utils libglog_init libreact_debug - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/utils) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/componentregistry/BUCK b/ReactCommon/react/renderer/componentregistry/BUCK index 4ffce4a8be3d72..6b8b907041c9ab 100644 --- a/ReactCommon/react/renderer/componentregistry/BUCK +++ b/ReactCommon/react/renderer/componentregistry/BUCK @@ -33,7 +33,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -44,7 +47,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/componentregistry/CMakeLists.txt b/ReactCommon/react/renderer/componentregistry/CMakeLists.txt new file mode 100644 index 00000000000000..23b256112aa1a8 --- /dev/null +++ b/ReactCommon/react/renderer/componentregistry/CMakeLists.txt @@ -0,0 +1,24 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_componentregistry_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_componentregistry SHARED ${react_render_componentregistry_SRC}) + +target_include_directories(react_render_componentregistry PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_componentregistry + folly_runtime + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_utils +) diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorFactory.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorFactory.h index d152fb981bfbba..5d1c8b022d3849 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorFactory.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProvider.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProvider.h index 99e91a8e9a7c23..10f8e14cbb6060 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProvider.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProvider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp index 609316369d39c5..965c7d409fae5a 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,7 +12,7 @@ namespace react { void ComponentDescriptorProviderRegistry::add( ComponentDescriptorProvider provider) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); /* // TODO: T57583139 @@ -45,8 +45,9 @@ void ComponentDescriptorProviderRegistry::add( void ComponentDescriptorProviderRegistry::setComponentDescriptorProviderRequest( ComponentDescriptorProviderRequest componentDescriptorProviderRequest) const { - std::shared_lock lock(mutex_); - componentDescriptorProviderRequest_ = componentDescriptorProviderRequest; + std::shared_lock lock(mutex_); + componentDescriptorProviderRequest_ = + std::move(componentDescriptorProviderRequest); } void ComponentDescriptorProviderRegistry::request( @@ -54,7 +55,7 @@ void ComponentDescriptorProviderRegistry::request( ComponentDescriptorProviderRequest componentDescriptorProviderRequest; { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); componentDescriptorProviderRequest = componentDescriptorProviderRequest_; } @@ -66,7 +67,7 @@ void ComponentDescriptorProviderRegistry::request( ComponentDescriptorRegistry::Shared ComponentDescriptorProviderRegistry::createComponentDescriptorRegistry( ComponentDescriptorParameters const ¶meters) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto registry = std::make_shared( parameters, *this, parameters.contextContainer); diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h index c4d1982b0b0791..182d24a7a8c7cb 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -59,10 +59,10 @@ class ComponentDescriptorProviderRegistry final { void request(ComponentName componentName) const; - mutable better::shared_mutex mutex_; + mutable butter::shared_mutex mutex_; mutable std::vector> componentDescriptorRegistries_; - mutable better::map + mutable butter::map componentDescriptorProviders_; mutable ComponentDescriptorProviderRequest componentDescriptorProviderRequest_; diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 137fb20cbbfe4b..42fe6e0eff1426 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,20 +14,22 @@ #include #include +#include + namespace facebook { namespace react { ComponentDescriptorRegistry::ComponentDescriptorRegistry( - ComponentDescriptorParameters const ¶meters, + ComponentDescriptorParameters parameters, ComponentDescriptorProviderRegistry const &providerRegistry, ContextContainer::Shared contextContainer) - : parameters_(parameters), + : parameters_(std::move(parameters)), providerRegistry_(providerRegistry), - contextContainer_(contextContainer) {} + contextContainer_(std::move(contextContainer)) {} void ComponentDescriptorRegistry::add( ComponentDescriptorProvider componentDescriptorProvider) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); auto componentDescriptor = componentDescriptorProvider.constructor( {parameters_.eventDispatcher, @@ -58,7 +60,7 @@ void ComponentDescriptorRegistry::registerComponentDescriptor( ComponentDescriptor const &ComponentDescriptorRegistry::at( std::string const &componentName) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto unifiedComponentName = componentNameByReactViewName(componentName); @@ -95,7 +97,7 @@ ComponentDescriptor const &ComponentDescriptorRegistry::at( ComponentDescriptor const *ComponentDescriptorRegistry:: findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN( ComponentHandle componentHandle) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto iterator = _registryByHandle.find(componentHandle); if (iterator == _registryByHandle.end()) { @@ -107,14 +109,14 @@ ComponentDescriptor const *ComponentDescriptorRegistry:: ComponentDescriptor const &ComponentDescriptorRegistry::at( ComponentHandle componentHandle) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); return *_registryByHandle.at(componentHandle); } bool ComponentDescriptorRegistry::hasComponentDescriptorAt( ComponentHandle componentHandle) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto iterator = _registryByHandle.find(componentHandle); if (iterator == _registryByHandle.end()) { @@ -124,7 +126,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt( return true; } -SharedShadowNode ComponentDescriptorRegistry::createNode( +ShadowNode::Shared ComponentDescriptorRegistry::createNode( Tag tag, std::string const &viewName, SurfaceId surfaceId, diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h index e23d41c1461657..054af63c032b9d 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include #include @@ -37,7 +37,7 @@ class ComponentDescriptorRegistry { * be used later to create `ComponentDescriptor`s. */ ComponentDescriptorRegistry( - ComponentDescriptorParameters const ¶meters, + ComponentDescriptorParameters parameters, ComponentDescriptorProviderRegistry const &providerRegistry, ContextContainer::Shared contextContainer); @@ -80,10 +80,10 @@ class ComponentDescriptorRegistry { */ void add(ComponentDescriptorProvider componentDescriptorProvider) const; - mutable better::shared_mutex mutex_; - mutable better::map + mutable butter::shared_mutex mutex_; + mutable butter::map _registryByHandle; - mutable better::map _registryByName; + mutable butter::map _registryByName; ComponentDescriptor::Shared _fallbackComponentDescriptor; ComponentDescriptorParameters parameters_{}; ComponentDescriptorProviderRegistry const &providerRegistry_; diff --git a/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.cpp b/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.cpp index d703dcb549d9cc..1588f2e619d44e 100644 --- a/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.cpp +++ b/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.h b/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.h index 8408b2a2cadc00..ab6b9c9fc4f860 100644 --- a/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.h +++ b/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/native/Android.mk b/ReactCommon/react/renderer/componentregistry/native/Android.mk deleted file mode 100644 index f5674482f6bc40..00000000000000 --- a/ReactCommon/react/renderer/componentregistry/native/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_native - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_SHARED_LIBRARIES := libjsi libfolly_futures libfolly_json libreact_render_core libreact_render_debug libreact_utils libglog_init libreact_debug - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,jsi) diff --git a/ReactCommon/react/renderer/componentregistry/native/BUCK b/ReactCommon/react/renderer/componentregistry/native/BUCK index a6aceadb768660..72507b951e8091 100644 --- a/ReactCommon/react/renderer/componentregistry/native/BUCK +++ b/ReactCommon/react/renderer/componentregistry/native/BUCK @@ -32,7 +32,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -43,7 +46,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/componentregistry/native/CMakeLists.txt b/ReactCommon/react/renderer/componentregistry/native/CMakeLists.txt new file mode 100644 index 00000000000000..270c2e4334502a --- /dev/null +++ b/ReactCommon/react/renderer/componentregistry/native/CMakeLists.txt @@ -0,0 +1,24 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_native_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_native SHARED ${rrc_native_SRC}) + +target_include_directories(rrc_native PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_native + folly_runtime + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_utils +) diff --git a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp index 47487766304965..b23525bddc7880 100644 --- a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp +++ b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.h b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.h index 403b332342df7a..a728c23586e2d5 100644 --- a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.h +++ b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/Android.mk b/ReactCommon/react/renderer/components/image/Android.mk deleted file mode 100644 index 8c3fbcabda9c02..00000000000000 --- a/ReactCommon/react/renderer/components/image/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_image - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_render_imagemanager libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/components/view) -$(call import-module,yogajni) -$(call import-module,react/debug) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/image/BUCK b/ReactCommon/react/renderer/components/image/BUCK index 36ad159d49ef93..a26a74dc9ee7dd 100644 --- a/ReactCommon/react/renderer/components/image/BUCK +++ b/ReactCommon/react/renderer/components/image/BUCK @@ -34,7 +34,10 @@ rn_xplat_cxx_library( ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -44,7 +47,7 @@ rn_xplat_cxx_library( tests = [":tests"], visibility = ["PUBLIC"], deps = [ - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:molly", YOGA_CXX_TARGET, react_native_xplat_target("react/debug:debug"), diff --git a/ReactCommon/react/renderer/components/image/CMakeLists.txt b/ReactCommon/react/renderer/components/image/CMakeLists.txt new file mode 100644 index 00000000000000..c78c9a26b80440 --- /dev/null +++ b/ReactCommon/react/renderer/components/image/CMakeLists.txt @@ -0,0 +1,29 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_image_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_image SHARED ${rrc_image_SRC}) + +target_include_directories(rrc_image PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_image + glog + folly_runtime + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_render_graphics + react_render_imagemanager + react_render_mapbuffer + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h index 39465a0fe6107d..69bc565ee2a28e 100644 --- a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageEventEmitter.cpp b/ReactCommon/react/renderer/components/image/ImageEventEmitter.cpp index 20639e40bdcf61..731a592ad920a9 100644 --- a/ReactCommon/react/renderer/components/image/ImageEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/image/ImageEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageEventEmitter.h b/ReactCommon/react/renderer/components/image/ImageEventEmitter.h index 13bc446ee9eb6e..d4fa125ea72fba 100644 --- a/ReactCommon/react/renderer/components/image/ImageEventEmitter.h +++ b/ReactCommon/react/renderer/components/image/ImageEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageProps.cpp b/ReactCommon/react/renderer/components/image/ImageProps.cpp index b007b4869d4583..37ca6e4208cf58 100644 --- a/ReactCommon/react/renderer/components/image/ImageProps.cpp +++ b/ReactCommon/react/renderer/components/image/ImageProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageProps.h b/ReactCommon/react/renderer/components/image/ImageProps.h index b3d9ef36cf53be..dd55bce0961426 100644 --- a/ReactCommon/react/renderer/components/image/ImageProps.h +++ b/ReactCommon/react/renderer/components/image/ImageProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp b/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp index 64a1020e2e2178..5edd7966c89524 100644 --- a/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp +++ b/ReactCommon/react/renderer/components/image/ImageShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageShadowNode.h b/ReactCommon/react/renderer/components/image/ImageShadowNode.h index 0e60f78deef2dd..4376eda4a583b7 100644 --- a/ReactCommon/react/renderer/components/image/ImageShadowNode.h +++ b/ReactCommon/react/renderer/components/image/ImageShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageState.cpp b/ReactCommon/react/renderer/components/image/ImageState.cpp index d30d21680fb990..17b8261d71fc1f 100644 --- a/ReactCommon/react/renderer/components/image/ImageState.cpp +++ b/ReactCommon/react/renderer/components/image/ImageState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/ImageState.h b/ReactCommon/react/renderer/components/image/ImageState.h index 68cdcb681f4fd8..281d395658ff84 100644 --- a/ReactCommon/react/renderer/components/image/ImageState.h +++ b/ReactCommon/react/renderer/components/image/ImageState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/image/conversions.h b/ReactCommon/react/renderer/components/image/conversions.h index 9449dfe773b278..4b4e3d9ca9d31c 100644 --- a/ReactCommon/react/renderer/components/image/conversions.h +++ b/ReactCommon/react/renderer/components/image/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -30,8 +30,8 @@ inline void fromRawValue( return; } - if (value.hasType>()) { - auto items = (better::map)value; + if (value.hasType>()) { + auto items = (butter::map)value; result = {}; result.type = ImageSource::Type::Remote; diff --git a/ReactCommon/react/renderer/components/image/tests/ImageTest.cpp b/ReactCommon/react/renderer/components/image/tests/ImageTest.cpp index 9fc41d11a3f210..5a5ede8ee5d075 100644 --- a/ReactCommon/react/renderer/components/image/tests/ImageTest.cpp +++ b/ReactCommon/react/renderer/components/image/tests/ImageTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/inputaccessory/BUCK b/ReactCommon/react/renderer/components/inputaccessory/BUCK index f50bb4337bffe5..6e26a77b96a8d5 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/BUCK +++ b/ReactCommon/react/renderer/components/inputaccessory/BUCK @@ -27,7 +27,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = APPLE, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h index 7978f06330afc4..c579ba5d407c7e 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.cpp b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.cpp index dcc59dcb0205e7..d806054883e2b6 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.cpp +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.h b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.h index d0afebc23ad16a..595c23bc86f71a 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.h +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryState.h b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryState.h index 24fe19b4e5dfc1..b5817524093944 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryState.h +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK index 6a5f2da93f54ee..749b0958532e6a 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK @@ -30,7 +30,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = APPLE, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -38,7 +41,7 @@ rn_xplat_cxx_library( ], visibility = ["PUBLIC"], deps = [ - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/components/view:view"), diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h index 089e3ff40cccee..4838a88d0926c8 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm index 8c44bc24653834..9b8e78b2dd6572 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,7 @@ #include "LegacyViewManagerInteropComponentDescriptor.h" #include +#include #include #include #include @@ -29,9 +30,6 @@ return "FBReactFDSTooltipViewManager"; } - if (componentName == "FBRotatablePhotoPlayer") { - return "FBRotatablePhotoPlayerViewManager"; - } std::string fbPrefix("FB"); if (std::mismatch(fbPrefix.begin(), fbPrefix.end(), componentName.begin()).first == fbPrefix.end()) { // If `moduleName` has "FB" prefix. @@ -43,6 +41,11 @@ return componentName + "Manager"; } + std::string rnPrefix("RN"); + if (std::mismatch(rnPrefix.begin(), rnPrefix.end(), componentName.begin()).first == rnPrefix.end()) { + return componentName + "Manager"; + } + return "RCT" + componentName + "Manager"; } @@ -71,11 +74,19 @@ eventDispatcher = unwrapManagedObject(optionalEventDispatcher.value()); } + auto optionalModuleDecorator = contextContainer->find>("RCTBridgeModuleDecorator"); + RCTBridgeModuleDecorator *bridgeModuleDecorator; + if (optionalModuleDecorator) { + bridgeModuleDecorator = unwrapManagedObject(optionalModuleDecorator.value()); + } + RCTComponentData *componentData = [[RCTComponentData alloc] initWithManagerClass:module bridge:bridge eventDispatcher:eventDispatcher]; - return wrapManagedObject([[RCTLegacyViewManagerInteropCoordinator alloc] initWithComponentData:componentData - bridge:bridge]); + return wrapManagedObject([[RCTLegacyViewManagerInteropCoordinator alloc] + initWithComponentData:componentData + bridge:bridge + bridgelessInteropData:bridgeModuleDecorator]); } LegacyViewManagerInteropComponentDescriptor::LegacyViewManagerInteropComponentDescriptor( diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.cpp index 53b8bf8f35225f..e99f7c390b5f67 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.h index 5667ed003f0054..da7b3691f74826 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.h index d416b0b23311e6..90b5cb8934fbbc 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.mm b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.mm index 4ded11fa5993d4..85ce2b0b5ac4e9 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.mm +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropState.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.cpp index 78ead212c36a84..39c0ec67043282 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.h index 8d0e0e29bb59b2..2a4abecfa9a623 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp index 4676a2c01e1b60..36771139bd9ec6 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h index b2645cd7de2d3b..fa684aab402e5e 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h index ca84249cae994e..242574f05ce781 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h @@ -1,11 +1,12 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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 +#import #import #include @@ -18,7 +19,9 @@ typedef void (^InterceptorBlock)(std::string eventName, folly::dynamic event); @interface RCTLegacyViewManagerInteropCoordinator : NSObject -- (instancetype)initWithComponentData:(RCTComponentData *)componentData bridge:(RCTBridge *)bridge; +- (instancetype)initWithComponentData:(RCTComponentData *)componentData + bridge:(RCTBridge *)bridge + bridgelessInteropData:(RCTBridgeModuleDecorator *)bridgelessInteropData; - (UIView *)createPaperViewWithTag:(NSInteger)tag; diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm index 60ac9786f6594a..02141cd4e1b9b9 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -25,6 +24,7 @@ @implementation RCTLegacyViewManagerInteropCoordinator { RCTComponentData *_componentData; __weak RCTBridge *_bridge; + __weak RCTBridgeModuleDecorator *_bridgelessInteropData; /* Each instance of `RCTLegacyViewManagerInteropComponentView` registers a block to which events are dispatched. This is the container that maps unretained UIView pointer to a block to which the event is dispatched. @@ -39,11 +39,20 @@ @implementation RCTLegacyViewManagerInteropCoordinator { NSMutableDictionary> *_moduleMethodsByName; } -- (instancetype)initWithComponentData:(RCTComponentData *)componentData bridge:(RCTBridge *)bridge +- (instancetype)initWithComponentData:(RCTComponentData *)componentData + bridge:(RCTBridge *)bridge + bridgelessInteropData:(RCTBridgeModuleDecorator *)bridgelessInteropData; { if (self = [super init]) { _componentData = componentData; _bridge = bridge; + _bridgelessInteropData = bridgelessInteropData; + if (bridgelessInteropData) { + // During bridge mode, RCTBridgeModules will be decorated with these APIs by the bridge. + RCTAssert( + _bridge == nil, + @"RCTLegacyViewManagerInteropCoordinator should not be intialized with RCTBridgeModuleDecorator in bridge mode."); + } _eventInterceptors = [NSMutableDictionary new]; @@ -74,20 +83,16 @@ - (void)removeObserveForTag:(NSInteger)tag - (UIView *)createPaperViewWithTag:(NSInteger)tag; { UIView *view = [_componentData createViewWithTag:[NSNumber numberWithInteger:tag] rootTag:NULL]; - if ([_componentData.bridgelessViewManager conformsToProtocol:@protocol(RCTWeakViewHolder)]) { - id weakViewHolder = (id)_componentData.bridgelessViewManager; - if (!weakViewHolder.weakViews) { - weakViewHolder.weakViews = [NSMapTable strongToWeakObjectsMapTable]; - } - [weakViewHolder.weakViews setObject:view forKey:[NSNumber numberWithInteger:tag]]; - } + [_bridgelessInteropData attachInteropAPIsToModule:(id)_componentData.bridgelessViewManager]; return view; } - (void)setProps:(folly::dynamic const &)props forView:(UIView *)view { - NSDictionary *convertedProps = convertFollyDynamicToId(props); - [_componentData setProps:convertedProps forView:view]; + if (props.isObject()) { + NSDictionary *convertedProps = convertFollyDynamicToId(props); + [_componentData setProps:convertedProps forView:view]; + } } - (NSString *)componentViewName diff --git a/ReactCommon/react/renderer/components/modal/Android.mk b/ReactCommon/react/renderer/components/modal/Android.mk deleted file mode 100644 index cd0a046e73204b..00000000000000 --- a/ReactCommon/react/renderer/components/modal/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_modal - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_image libreact_render_uimanager libreact_render_imagemanager librrc_view libreact_render_componentregistry libreact_codegen_rncore libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/modal/BUCK b/ReactCommon/react/renderer/components/modal/BUCK index 10c9e229be2d04..fb7ccbc840daa4 100644 --- a/ReactCommon/react/renderer/components/modal/BUCK +++ b/ReactCommon/react/renderer/components/modal/BUCK @@ -57,7 +57,10 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/modal", ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -68,7 +71,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/modal/CMakeLists.txt b/ReactCommon/react/renderer/components/modal/CMakeLists.txt new file mode 100644 index 00000000000000..8f596972539756 --- /dev/null +++ b/ReactCommon/react/renderer/components/modal/CMakeLists.txt @@ -0,0 +1,31 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_modal_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_modal STATIC ${rrc_modal_SRC}) + +target_include_directories(rrc_modal PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_modal + glog + folly_runtime + glog_init + react_codegen_rncore + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_imagemanager + react_render_mapbuffer + react_render_uimanager + rrc_image + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h index c1130183ad142e..0ff4d14d9ac41d 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,7 +15,7 @@ namespace facebook { namespace react { /* - * Descriptor for component. + * Descriptor for component. */ class ModalHostViewComponentDescriptor final diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.cpp b/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.cpp index fffaf8047e9ed4..bdf59f88ca15e3 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.h b/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.h index ad02fd26aafdf4..5558e0ef1257bd 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.h +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,7 @@ namespace react { extern const char ModalHostViewComponentName[]; /* - * `ShadowNode` for component. + * `ShadowNode` for component. */ class ModalHostViewShadowNode final : public ConcreteViewShadowNode< ModalHostViewComponentName, diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewState.cpp b/ReactCommon/react/renderer/components/modal/ModalHostViewState.cpp index 2650613a75c56e..1105a3883eb3bf 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewState.cpp +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewState.h b/ReactCommon/react/renderer/components/modal/ModalHostViewState.h index b0921864ba7791..2afe22358d135b 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewState.h +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,7 +21,7 @@ namespace facebook { namespace react { /* - * State for component. + * State for component. */ class ModalHostViewState final { public: diff --git a/ReactCommon/react/renderer/components/progressbar/Android.mk b/ReactCommon/react/renderer/components/progressbar/Android.mk deleted file mode 100644 index b899b97badae11..00000000000000 --- a/ReactCommon/react/renderer/components/progressbar/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_progressbar - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/android/react/renderer/components/progressbar/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/android/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/progressbar/BUCK b/ReactCommon/react/renderer/components/progressbar/BUCK index b45bde96a1af2e..c255c2cd4ede89 100644 --- a/ReactCommon/react/renderer/components/progressbar/BUCK +++ b/ReactCommon/react/renderer/components/progressbar/BUCK @@ -65,7 +65,10 @@ rn_xplat_cxx_library( ios_srcs = glob( ["platform/ios/*.cpp"], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -75,7 +78,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/progressbar/CMakeLists.txt b/ReactCommon/react/renderer/components/progressbar/CMakeLists.txt new file mode 100644 index 00000000000000..c1bc726cf9ced2 --- /dev/null +++ b/ReactCommon/react/renderer/components/progressbar/CMakeLists.txt @@ -0,0 +1,34 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_progressbar_SRC CONFIGURE_DEPENDS android/react/renderer/components/progressbar/*.cpp) +add_library(rrc_progressbar STATIC ${rrc_progressbar_SRC}) + +target_include_directories(rrc_progressbar + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/android/ +) + +target_link_libraries(rrc_progressbar + glog + fbjni + folly_runtime + glog_init + react_codegen_rncore + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_uimanager + reactnativeutilsjni + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h index 9e012b91cc56ac..cd8ea2235156d3 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp index 9e4c2fdbe92a7d..71ce1f60798a89 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,7 @@ namespace react { Size AndroidProgressBarMeasurementsManager::measure( SurfaceId surfaceId, - AndroidProgressBarProps props, + AndroidProgressBarProps const &props, LayoutConstraints layoutConstraints) const { { std::lock_guard lock(mutex_); diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h index c2eb8191f77214..7755ed371619aa 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,7 +24,7 @@ class AndroidProgressBarMeasurementsManager { Size measure( SurfaceId surfaceId, - AndroidProgressBarProps props, + AndroidProgressBarProps const &props, LayoutConstraints layoutConstraints) const; private: diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp index 0ab3970a71fd37..3d7c97a4a03bcd 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.h index e13f547eb6632c..65d0de57cdbe64 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/conversions.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/conversions.h index cb70dc61169fb4..dc3c1474777461 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/conversions.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,7 +20,7 @@ inline folly::dynamic toDynamic(AndroidProgressBarProps const &props) { serializedProps["indeterminate"] = props.indeterminate; serializedProps["progress"] = props.progress; serializedProps["animating"] = props.animating; - serializedProps["color"] = toDynamic(props.color); + serializedProps["color"] = toAndroidRepr(props.color); serializedProps["testID"] = props.testID; return serializedProps; } diff --git a/ReactCommon/react/renderer/components/root/Android.mk b/ReactCommon/react/renderer/components/root/Android.mk deleted file mode 100644 index 8149fe3f02fde8..00000000000000 --- a/ReactCommon/react/renderer/components/root/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_root - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/root/BUCK b/ReactCommon/react/renderer/components/root/BUCK index 59cd4b32a0462c..69f2036924fe03 100644 --- a/ReactCommon/react/renderer/components/root/BUCK +++ b/ReactCommon/react/renderer/components/root/BUCK @@ -31,7 +31,10 @@ rn_xplat_cxx_library( ), fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -43,7 +46,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/root/CMakeLists.txt b/ReactCommon/react/renderer/components/root/CMakeLists.txt new file mode 100644 index 00000000000000..96b43b7498a485 --- /dev/null +++ b/ReactCommon/react/renderer/components/root/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_root_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_root SHARED ${rrc_root_SRC}) + +target_include_directories(rrc_root PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_root + folly_runtime + glog + glog_init + react_debug + react_render_core + react_render_debug + react_render_graphics + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/root/RootComponentDescriptor.h b/ReactCommon/react/renderer/components/root/RootComponentDescriptor.h index 7d8cb7b2b277eb..c031b7eeb35122 100644 --- a/ReactCommon/react/renderer/components/root/RootComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/root/RootComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/root/RootProps.cpp b/ReactCommon/react/renderer/components/root/RootProps.cpp index 3e14c8a73ad07c..47013f3c14e4f7 100644 --- a/ReactCommon/react/renderer/components/root/RootProps.cpp +++ b/ReactCommon/react/renderer/components/root/RootProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/root/RootProps.h b/ReactCommon/react/renderer/components/root/RootProps.h index d28f02837b93d7..6ba7952c495b37 100644 --- a/ReactCommon/react/renderer/components/root/RootProps.h +++ b/ReactCommon/react/renderer/components/root/RootProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/root/RootShadowNode.cpp b/ReactCommon/react/renderer/components/root/RootShadowNode.cpp index 5e611de8d61487..20380d422887ba 100644 --- a/ReactCommon/react/renderer/components/root/RootShadowNode.cpp +++ b/ReactCommon/react/renderer/components/root/RootShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/root/RootShadowNode.h b/ReactCommon/react/renderer/components/root/RootShadowNode.h index 8d88ec913389d8..aa6a5f8343d52e 100644 --- a/ReactCommon/react/renderer/components/root/RootShadowNode.h +++ b/ReactCommon/react/renderer/components/root/RootShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp b/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp index 66d67ee817ca86..659ce017f081fe 100644 --- a/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/safeareaview/BUCK b/ReactCommon/react/renderer/components/safeareaview/BUCK index fb85f5b0f07bdd..f0837d54ada75e 100644 --- a/ReactCommon/react/renderer/components/safeareaview/BUCK +++ b/ReactCommon/react/renderer/components/safeareaview/BUCK @@ -27,7 +27,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = APPLE, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h index ad10ca8b125ebe..de0dcb4a9057b5 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.cpp b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.cpp index a04bea2e5e6edd..e4b821d3141101 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h index 2a27f0ef227c38..c4b312d90aa165 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.cpp b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.cpp index 8824fbb15d71c5..2238b0793d85eb 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.cpp +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h index f64b1bb275b6bf..a2d272b8c6e08b 100644 --- a/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h +++ b/ReactCommon/react/renderer/components/safeareaview/SafeAreaViewState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/Android.mk b/ReactCommon/react/renderer/components/scrollview/Android.mk deleted file mode 100644 index 9b02ae73f04215..00000000000000 --- a/ReactCommon/react/renderer/components/scrollview/Android.mk +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_scrollview - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/scrollview/BUCK b/ReactCommon/react/renderer/components/scrollview/BUCK index d5c0d3f2468733..20d52e1e84c172 100644 --- a/ReactCommon/react/renderer/components/scrollview/BUCK +++ b/ReactCommon/react/renderer/components/scrollview/BUCK @@ -38,7 +38,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -50,7 +53,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/scrollview/CMakeLists.txt b/ReactCommon/react/renderer/components/scrollview/CMakeLists.txt new file mode 100644 index 00000000000000..92927ff967889c --- /dev/null +++ b/ReactCommon/react/renderer/components/scrollview/CMakeLists.txt @@ -0,0 +1,28 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_scrollview_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_scrollview SHARED ${rrc_scrollview_SRC}) + +target_include_directories(rrc_scrollview PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_scrollview + glog + folly_runtime + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_render_graphics + react_render_mapbuffer + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h b/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h index 0fab3ae8160e68..d1cdcfc995545b 100644 --- a/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h +++ b/ReactCommon/react/renderer/components/scrollview/RCTComponentViewHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewComponentDescriptor.h b/ReactCommon/react/renderer/components/scrollview/ScrollViewComponentDescriptor.h index 43b74b08dc335d..3f6dd76720bf2b 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp b/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp index a44150d2183fd6..c009fa42775de6 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -86,11 +86,11 @@ void ScrollViewEventEmitter::onMomentumScrollEnd( } void ScrollViewEventEmitter::dispatchScrollViewEvent( - const std::string &name, + std::string name, const ScrollViewMetrics &scrollViewMetrics, EventPriority priority) const { dispatchEvent( - name, + std::move(name), [scrollViewMetrics](jsi::Runtime &runtime) { return scrollViewMetricsPayload(runtime, scrollViewMetrics); }, diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h b/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h index 722731fdbbce21..39274ad2daaa6a 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -38,7 +38,7 @@ class ScrollViewEventEmitter : public ViewEventEmitter { private: void dispatchScrollViewEvent( - const std::string &name, + std::string name, const ScrollViewMetrics &scrollViewMetrics, EventPriority priority = EventPriority::AsynchronousBatched) const; }; diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.cpp b/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.cpp index 5ac1187937b288..ff1611d71fcbe0 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.cpp +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,204 +21,327 @@ ScrollViewProps::ScrollViewProps( ScrollViewProps const &sourceProps, RawProps const &rawProps) : ViewProps(context, sourceProps, rawProps), - alwaysBounceHorizontal(convertRawProp( - context, - rawProps, - "alwaysBounceHorizontal", - sourceProps.alwaysBounceHorizontal, - {})), - alwaysBounceVertical(convertRawProp( - context, - rawProps, - "alwaysBounceVertical", - sourceProps.alwaysBounceVertical, - {})), - bounces(convertRawProp( - context, - rawProps, - "bounces", - sourceProps.bounces, - true)), - bouncesZoom(convertRawProp( - context, - rawProps, - "bouncesZoom", - sourceProps.bouncesZoom, - true)), - canCancelContentTouches(convertRawProp( - context, - rawProps, - "canCancelContentTouches", - sourceProps.canCancelContentTouches, - true)), - centerContent(convertRawProp( - context, - rawProps, - "centerContent", - sourceProps.centerContent, - {})), - automaticallyAdjustContentInsets(convertRawProp( - context, - rawProps, - "automaticallyAdjustContentInsets", - sourceProps.automaticallyAdjustContentInsets, - {})), - automaticallyAdjustsScrollIndicatorInsets(convertRawProp( - context, - rawProps, - "automaticallyAdjustsScrollIndicatorInsets", - sourceProps.automaticallyAdjustsScrollIndicatorInsets, - true)), - decelerationRate(convertRawProp( - context, - rawProps, - "decelerationRate", - sourceProps.decelerationRate, - (Float)0.998)), - directionalLockEnabled(convertRawProp( - context, - rawProps, - "directionalLockEnabled", - sourceProps.directionalLockEnabled, - {})), - indicatorStyle(convertRawProp( - context, - rawProps, - "indicatorStyle", - sourceProps.indicatorStyle, - {})), - keyboardDismissMode(convertRawProp( - context, - rawProps, - "keyboardDismissMode", - sourceProps.keyboardDismissMode, - {})), - maximumZoomScale(convertRawProp( - context, - rawProps, - "maximumZoomScale", - sourceProps.maximumZoomScale, - (Float)1.0)), - minimumZoomScale(convertRawProp( - context, - rawProps, - "minimumZoomScale", - sourceProps.minimumZoomScale, - (Float)1.0)), - scrollEnabled(convertRawProp( - context, - rawProps, - "scrollEnabled", - sourceProps.scrollEnabled, - true)), - pagingEnabled(convertRawProp( - context, - rawProps, - "pagingEnabled", - sourceProps.pagingEnabled, - {})), - pinchGestureEnabled(convertRawProp( - context, - rawProps, - "pinchGestureEnabled", - sourceProps.pinchGestureEnabled, - true)), - scrollsToTop(convertRawProp( - context, - rawProps, - "scrollsToTop", - sourceProps.scrollsToTop, - true)), - showsHorizontalScrollIndicator(convertRawProp( - context, - rawProps, - "showsHorizontalScrollIndicator", - sourceProps.showsHorizontalScrollIndicator, - true)), - showsVerticalScrollIndicator(convertRawProp( - context, - rawProps, - "showsVerticalScrollIndicator", - sourceProps.showsVerticalScrollIndicator, - true)), - scrollEventThrottle(convertRawProp( - context, - rawProps, - "scrollEventThrottle", - sourceProps.scrollEventThrottle, - {})), - zoomScale(convertRawProp( - context, - rawProps, - "zoomScale", - sourceProps.zoomScale, - (Float)1.0)), - contentInset(convertRawProp( - context, - rawProps, - "contentInset", - sourceProps.contentInset, - {})), - contentOffset(convertRawProp( - context, - rawProps, - "contentOffset", - sourceProps.contentOffset, - {})), - scrollIndicatorInsets(convertRawProp( - context, - rawProps, - "scrollIndicatorInsets", - sourceProps.scrollIndicatorInsets, - {})), - snapToInterval(convertRawProp( - context, - rawProps, - "snapToInterval", - sourceProps.snapToInterval, - {})), - snapToAlignment(convertRawProp( - context, - rawProps, - "snapToAlignment", - sourceProps.snapToAlignment, - {})), - disableIntervalMomentum(convertRawProp( - context, - rawProps, - "disableIntervalMomentum", - sourceProps.disableIntervalMomentum, - {})), - snapToOffsets(convertRawProp( - context, - rawProps, - "snapToOffsets", - sourceProps.snapToOffsets, - {})), - snapToStart(convertRawProp( - context, - rawProps, - "snapToStart", - sourceProps.snapToStart, - true)), - snapToEnd(convertRawProp( - context, - rawProps, - "snapToEnd", - sourceProps.snapToEnd, - true)), - contentInsetAdjustmentBehavior(convertRawProp( - context, - rawProps, - "contentInsetAdjustmentBehavior", - sourceProps.contentInsetAdjustmentBehavior, - {ContentInsetAdjustmentBehavior::Never})), - scrollToOverflowEnabled(convertRawProp( - context, - rawProps, - "scrollToOverflowEnabled", - sourceProps.scrollToOverflowEnabled, - {})) {} + alwaysBounceHorizontal( + Props::enablePropIteratorSetter + ? sourceProps.alwaysBounceHorizontal + : convertRawProp( + context, + rawProps, + "alwaysBounceHorizontal", + sourceProps.alwaysBounceHorizontal, + {})), + alwaysBounceVertical( + Props::enablePropIteratorSetter + ? sourceProps.alwaysBounceVertical + : convertRawProp( + context, + rawProps, + "alwaysBounceVertical", + sourceProps.alwaysBounceVertical, + {})), + bounces( + Props::enablePropIteratorSetter ? sourceProps.bounces + : convertRawProp( + context, + rawProps, + "bounces", + sourceProps.bounces, + true)), + bouncesZoom( + Props::enablePropIteratorSetter ? sourceProps.bouncesZoom + : convertRawProp( + context, + rawProps, + "bouncesZoom", + sourceProps.bouncesZoom, + true)), + canCancelContentTouches( + Props::enablePropIteratorSetter + ? sourceProps.canCancelContentTouches + : convertRawProp( + context, + rawProps, + "canCancelContentTouches", + sourceProps.canCancelContentTouches, + true)), + centerContent( + Props::enablePropIteratorSetter ? sourceProps.centerContent + : convertRawProp( + context, + rawProps, + "centerContent", + sourceProps.centerContent, + {})), + automaticallyAdjustContentInsets( + Props::enablePropIteratorSetter + ? sourceProps.automaticallyAdjustContentInsets + : convertRawProp( + context, + rawProps, + "automaticallyAdjustContentInsets", + sourceProps.automaticallyAdjustContentInsets, + {})), + automaticallyAdjustsScrollIndicatorInsets( + Props::enablePropIteratorSetter + ? sourceProps.automaticallyAdjustsScrollIndicatorInsets + : convertRawProp( + context, + rawProps, + "automaticallyAdjustsScrollIndicatorInsets", + sourceProps.automaticallyAdjustsScrollIndicatorInsets, + true)), + decelerationRate( + Props::enablePropIteratorSetter ? sourceProps.decelerationRate + : convertRawProp( + context, + rawProps, + "decelerationRate", + sourceProps.decelerationRate, + (Float)0.998)), + directionalLockEnabled( + Props::enablePropIteratorSetter + ? sourceProps.directionalLockEnabled + : convertRawProp( + context, + rawProps, + "directionalLockEnabled", + sourceProps.directionalLockEnabled, + {})), + indicatorStyle( + Props::enablePropIteratorSetter ? sourceProps.indicatorStyle + : convertRawProp( + context, + rawProps, + "indicatorStyle", + sourceProps.indicatorStyle, + {})), + keyboardDismissMode( + Props::enablePropIteratorSetter ? sourceProps.keyboardDismissMode + : convertRawProp( + context, + rawProps, + "keyboardDismissMode", + sourceProps.keyboardDismissMode, + {})), + maximumZoomScale( + Props::enablePropIteratorSetter ? sourceProps.maximumZoomScale + : convertRawProp( + context, + rawProps, + "maximumZoomScale", + sourceProps.maximumZoomScale, + (Float)1.0)), + minimumZoomScale( + Props::enablePropIteratorSetter ? sourceProps.minimumZoomScale + : convertRawProp( + context, + rawProps, + "minimumZoomScale", + sourceProps.minimumZoomScale, + (Float)1.0)), + scrollEnabled( + Props::enablePropIteratorSetter ? sourceProps.scrollEnabled + : convertRawProp( + context, + rawProps, + "scrollEnabled", + sourceProps.scrollEnabled, + true)), + pagingEnabled( + Props::enablePropIteratorSetter ? sourceProps.pagingEnabled + : convertRawProp( + context, + rawProps, + "pagingEnabled", + sourceProps.pagingEnabled, + {})), + pinchGestureEnabled( + Props::enablePropIteratorSetter ? sourceProps.pinchGestureEnabled + : convertRawProp( + context, + rawProps, + "pinchGestureEnabled", + sourceProps.pinchGestureEnabled, + true)), + scrollsToTop( + Props::enablePropIteratorSetter ? sourceProps.scrollsToTop + : convertRawProp( + context, + rawProps, + "scrollsToTop", + sourceProps.scrollsToTop, + true)), + showsHorizontalScrollIndicator( + Props::enablePropIteratorSetter + ? sourceProps.showsHorizontalScrollIndicator + : convertRawProp( + context, + rawProps, + "showsHorizontalScrollIndicator", + sourceProps.showsHorizontalScrollIndicator, + true)), + showsVerticalScrollIndicator( + Props::enablePropIteratorSetter + ? sourceProps.showsVerticalScrollIndicator + : convertRawProp( + context, + rawProps, + "showsVerticalScrollIndicator", + sourceProps.showsVerticalScrollIndicator, + true)), + scrollEventThrottle( + Props::enablePropIteratorSetter ? sourceProps.scrollEventThrottle + : convertRawProp( + context, + rawProps, + "scrollEventThrottle", + sourceProps.scrollEventThrottle, + {})), + zoomScale( + Props::enablePropIteratorSetter ? sourceProps.zoomScale + : convertRawProp( + context, + rawProps, + "zoomScale", + sourceProps.zoomScale, + (Float)1.0)), + contentInset( + Props::enablePropIteratorSetter ? sourceProps.contentInset + : convertRawProp( + context, + rawProps, + "contentInset", + sourceProps.contentInset, + {})), + contentOffset( + Props::enablePropIteratorSetter ? sourceProps.contentOffset + : convertRawProp( + context, + rawProps, + "contentOffset", + sourceProps.contentOffset, + {})), + scrollIndicatorInsets( + Props::enablePropIteratorSetter + ? sourceProps.scrollIndicatorInsets + : convertRawProp( + context, + rawProps, + "scrollIndicatorInsets", + sourceProps.scrollIndicatorInsets, + {})), + snapToInterval( + Props::enablePropIteratorSetter ? sourceProps.snapToInterval + : convertRawProp( + context, + rawProps, + "snapToInterval", + sourceProps.snapToInterval, + {})), + snapToAlignment( + Props::enablePropIteratorSetter ? sourceProps.snapToAlignment + : convertRawProp( + context, + rawProps, + "snapToAlignment", + sourceProps.snapToAlignment, + {})), + disableIntervalMomentum( + Props::enablePropIteratorSetter + ? sourceProps.disableIntervalMomentum + : convertRawProp( + context, + rawProps, + "disableIntervalMomentum", + sourceProps.disableIntervalMomentum, + {})), + snapToOffsets( + Props::enablePropIteratorSetter ? sourceProps.snapToOffsets + : convertRawProp( + context, + rawProps, + "snapToOffsets", + sourceProps.snapToOffsets, + {})), + snapToStart( + Props::enablePropIteratorSetter ? sourceProps.snapToStart + : convertRawProp( + context, + rawProps, + "snapToStart", + sourceProps.snapToStart, + true)), + snapToEnd( + Props::enablePropIteratorSetter ? sourceProps.snapToEnd + : convertRawProp( + context, + rawProps, + "snapToEnd", + sourceProps.snapToEnd, + true)), + contentInsetAdjustmentBehavior( + Props::enablePropIteratorSetter + ? sourceProps.contentInsetAdjustmentBehavior + : convertRawProp( + context, + rawProps, + "contentInsetAdjustmentBehavior", + sourceProps.contentInsetAdjustmentBehavior, + {ContentInsetAdjustmentBehavior::Never})), + scrollToOverflowEnabled( + Props::enablePropIteratorSetter + ? sourceProps.scrollToOverflowEnabled + : convertRawProp( + context, + rawProps, + "scrollToOverflowEnabled", + sourceProps.scrollToOverflowEnabled, + {})) {} + +void ScrollViewProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + ViewProps::setProp(context, hash, propName, value); + switch (hash) { + RAW_SET_PROP_SWITCH_CASE_BASIC(alwaysBounceHorizontal, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(alwaysBounceVertical, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(bounces, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(bouncesZoom, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(canCancelContentTouches, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(centerContent, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(automaticallyAdjustContentInsets, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC( + automaticallyAdjustsScrollIndicatorInsets, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(decelerationRate, (Float)0.998); + RAW_SET_PROP_SWITCH_CASE_BASIC(directionalLockEnabled, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(indicatorStyle, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(keyboardDismissMode, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(maximumZoomScale, (Float)1.0); + RAW_SET_PROP_SWITCH_CASE_BASIC(minimumZoomScale, (Float)1.0); + RAW_SET_PROP_SWITCH_CASE_BASIC(scrollEnabled, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(pagingEnabled, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(pinchGestureEnabled, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(scrollsToTop, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(showsHorizontalScrollIndicator, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(showsVerticalScrollIndicator, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(scrollEventThrottle, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(zoomScale, (Float)1.0); + RAW_SET_PROP_SWITCH_CASE_BASIC(contentInset, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(contentOffset, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(scrollIndicatorInsets, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(snapToInterval, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(snapToAlignment, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(disableIntervalMomentum, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(snapToOffsets, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(snapToStart, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(snapToEnd, true); + RAW_SET_PROP_SWITCH_CASE_BASIC( + contentInsetAdjustmentBehavior, ContentInsetAdjustmentBehavior::Never); + RAW_SET_PROP_SWITCH_CASE_BASIC(scrollToOverflowEnabled, {}); + } +} #pragma mark - DebugStringConvertible diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.h b/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.h index 2e83cb16a19fde..bd53bc4bb22def 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.h +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -23,6 +23,12 @@ class ScrollViewProps final : public ViewProps { ScrollViewProps const &sourceProps, RawProps const &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + #pragma mark - Props bool alwaysBounceHorizontal{}; diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp b/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp index 09c860740f3224..41ddcdb4175f0f 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h b/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h index f4d4a5f964bbc7..c34367e8c55b69 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewState.cpp b/ReactCommon/react/renderer/components/scrollview/ScrollViewState.cpp index 6f368957a6e8fd..4bbfaa4a3e5cd6 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewState.cpp +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/ScrollViewState.h b/ReactCommon/react/renderer/components/scrollview/ScrollViewState.h index 6d3dd7e632525f..d0846baecc6f69 100644 --- a/ReactCommon/react/renderer/components/scrollview/ScrollViewState.h +++ b/ReactCommon/react/renderer/components/scrollview/ScrollViewState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/conversions.h b/ReactCommon/react/renderer/components/scrollview/conversions.h index 710bd8f3b07de9..4605f08ea203dd 100644 --- a/ReactCommon/react/renderer/components/scrollview/conversions.h +++ b/ReactCommon/react/renderer/components/scrollview/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/primitives.h b/ReactCommon/react/renderer/components/scrollview/primitives.h index 03cfd90c6ff079..fe8a60e21d7c0d 100644 --- a/ReactCommon/react/renderer/components/scrollview/primitives.h +++ b/ReactCommon/react/renderer/components/scrollview/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewTest.cpp b/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewTest.cpp index 87313e585e483b..1b64ed7ac06c46 100644 --- a/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewTest.cpp +++ b/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/Android.mk b/ReactCommon/react/renderer/components/slider/Android.mk deleted file mode 100644 index 101ed6ee564c16..00000000000000 --- a/ReactCommon/react/renderer/components/slider/Android.mk +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_slider - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/platform/android/react/renderer/components/slider/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/platform/android/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreact_render_imagemanager libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager librrc_image libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/slider/BUCK b/ReactCommon/react/renderer/components/slider/BUCK index 01ac302615e742..59bd982faeee4e 100644 --- a/ReactCommon/react/renderer/components/slider/BUCK +++ b/ReactCommon/react/renderer/components/slider/BUCK @@ -67,7 +67,10 @@ rn_xplat_cxx_library( ios_srcs = glob( ["platform/ios/*.cpp"], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -75,7 +78,7 @@ rn_xplat_cxx_library( ], visibility = ["PUBLIC"], deps = [ - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:molly", YOGA_CXX_TARGET, react_native_xplat_target("react/debug:debug"), diff --git a/ReactCommon/react/renderer/components/slider/CMakeLists.txt b/ReactCommon/react/renderer/components/slider/CMakeLists.txt new file mode 100644 index 00000000000000..059ece7daded82 --- /dev/null +++ b/ReactCommon/react/renderer/components/slider/CMakeLists.txt @@ -0,0 +1,38 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_slider_SRC CONFIGURE_DEPENDS *.cpp platform/android/react/renderer/components/slider/*.cpp) +add_library(rrc_slider STATIC ${rrc_slider_SRC}) + +target_include_directories(rrc_slider + PUBLIC + ${REACT_COMMON_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/platform/android/ +) + +target_link_libraries(rrc_slider + glog + fbjni + folly_runtime + glog_init + react_codegen_rncore + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_imagemanager + react_render_mapbuffer + react_render_uimanager + reactnativeutilsjni + rrc_image + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h index c167f68fa48cbe..8a4d592c3ff0dd 100644 --- a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp index 15803f26f3de52..094389801734b7 100644 --- a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp +++ b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/SliderShadowNode.h b/ReactCommon/react/renderer/components/slider/SliderShadowNode.h index ebd2eca0483606..b1aa0dc9c5fc90 100644 --- a/ReactCommon/react/renderer/components/slider/SliderShadowNode.h +++ b/ReactCommon/react/renderer/components/slider/SliderShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/SliderState.cpp b/ReactCommon/react/renderer/components/slider/SliderState.cpp index 348d372d9a293a..c27e7139cd0501 100644 --- a/ReactCommon/react/renderer/components/slider/SliderState.cpp +++ b/ReactCommon/react/renderer/components/slider/SliderState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/SliderState.h b/ReactCommon/react/renderer/components/slider/SliderState.h index 82a338c08f24ee..7984a657088ab9 100644 --- a/ReactCommon/react/renderer/components/slider/SliderState.h +++ b/ReactCommon/react/renderer/components/slider/SliderState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.cpp b/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.cpp index 24bc977fbad790..07119bd68a3160 100644 --- a/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.h b/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.h index 19ba0c4f7de293..a8234ae6aea366 100644 --- a/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.h +++ b/ReactCommon/react/renderer/components/slider/platform/android/react/renderer/components/slider/SliderMeasurementsManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp index d23aff739c7aff..773d3f7bbeec35 100644 --- a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.h b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.h index f78ff2bb2704ca..067deeadff5b5c 100644 --- a/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.h +++ b/ReactCommon/react/renderer/components/slider/platform/ios/SliderMeasurementsManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/slider/tests/SliderTest.cpp b/ReactCommon/react/renderer/components/slider/tests/SliderTest.cpp index ea1923f5665867..5bb020e65b714a 100644 --- a/ReactCommon/react/renderer/components/slider/tests/SliderTest.cpp +++ b/ReactCommon/react/renderer/components/slider/tests/SliderTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/switch/Android.mk b/ReactCommon/react/renderer/components/switch/Android.mk deleted file mode 100644 index ec7b041a63e247..00000000000000 --- a/ReactCommon/react/renderer/components/switch/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_switch - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/androidswitch/react/renderer/components/androidswitch/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/androidswitch/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/androidswitch/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libfbjni libreact_codegen_rncore libreactnativeutilsjni libreact_render_componentregistry libreact_render_uimanager libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/switch/BUCK b/ReactCommon/react/renderer/components/switch/BUCK index 82ca7c4074eae0..33d4f9170377d8 100644 --- a/ReactCommon/react/renderer/components/switch/BUCK +++ b/ReactCommon/react/renderer/components/switch/BUCK @@ -41,7 +41,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -51,7 +54,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/switch/CMakeLists.txt b/ReactCommon/react/renderer/components/switch/CMakeLists.txt new file mode 100644 index 00000000000000..f4a251343f978c --- /dev/null +++ b/ReactCommon/react/renderer/components/switch/CMakeLists.txt @@ -0,0 +1,44 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) + +file(GLOB rrc_switch_SRCS CONFIGURE_DEPENDS androidswitch/react/renderer/components/androidswitch/*.cpp) + +add_library( + rrc_switch + STATIC + ${rrc_switch_SRCS} +) + +target_include_directories(rrc_switch PUBLIC androidswitch/) + +target_link_libraries( + rrc_switch + glog + fbjni + folly_runtime + glog_init + react_codegen_rncore + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_uimanager + reactnativeutilsjni + rrc_view + yoga +) + +target_compile_options( + rrc_switch + PRIVATE + -DLOG_TAG=\"Fabric\" + -fexceptions + -frtti + -std=c++17 + -Wall +) diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h index b253baf1718314..aefde23b9c9a9e 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.cpp b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.cpp index 1d8d53e9c16d97..7a683eecc0324a 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.cpp +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.h b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.h index 1d7672df504e1f..ebf7eaea64c41b 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.h +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp index 53667c313a3bf8..4dca3fbda46dda 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.h b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.h index f002902dd64456..4b990444147754 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.h +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/Android.mk b/ReactCommon/react/renderer/components/text/Android.mk deleted file mode 100644 index 33bfdb78a96362..00000000000000 --- a/ReactCommon/react/renderer/components/text/Android.mk +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_text - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_textlayoutmanager libreact_render_attributedstring libreact_render_mounting librrc_view libreact_utils libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/textlayoutmanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/view) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/renderer/mapbuffer) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/text/BUCK b/ReactCommon/react/renderer/components/text/BUCK index 47f41977a119eb..00e9e735d35c66 100644 --- a/ReactCommon/react/renderer/components/text/BUCK +++ b/ReactCommon/react/renderer/components/text/BUCK @@ -43,7 +43,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -54,7 +57,7 @@ rn_xplat_cxx_library( "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", "//xplat/folly:container_evicting_cache_map", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 73590497435173..e93c000d1b2cbf 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,35 +12,41 @@ #include #include +#define GET_FIELD_VALUE(field, fieldName, defaultValue, rawValue) \ + (rawValue.hasValue() ? ({ \ + decltype(defaultValue) res; \ + fromRawValue(context, rawValue, res); \ + res; \ + }) \ + : defaultValue) + +#define REBUILD_FIELD_SWITCH_CASE( \ + defaults, rawValue, property, field, fieldName) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \ + property.field = \ + GET_FIELD_VALUE(field, fieldName, defaults.field, rawValue); \ + return; \ + } + namespace facebook { namespace react { +bool BaseTextProps::enablePropIteratorSetter = false; + static TextAttributes convertRawProp( - const PropsParserContext &context, - const RawProps &rawProps, - const TextAttributes sourceTextAttributes, - const TextAttributes defaultTextAttributes) { + PropsParserContext const &context, + RawProps const &rawProps, + TextAttributes const &sourceTextAttributes, + TextAttributes const &defaultTextAttributes) { auto textAttributes = TextAttributes{}; - // Color + // Color (not accessed by ViewProps) textAttributes.foregroundColor = convertRawProp( context, rawProps, "color", sourceTextAttributes.foregroundColor, defaultTextAttributes.foregroundColor); - textAttributes.backgroundColor = convertRawProp( - context, - rawProps, - "backgroundColor", - sourceTextAttributes.backgroundColor, - defaultTextAttributes.backgroundColor); - textAttributes.opacity = convertRawProp( - context, - rawProps, - "opacity", - sourceTextAttributes.opacity, - defaultTextAttributes.opacity); // Font textAttributes.fontFamily = convertRawProp( @@ -166,6 +172,16 @@ static TextAttributes convertRawProp( sourceTextAttributes.isHighlighted, defaultTextAttributes.isHighlighted); + // In general, we want this class to access props in the same order + // that ViewProps accesses them in, so that RawPropParser can optimize + // accesses. This is both theoretical, and ParagraphProps takes advantage + // of this. + // In particular: accessibilityRole, opacity, and backgroundColor also + // are parsed first by ViewProps (and indirectly AccessibilityProps). + // However, since RawPropsParser will always store these props /before/ + // the unique BaseTextProps props, it is most efficient to parse these, in + // order, /after/ all of the other BaseTextProps, so that the RawPropsParser + // index rolls over only once instead of twice. textAttributes.accessibilityRole = convertRawProp( context, rawProps, @@ -173,6 +189,20 @@ static TextAttributes convertRawProp( sourceTextAttributes.accessibilityRole, defaultTextAttributes.accessibilityRole); + // Color (accessed in this order by ViewProps) + textAttributes.opacity = convertRawProp( + context, + rawProps, + "opacity", + sourceTextAttributes.opacity, + defaultTextAttributes.opacity); + textAttributes.backgroundColor = convertRawProp( + context, + rawProps, + "backgroundColor", + sourceTextAttributes.backgroundColor, + defaultTextAttributes.backgroundColor); + return textAttributes; } @@ -180,11 +210,95 @@ BaseTextProps::BaseTextProps( const PropsParserContext &context, const BaseTextProps &sourceProps, const RawProps &rawProps) - : textAttributes(convertRawProp( - context, - rawProps, - sourceProps.textAttributes, - TextAttributes{})){}; + : textAttributes( + BaseTextProps::enablePropIteratorSetter + ? sourceProps.textAttributes + : convertRawProp( + context, + rawProps, + sourceProps.textAttributes, + TextAttributes{})){}; + +void BaseTextProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + static auto defaults = TextAttributes{}; + + switch (hash) { + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, foregroundColor, "color"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, fontFamily, "fontFamily"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, fontSize, "fontSize"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + fontSizeMultiplier, + "fontSizeMultiplier"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, fontWeight, "fontWeight"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, fontStyle, "fontStyle"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, fontVariant, "fontVariant"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, allowFontScaling, "allowFontScaling"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, letterSpacing, "letterSpacing"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, textTransform, "textTransform"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, lineHeight, "lineHeight"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, alignment, "textAlign"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + baseWritingDirection, + "baseWritingDirection"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + textDecorationColor, + "textDecorationColor"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + textDecorationLineType, + "textDecorationLine"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + textDecorationStyle, + "textDecorationStyle"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, textShadowOffset, "textShadowOffset"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, textShadowRadius, "textShadowRadius"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, textShadowColor, "textShadowColor"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, isHighlighted, "isHighlighted"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + accessibilityRole, + "accessibilityRole"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, opacity, "opacity"); + REBUILD_FIELD_SWITCH_CASE( + defaults, value, textAttributes, backgroundColor, "backgroundColor"); + } +} #pragma mark - DebugStringConvertible diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.h b/ReactCommon/react/renderer/components/text/BaseTextProps.h index c20d07b6c3e28e..092ff27c963927 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.h +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -28,6 +28,14 @@ class BaseTextProps { const BaseTextProps &sourceProps, const RawProps &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + + static bool enablePropIteratorSetter; + #pragma mark - Props TextAttributes textAttributes{}; diff --git a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp index a68e2dca773cae..054bdeb14fbe09 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.h b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.h index 49d8733645c874..17a29b1e769d5c 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.h +++ b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/CMakeLists.txt b/ReactCommon/react/renderer/components/text/CMakeLists.txt new file mode 100644 index 00000000000000..392d76171b476e --- /dev/null +++ b/ReactCommon/react/renderer/components/text/CMakeLists.txt @@ -0,0 +1,33 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_text_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_text SHARED ${rrc_text_SRC}) + +target_include_directories(rrc_text PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_text + glog + folly_runtime + glog_init + jsi + react_debug + react_render_attributedstring + react_render_core + react_render_debug + react_render_graphics + react_render_mapbuffer + react_render_mounting + react_render_textlayoutmanager + react_render_uimanager + react_utils + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h index 0801a07b8d1225..2909ebbc57a4ca 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -41,7 +41,7 @@ class ParagraphComponentDescriptor final } private: - SharedTextLayoutManager textLayoutManager_; + std::shared_ptr textLayoutManager_; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.cpp b/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.cpp index ee16f5d02655c9..3ea125167594f1 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.h b/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.h index 597ef6baa2ddcb..c7e306d75edcd9 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.h +++ b/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/ParagraphProps.cpp b/ReactCommon/react/renderer/components/text/ParagraphProps.cpp index 632da3bdcd1a76..0ecf15bab4f9c0 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphProps.cpp +++ b/ReactCommon/react/renderer/components/text/ParagraphProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -48,6 +48,25 @@ ParagraphProps::ParagraphProps( textAttributes.backgroundColor = {}; }; +void ParagraphProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + // All Props structs setProp methods must always, unconditionally, + // call all super::setProp methods, since multiple structs may + // reuse the same values. + ViewProps::setProp(context, hash, propName, value); + BaseTextProps::setProp(context, hash, propName, value); + + /* + * These props are applied to `View`, therefore they must not be a part of + * base text attributes. + */ + textAttributes.opacity = std::numeric_limits::quiet_NaN(); + textAttributes.backgroundColor = {}; +} + #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE diff --git a/ReactCommon/react/renderer/components/text/ParagraphProps.h b/ReactCommon/react/renderer/components/text/ParagraphProps.h index a82bbb8eb4bd2b..b73ad0f2a4620b 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphProps.h +++ b/ReactCommon/react/renderer/components/text/ParagraphProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -32,6 +32,12 @@ class ParagraphProps : public ViewProps, public BaseTextProps { ParagraphProps const &sourceProps, RawProps const &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + #pragma mark - Props /* diff --git a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp index 46f4098784165c..7c42ae7672e122 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -93,9 +93,9 @@ Content ParagraphShadowNode::getContentWithMeasuredAttachments( } void ParagraphShadowNode::setTextLayoutManager( - SharedTextLayoutManager textLayoutManager) { + std::shared_ptr textLayoutManager) { ensureUnsealed(); - textLayoutManager_ = textLayoutManager; + textLayoutManager_ = std::move(textLayoutManager); } void ParagraphShadowNode::updateStateIfNeeded(Content const &content) { diff --git a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h index 5bd8c1b1085caa..42ef650a3cf842 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h +++ b/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -57,7 +57,8 @@ class ParagraphShadowNode final : public ConcreteViewShadowNode< * `ParagraphShadowNode` uses the manager to measure text content * and construct `ParagraphState` objects. */ - void setTextLayoutManager(SharedTextLayoutManager textLayoutManager); + void setTextLayoutManager( + std::shared_ptr textLayoutManager); #pragma mark - LayoutableShadowNode @@ -96,12 +97,12 @@ class ParagraphShadowNode final : public ConcreteViewShadowNode< */ void updateStateIfNeeded(Content const &content); - SharedTextLayoutManager textLayoutManager_; + std::shared_ptr textLayoutManager_; /* * Cached content of the subtree started from the node. */ - mutable better::optional content_{}; + mutable std::optional content_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/text/ParagraphState.cpp b/ReactCommon/react/renderer/components/text/ParagraphState.cpp index 5c15d2a31e6492..aa5ca1a8b393af 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphState.cpp +++ b/ReactCommon/react/renderer/components/text/ParagraphState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/ParagraphState.h b/ReactCommon/react/renderer/components/text/ParagraphState.h index d4e80fda9cd7c7..76dcbcf1cee0c5 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphState.h +++ b/ReactCommon/react/renderer/components/text/ParagraphState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/RawTextComponentDescriptor.h b/ReactCommon/react/renderer/components/text/RawTextComponentDescriptor.h index 5a437ec89612b4..163bdb5c600771 100644 --- a/ReactCommon/react/renderer/components/text/RawTextComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/text/RawTextComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/RawTextProps.cpp b/ReactCommon/react/renderer/components/text/RawTextProps.cpp index 3660824907f04a..40e49859d29a7f 100644 --- a/ReactCommon/react/renderer/components/text/RawTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/RawTextProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/RawTextProps.h b/ReactCommon/react/renderer/components/text/RawTextProps.h index 2516e99b1c4984..7d448b374db097 100644 --- a/ReactCommon/react/renderer/components/text/RawTextProps.h +++ b/ReactCommon/react/renderer/components/text/RawTextProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/RawTextShadowNode.cpp b/ReactCommon/react/renderer/components/text/RawTextShadowNode.cpp index 13a15e29f6933e..55ee95cc2a85d2 100644 --- a/ReactCommon/react/renderer/components/text/RawTextShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/RawTextShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/RawTextShadowNode.h b/ReactCommon/react/renderer/components/text/RawTextShadowNode.h index 8dbde86c996e93..11cda560918884 100644 --- a/ReactCommon/react/renderer/components/text/RawTextShadowNode.h +++ b/ReactCommon/react/renderer/components/text/RawTextShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/TextComponentDescriptor.h b/ReactCommon/react/renderer/components/text/TextComponentDescriptor.h index 12e6b54512e145..85612690049e9b 100644 --- a/ReactCommon/react/renderer/components/text/TextComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/text/TextComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/TextProps.cpp b/ReactCommon/react/renderer/components/text/TextProps.cpp index 8e4bc4b0a6e944..a8b83aa0b1b3fa 100644 --- a/ReactCommon/react/renderer/components/text/TextProps.cpp +++ b/ReactCommon/react/renderer/components/text/TextProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,15 @@ TextProps::TextProps( : Props(context, sourceProps, rawProps), BaseTextProps::BaseTextProps(context, sourceProps, rawProps){}; +void TextProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + BaseTextProps::setProp(context, hash, propName, value); + Props::setProp(context, hash, propName, value); +} + #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE diff --git a/ReactCommon/react/renderer/components/text/TextProps.h b/ReactCommon/react/renderer/components/text/TextProps.h index 9903b05e0d711e..53df63702b10c5 100644 --- a/ReactCommon/react/renderer/components/text/TextProps.h +++ b/ReactCommon/react/renderer/components/text/TextProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,6 +25,12 @@ class TextProps : public Props, public BaseTextProps { const TextProps &sourceProps, const RawProps &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE diff --git a/ReactCommon/react/renderer/components/text/TextShadowNode.cpp b/ReactCommon/react/renderer/components/text/TextShadowNode.cpp index 3ae356c491c469..561ddcb9475ee4 100644 --- a/ReactCommon/react/renderer/components/text/TextShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/TextShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/TextShadowNode.h b/ReactCommon/react/renderer/components/text/TextShadowNode.h index 57e3f25076ba23..cefad90615133c 100644 --- a/ReactCommon/react/renderer/components/text/TextShadowNode.h +++ b/ReactCommon/react/renderer/components/text/TextShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/conversions.h b/ReactCommon/react/renderer/components/text/conversions.h index 8ea5baeddb7978..712b8f2fde2325 100644 --- a/ReactCommon/react/renderer/components/text/conversions.h +++ b/ReactCommon/react/renderer/components/text/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,11 +27,11 @@ inline folly::dynamic toDynamic(ParagraphState const ¶graphState) { } // constants for Text State serialization -constexpr static Key TX_STATE_KEY_ATTRIBUTED_STRING = 0; -constexpr static Key TX_STATE_KEY_PARAGRAPH_ATTRIBUTES = 1; +constexpr static MapBuffer::Key TX_STATE_KEY_ATTRIBUTED_STRING = 0; +constexpr static MapBuffer::Key TX_STATE_KEY_PARAGRAPH_ATTRIBUTES = 1; // Used for TextInput -constexpr static Key TX_STATE_KEY_HASH = 2; -constexpr static Key TX_STATE_KEY_MOST_RECENT_EVENT_COUNT = 3; +constexpr static MapBuffer::Key TX_STATE_KEY_HASH = 2; +constexpr static MapBuffer::Key TX_STATE_KEY_MOST_RECENT_EVENT_COUNT = 3; inline MapBuffer toMapBuffer(ParagraphState const ¶graphState) { auto builder = MapBufferBuilder(); diff --git a/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp b/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp index f38bfe8de4f8e7..1c09c5d052bfcf 100644 --- a/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp +++ b/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/text/tests/TextTest.cpp b/ReactCommon/react/renderer/components/text/tests/TextTest.cpp index 5debe8f34f10e9..296fc9a53a88a7 100644 --- a/ReactCommon/react/renderer/components/text/tests/TextTest.cpp +++ b/ReactCommon/react/renderer/components/text/tests/TextTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/textinput/Android.mk b/ReactCommon/react/renderer/components/textinput/Android.mk deleted file mode 100644 index c45affab7b9b83..00000000000000 --- a/ReactCommon/react/renderer/components/textinput/Android.mk +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_textinput - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/androidtextinput/react/renderer/components/androidtextinput/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/androidtextinput/react/renderer/components/androidtextinput/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/androidtextinput/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_mounting libreact_render_componentregistry libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_attributedstring librrc_text librrc_image librrc_view libreact_utils libreact_debug libreact_render_mapbuffer - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/textlayoutmanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/components/text) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/textinput/BUCK b/ReactCommon/react/renderer/components/textinput/BUCK index 76f69e93aa20ac..a6d1767b918292 100644 --- a/ReactCommon/react/renderer/components/textinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/BUCK @@ -40,7 +40,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -51,7 +54,7 @@ rn_xplat_cxx_library( "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", "//xplat/folly:container_evicting_cache_map", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/textinput/CMakeLists.txt b/ReactCommon/react/renderer/components/textinput/CMakeLists.txt new file mode 100644 index 00000000000000..84826c23d3f5ed --- /dev/null +++ b/ReactCommon/react/renderer/components/textinput/CMakeLists.txt @@ -0,0 +1,40 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_textinput_SRC CONFIGURE_DEPENDS androidtextinput/react/renderer/components/androidtextinput/*.cpp) +add_library(rrc_textinput SHARED ${rrc_textinput_SRC}) + +target_include_directories(rrc_textinput + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/androidtextinput/ +) + +target_link_libraries(rrc_textinput + glog + folly_runtime + glog_init + jsi + react_debug + react_render_attributedstring + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_imagemanager + react_render_mapbuffer + react_render_mounting + react_render_textlayoutmanager + react_render_uimanager + react_utils + rrc_image + rrc_text + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h index 1728de336a8e15..60c14908786eea 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -180,7 +180,7 @@ class AndroidTextInputComponentDescriptor final "com/facebook/react/fabric/FabricUIManager"; SharedTextLayoutManager textLayoutManager_; - mutable better::map surfaceIdToThemePaddingMap_; + mutable butter::map surfaceIdToThemePaddingMap_; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.cpp deleted file mode 100644 index 56fdc264a27ebb..00000000000000 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "AndroidTextInputEventEmitter.h" - -namespace facebook { -namespace react { - -void AndroidTextInputEventEmitter::onBlur( - AndroidTextInputOnBlurStruct event) const { - dispatchEvent("blur", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - return payload; - }); -} -void AndroidTextInputEventEmitter::onFocus( - AndroidTextInputOnFocusStruct event) const { - dispatchEvent("focus", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - return payload; - }); -} -void AndroidTextInputEventEmitter::onChange( - AndroidTextInputOnChangeStruct event) const { - dispatchEvent("change", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "eventCount", event.eventCount); - payload.setProperty(runtime, "text", event.text); - return payload; - }); -} -void AndroidTextInputEventEmitter::onChangeText( - AndroidTextInputOnChangeTextStruct event) const { - dispatchEvent( - "changeText", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "eventCount", event.eventCount); - payload.setProperty(runtime, "text", event.text); - return payload; - }); -} -void AndroidTextInputEventEmitter::onContentSizeChange( - AndroidTextInputOnContentSizeChangeStruct event) const { - dispatchEvent( - "contentSizeChange", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - { - auto contentSize = jsi::Object(runtime); - contentSize.setProperty(runtime, "width", event.contentSize.width); - contentSize.setProperty(runtime, "height", event.contentSize.height); - - payload.setProperty(runtime, "contentSize", contentSize); - } - return payload; - }); -} -void AndroidTextInputEventEmitter::onTextInput( - AndroidTextInputOnTextInputStruct event) const { - dispatchEvent("textInput", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "text", event.text); - payload.setProperty(runtime, "previousText", event.previousText); - { - auto range = jsi::Object(runtime); - range.setProperty(runtime, "start", event.range.start); - range.setProperty(runtime, "end", event.range.end); - - payload.setProperty(runtime, "range", range); - } - return payload; - }); -} -void AndroidTextInputEventEmitter::onEndEditing( - AndroidTextInputOnEndEditingStruct event) const { - dispatchEvent( - "endEditing", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "text", event.text); - return payload; - }); -} -void AndroidTextInputEventEmitter::onSelectionChange( - AndroidTextInputOnSelectionChangeStruct event) const { - dispatchEvent( - "selectionChange", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - { - auto selection = jsi::Object(runtime); - selection.setProperty(runtime, "start", event.selection.start); - selection.setProperty(runtime, "end", event.selection.end); - - payload.setProperty(runtime, "selection", selection); - } - return payload; - }); -} -void AndroidTextInputEventEmitter::onSubmitEditing( - AndroidTextInputOnSubmitEditingStruct event) const { - dispatchEvent( - "submitEditing", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "text", event.text); - return payload; - }); -} -void AndroidTextInputEventEmitter::onKeyPress( - AndroidTextInputOnKeyPressStruct event) const { - dispatchEvent("keyPress", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty(runtime, "key", event.key); - return payload; - }); -} -void AndroidTextInputEventEmitter::onScroll( - AndroidTextInputOnScrollStruct event) const { - dispatchEvent("scroll", [event = std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "target", event.target); - payload.setProperty( - runtime, "responderIgnoreScroll", event.responderIgnoreScroll); - { - auto contentInset = jsi::Object(runtime); - contentInset.setProperty(runtime, "top", event.contentInset.top); - contentInset.setProperty(runtime, "bottom", event.contentInset.bottom); - contentInset.setProperty(runtime, "left", event.contentInset.left); - contentInset.setProperty(runtime, "right", event.contentInset.right); - - payload.setProperty(runtime, "contentInset", contentInset); - } - { - auto contentOffset = jsi::Object(runtime); - contentOffset.setProperty(runtime, "x", event.contentOffset.x); - contentOffset.setProperty(runtime, "y", event.contentOffset.y); - - payload.setProperty(runtime, "contentOffset", contentOffset); - } - { - auto contentSize = jsi::Object(runtime); - contentSize.setProperty(runtime, "width", event.contentSize.width); - contentSize.setProperty(runtime, "height", event.contentSize.height); - - payload.setProperty(runtime, "contentSize", contentSize); - } - { - auto layoutMeasurement = jsi::Object(runtime); - layoutMeasurement.setProperty( - runtime, "width", event.layoutMeasurement.width); - layoutMeasurement.setProperty( - runtime, "height", event.layoutMeasurement.height); - - payload.setProperty(runtime, "layoutMeasurement", layoutMeasurement); - } - { - auto velocity = jsi::Object(runtime); - velocity.setProperty(runtime, "x", event.velocity.x); - velocity.setProperty(runtime, "y", event.velocity.y); - - payload.setProperty(runtime, "velocity", velocity); - } - return payload; - }); -} - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.h index b99192b244f861..e9b4bd44510508 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,136 +12,15 @@ namespace facebook { namespace react { -struct AndroidTextInputOnBlurStruct { - int target; -}; - -struct AndroidTextInputOnFocusStruct { - int target; -}; - -struct AndroidTextInputOnChangeStruct { - int target; - int eventCount; - std::string text; -}; - -struct AndroidTextInputOnChangeTextStruct { - int target; - int eventCount; - std::string text; -}; - -struct AndroidTextInputOnContentSizeChangeContentSizeStruct { - double width; - double height; -}; - -struct AndroidTextInputOnContentSizeChangeStruct { - int target; - AndroidTextInputOnContentSizeChangeContentSizeStruct contentSize; -}; - -struct AndroidTextInputOnTextInputRangeStruct { - double start; - double end; -}; - -struct AndroidTextInputOnTextInputStruct { - int target; - std::string text; - std::string previousText; - AndroidTextInputOnTextInputRangeStruct range; -}; - -struct AndroidTextInputOnEndEditingStruct { - int target; - std::string text; -}; - -struct AndroidTextInputOnSelectionChangeSelectionStruct { - double start; - double end; -}; - -struct AndroidTextInputOnSelectionChangeStruct { - int target; - AndroidTextInputOnSelectionChangeSelectionStruct selection; -}; - -struct AndroidTextInputOnSubmitEditingStruct { - int target; - std::string text; -}; - -struct AndroidTextInputOnKeyPressStruct { - int target; - std::string key; -}; - -struct AndroidTextInputOnScrollContentInsetStruct { - double top; - double bottom; - double left; - double right; -}; - -struct AndroidTextInputOnScrollContentOffsetStruct { - double x; - double y; -}; - -struct AndroidTextInputOnScrollContentSizeStruct { - double width; - double height; -}; - -struct AndroidTextInputOnScrollLayoutMeasurementStruct { - double width; - double height; -}; - -struct AndroidTextInputOnScrollVelocityStruct { - double x; - double y; -}; - -struct AndroidTextInputOnScrollStruct { - int target; - bool responderIgnoreScroll; - AndroidTextInputOnScrollContentInsetStruct contentInset; - AndroidTextInputOnScrollContentOffsetStruct contentOffset; - AndroidTextInputOnScrollContentSizeStruct contentSize; - AndroidTextInputOnScrollLayoutMeasurementStruct layoutMeasurement; - AndroidTextInputOnScrollVelocityStruct velocity; -}; - +// This emitter exists only as a placeholder and is not used for communication +// with JS. +// +// See: +// - EventEmitterWrapper::invokeEvent for the Android event emitter dispatch +// - ReactTextInputManager.java for the text input events used on Android class AndroidTextInputEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; - - void onBlur(AndroidTextInputOnBlurStruct value) const; - - void onFocus(AndroidTextInputOnFocusStruct value) const; - - void onChange(AndroidTextInputOnChangeStruct value) const; - - void onChangeText(AndroidTextInputOnChangeTextStruct value) const; - - void onContentSizeChange( - AndroidTextInputOnContentSizeChangeStruct value) const; - - void onTextInput(AndroidTextInputOnTextInputStruct value) const; - - void onEndEditing(AndroidTextInputOnEndEditingStruct value) const; - - void onSelectionChange(AndroidTextInputOnSelectionChangeStruct value) const; - - void onSubmitEditing(AndroidTextInputOnSubmitEditingStruct value) const; - - void onKeyPress(AndroidTextInputOnKeyPressStruct value) const; - - void onScroll(AndroidTextInputOnScrollStruct value) const; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp index ce7e24fd476aa3..becfec590be7a9 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -258,6 +258,15 @@ AndroidTextInputProps::AndroidTextInputProps( hasValue(rawProps, sourceProps.hasPaddingEnd, "End", "padding", "")) { } +void AndroidTextInputProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + ViewProps::setProp(context, hash, propName, value); + BaseTextProps::setProp(context, hash, propName, value); +} + // TODO T53300085: support this in codegen; this was hand-written folly::dynamic AndroidTextInputProps::getDynamic() const { folly::dynamic props = folly::dynamic::object(); @@ -266,7 +275,7 @@ folly::dynamic AndroidTextInputProps::getDynamic() const { props["numberOfLines"] = numberOfLines; props["disableFullscreenUI"] = disableFullscreenUI; props["textBreakStrategy"] = textBreakStrategy; - props["underlineColorAndroid"] = toDynamic(underlineColorAndroid); + props["underlineColorAndroid"] = toAndroidRepr(underlineColorAndroid); props["inlineImageLeft"] = inlineImageLeft; props["inlineImagePadding"] = inlineImagePadding; props["importantForAutofill"] = importantForAutofill; @@ -282,9 +291,9 @@ folly::dynamic AndroidTextInputProps::getDynamic() const { props["maxLength"] = maxLength; props["multiline"] = multiline; props["placeholder"] = placeholder; - props["placeholderTextColor"] = toDynamic(placeholderTextColor); + props["placeholderTextColor"] = toAndroidRepr(placeholderTextColor); props["secureTextEntry"] = secureTextEntry; - props["selectionColor"] = toDynamic(selectionColor); + props["selectionColor"] = toAndroidRepr(selectionColor); props["selection"] = toDynamic(selection); props["value"] = value; props["defaultValue"] = defaultValue; @@ -292,14 +301,14 @@ folly::dynamic AndroidTextInputProps::getDynamic() const { props["blurOnSubmit"] = blurOnSubmit; props["caretHidden"] = caretHidden; props["contextMenuHidden"] = contextMenuHidden; - props["textShadowColor"] = toDynamic(textShadowColor); + props["textShadowColor"] = toAndroidRepr(textShadowColor); props["textShadowRadius"] = textShadowRadius; props["textDecorationLine"] = textDecorationLine; props["fontStyle"] = fontStyle; props["textShadowOffset"] = toDynamic(textShadowOffset); props["lineHeight"] = lineHeight; props["textTransform"] = textTransform; - props["color"] = toDynamic(color); + props["color"] = toAndroidRepr(color); props["letterSpacing"] = letterSpacing; props["fontSize"] = fontSize; props["textAlign"] = textAlign; @@ -307,7 +316,7 @@ folly::dynamic AndroidTextInputProps::getDynamic() const { props["fontWeight"] = fontWeight; props["fontFamily"] = fontFamily; props["textAlignVertical"] = textAlignVertical; - props["cursorColor"] = toDynamic(cursorColor); + props["cursorColor"] = toAndroidRepr(cursorColor); props["mostRecentEventCount"] = mostRecentEventCount; props["text"] = text; diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h index 34048ddf9100f5..6843425b190117 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -37,7 +37,7 @@ static inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AndroidTextInputSelectionStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto start = map.find("start"); if (start != map.end()) { @@ -63,7 +63,7 @@ static inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AndroidTextInputTextShadowOffsetStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto width = map.find("width"); if (width != map.end()) { @@ -105,6 +105,12 @@ class AndroidTextInputProps final : public ViewProps, public BaseTextProps { const AndroidTextInputProps &sourceProps, const RawProps &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + folly::dynamic getDynamic() const; #pragma mark - Props diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp index 1f2e468653e2bd..5edf5badde2216 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,8 @@ #include #include +#include + using namespace facebook::jni; namespace facebook { @@ -91,7 +93,7 @@ AttributedString AndroidTextInputShadowNode::getPlaceholderAttributedString() void AndroidTextInputShadowNode::setTextLayoutManager( SharedTextLayoutManager textLayoutManager) { ensureUnsealed(); - textLayoutManager_ = textLayoutManager; + textLayoutManager_ = std::move(textLayoutManager); } AttributedString AndroidTextInputShadowNode::getMostRecentAttributedString() @@ -139,17 +141,17 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() { auto defaultTextAttributes = TextAttributes::defaultTextAttributes(); defaultTextAttributes.apply(getConcreteProps().textAttributes); - auto newEventCount = - (state.reactTreeAttributedString == reactTreeAttributedString - ? 0 - : getConcreteProps().mostRecentEventCount); - auto newAttributedString = getMostRecentAttributedString(); - // Even if we're here and updating state, it may be only to update the layout // manager If that is the case, make sure we don't update text: pass in the // current attributedString unchanged, and pass in zero for the "event count" // so no changes are applied There's no way to prevent a state update from // flowing to Java, so we just ensure it's a noop in those cases. + auto newEventCount = + state.reactTreeAttributedString.isContentEqual(reactTreeAttributedString) + ? 0 + : getConcreteProps().mostRecentEventCount; + auto newAttributedString = getMostRecentAttributedString(); + setStateData(AndroidTextInputState{ newEventCount, newAttributedString, diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h index 2642030d94776f..d79d8e51059249 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -81,7 +81,7 @@ class AndroidTextInputShadowNode final : public ConcreteViewShadowNode< * Cached attributed string that represents the content of the subtree started * from the node. */ - mutable better::optional cachedAttributedString_{}; + mutable std::optional cachedAttributedString_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp index 4e51cf0ceef85f..a2deb59db337d9 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,27 +10,28 @@ #include #include +#include + namespace facebook { namespace react { AndroidTextInputState::AndroidTextInputState( int64_t mostRecentEventCount, - AttributedString const &attributedString, - AttributedString const &reactTreeAttributedString, - ParagraphAttributes const ¶graphAttributes, - TextAttributes const &defaultTextAttributes, - ShadowView const &defaultParentShadowView, + AttributedString attributedString, + AttributedString reactTreeAttributedString, + ParagraphAttributes paragraphAttributes, + TextAttributes defaultTextAttributes, + ShadowView defaultParentShadowView, float defaultThemePaddingStart, float defaultThemePaddingEnd, float defaultThemePaddingTop, float defaultThemePaddingBottom) : mostRecentEventCount(mostRecentEventCount), - cachedAttributedStringId(0), - attributedString(attributedString), - reactTreeAttributedString(reactTreeAttributedString), - paragraphAttributes(paragraphAttributes), - defaultTextAttributes(defaultTextAttributes), - defaultParentShadowView(defaultParentShadowView), + attributedString(std::move(attributedString)), + reactTreeAttributedString(std::move(reactTreeAttributedString)), + paragraphAttributes(std::move(paragraphAttributes)), + defaultTextAttributes(std::move(defaultTextAttributes)), + defaultParentShadowView(std::move(defaultParentShadowView)), defaultThemePaddingStart(defaultThemePaddingStart), defaultThemePaddingEnd(defaultThemePaddingEnd), defaultThemePaddingTop(defaultThemePaddingTop), diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.h index 4d3d41ac7a87c6..4dc50ac9410188 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -79,11 +79,11 @@ class AndroidTextInputState final { AndroidTextInputState( int64_t mostRecentEventCount, - AttributedString const &attributedString, - AttributedString const &reactTreeAttributedString, - ParagraphAttributes const ¶graphAttributes, - TextAttributes const &defaultTextAttributes, - ShadowView const &defaultParentShadowView, + AttributedString attributedString, + AttributedString reactTreeAttributedString, + ParagraphAttributes paragraphAttributes, + TextAttributes defaultTextAttributes, + ShadowView defaultParentShadowView, float defaultThemePaddingStart, float defaultThemePaddingEnd, float defaultThemePaddingTop, diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK index 414f2d39855f93..548ad6ade82146 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK @@ -37,7 +37,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -48,7 +51,7 @@ rn_xplat_cxx_library( "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", "//xplat/folly:container_evicting_cache_map", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h index a23ad76a7b3669..63900758c9bd5f 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -36,7 +36,7 @@ class TextInputComponentDescriptor final } private: - TextLayoutManager::Shared textLayoutManager_; + std::shared_ptr textLayoutManager_; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.cpp index a01d96d9466eee..66e3c6e41f9b13 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -75,9 +75,10 @@ void TextInputEventEmitter::onChange( dispatchTextInputEvent("change", textInputMetrics); } -void TextInputEventEmitter::onChangeText( +void TextInputEventEmitter::onChangeSync( TextInputMetrics const &textInputMetrics) const { - dispatchTextInputEvent("changeText", textInputMetrics); + dispatchTextInputEvent( + "changeSync", textInputMetrics, EventPriority::SynchronousBatched); } void TextInputEventEmitter::onContentSizeChange( @@ -110,9 +111,19 @@ void TextInputEventEmitter::onKeyPress( EventPriority::AsynchronousBatched); } +void TextInputEventEmitter::onKeyPressSync( + KeyPressMetrics const &keyPressMetrics) const { + dispatchEvent( + "keyPressSync", + [keyPressMetrics](jsi::Runtime &runtime) { + return keyPressMetricsPayload(runtime, keyPressMetrics); + }, + EventPriority::SynchronousBatched); +} + void TextInputEventEmitter::onScroll( TextInputMetrics const &textInputMetrics) const { - dispatchTextInputEvent("onScroll", textInputMetrics); + dispatchTextInputEvent("scroll", textInputMetrics); } void TextInputEventEmitter::dispatchTextInputEvent( diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h index 60097a7e2fdb1c..a872f5f7ba6fea 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -40,12 +40,13 @@ class TextInputEventEmitter : public ViewEventEmitter { void onFocus(TextInputMetrics const &textInputMetrics) const; void onBlur(TextInputMetrics const &textInputMetrics) const; void onChange(TextInputMetrics const &textInputMetrics) const; - void onChangeText(TextInputMetrics const &textInputMetrics) const; + void onChangeSync(TextInputMetrics const &textInputMetrics) const; void onContentSizeChange(TextInputMetrics const &textInputMetrics) const; void onSelectionChange(TextInputMetrics const &textInputMetrics) const; void onEndEditing(TextInputMetrics const &textInputMetrics) const; void onSubmitEditing(TextInputMetrics const &textInputMetrics) const; void onKeyPress(KeyPressMetrics const &textInputMetrics) const; + void onKeyPressSync(KeyPressMetrics const &textInputMetrics) const; void onScroll(TextInputMetrics const &textInputMetrics) const; private: diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp index 9e13cb97bb0574..96d4d0c1849259 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -87,14 +87,35 @@ TextInputProps::TextInputProps( rawProps, "selection", sourceProps.selection, - better::optional())), + std::optional())), inputAccessoryViewID(convertRawProp( context, rawProps, "inputAccessoryViewID", sourceProps.inputAccessoryViewID, + {})), + onKeyPressSync(convertRawProp( + context, + rawProps, + "onKeyPressSync", + sourceProps.onKeyPressSync, + {})), + onChangeSync(convertRawProp( + context, + rawProps, + "onChangeSync", + sourceProps.onChangeSync, {})){}; +void TextInputProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + ViewProps::setProp(context, hash, propName, value); + BaseTextProps::setProp(context, hash, propName, value); +} + TextAttributes TextInputProps::getEffectiveTextAttributes( Float fontSizeMultiplier) const { auto result = TextAttributes::defaultTextAttributes(); diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h index 9fb44a4b2c1724..bede7451767b36 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -31,6 +31,12 @@ class TextInputProps final : public ViewProps, public BaseTextProps { TextInputProps const &sourceProps, RawProps const &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + #pragma mark - Props TextInputTraits const traits{}; @@ -58,10 +64,13 @@ class TextInputProps final : public ViewProps, public BaseTextProps { int const mostRecentEventCount{0}; bool autoFocus{false}; - better::optional selection{}; + std::optional selection{}; std::string const inputAccessoryViewID{}; + bool onKeyPressSync{false}; + bool onChangeSync{false}; + /* * Accessors */ diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp index fb5c0ff7f33bda..8910d21fb43d60 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -71,9 +71,9 @@ AttributedString TextInputShadowNode::getAttributedString( } void TextInputShadowNode::setTextLayoutManager( - TextLayoutManager::Shared const &textLayoutManager) { + std::shared_ptr textLayoutManager) { ensureUnsealed(); - textLayoutManager_ = textLayoutManager; + textLayoutManager_ = std::move(textLayoutManager); } void TextInputShadowNode::updateStateIfNeeded( diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h index ffb370aab03f97..105ed7805ab969 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -46,7 +46,8 @@ class TextInputShadowNode final : public ConcreteViewShadowNode< * `TextInputShadowNode` uses the manager to measure text content * and construct `TextInputState` objects. */ - void setTextLayoutManager(TextLayoutManager::Shared const &textLayoutManager); + void setTextLayoutManager( + std::shared_ptr textLayoutManager); #pragma mark - LayoutableShadowNode @@ -75,7 +76,7 @@ class TextInputShadowNode final : public ConcreteViewShadowNode< AttributedStringBox attributedStringBoxToMeasure( LayoutContext const &layoutContext) const; - TextLayoutManager::Shared textLayoutManager_; + std::shared_ptr textLayoutManager_; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp index c22ba8bd11d2a1..f4930a436e9411 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,5 +8,27 @@ #include "TextInputState.h" namespace facebook { -namespace react {} // namespace react +namespace react { + +#ifdef ANDROID +TextInputState::TextInputState( + TextInputState const &previousState, + folly::dynamic const &data){}; + +/* + * Empty implementation for Android because it doesn't use this class. + */ +folly::dynamic TextInputState::getDynamic() const { + return {}; +}; + +/* + * Empty implementation for Android because it doesn't use this class. + */ +MapBuffer TextInputState::getMapBuffer() const { + return MapBufferBuilder::EMPTY(); +}; +#endif + +} // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h index fb249f4a840ab3..68572c09e218b6 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,6 +25,8 @@ namespace react { */ class TextInputState final { public: + TextInputState() = default; + /* * All content of component. */ @@ -50,9 +52,19 @@ class TextInputState final { * text rendering infrastructure which is capable to render the * `AttributedString`. */ - SharedTextLayoutManager layoutManager; + std::shared_ptr layoutManager; size_t mostRecentEventCount{0}; + +#ifdef ANDROID + TextInputState( + TextInputState const &previousState, + folly::dynamic const &data); + + folly::dynamic getDynamic() const; + + MapBuffer getMapBuffer() const; +#endif }; } // namespace react diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/conversions.h b/ReactCommon/react/renderer/components/textinput/iostextinput/conversions.h index 56be93b9da177a..98e44fd7c07074 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/conversions.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h index f3b0fc2dfc5899..1747a98bf4cd44 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,10 +7,9 @@ #pragma once +#include #include -#include - namespace facebook { namespace react { @@ -106,7 +105,7 @@ class TextInputTraits final { * iOS & Android * Default value: `empty` (`null`). */ - better::optional autoCorrect{}; + std::optional autoCorrect{}; /* * iOS & Android @@ -141,7 +140,7 @@ class TextInputTraits final { * Can be empty (`null` in JavaScript) which means `default`. * Default value: `empty` (`null`). */ - better::optional spellCheck{}; + std::optional spellCheck{}; /* * iOS & Android diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h b/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h index 162e989112474c..84c52eeace6ce4 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/propsConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -149,8 +149,8 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, Selection &result) { - if (value.hasType>()) { - auto map = (better::map)value; + if (value.hasType>()) { + auto map = (butter::map)value; for (const auto &pair : map) { if (pair.first == "start") { result.start = pair.second; diff --git a/ReactCommon/react/renderer/components/unimplementedview/Android.mk b/ReactCommon/react/renderer/components/unimplementedview/Android.mk deleted file mode 100644 index 959500fb70d131..00000000000000 --- a/ReactCommon/react/renderer/components/unimplementedview/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_unimplementedview - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,yogajni) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/unimplementedview/BUCK b/ReactCommon/react/renderer/components/unimplementedview/BUCK index 8e59dd374ad0fe..c90681d7ac4bf8 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/BUCK +++ b/ReactCommon/react/renderer/components/unimplementedview/BUCK @@ -31,7 +31,10 @@ rn_xplat_cxx_library( ), fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -43,7 +46,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/components/unimplementedview/CMakeLists.txt b/ReactCommon/react/renderer/components/unimplementedview/CMakeLists.txt new file mode 100644 index 00000000000000..7b128501bd812d --- /dev/null +++ b/ReactCommon/react/renderer/components/unimplementedview/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_unimplementedview_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_unimplementedview SHARED ${rrc_unimplementedview_SRC}) + +target_include_directories(rrc_unimplementedview PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_unimplementedview + glog + folly_runtime + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_render_graphics + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp index c6b460641670a5..e58621a6c51b40 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h index 2f5bfca3a95ddc..0d89f9553ec6dc 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp index b5033818f156ee..73aff6fd4e9607 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h index c2907a50abc381..87794e2f312b8a 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp index a01eb025bbf204..30cadf3a3f399b 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h index f176f68fc4ae3f..a6d141aacf7a57 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h index 23999ae4d28f54..abc5df00883946 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,9 +7,10 @@ #pragma once -#include #include +#include #include +#include namespace facebook { namespace react { @@ -50,9 +51,21 @@ constexpr enum AccessibilityTraits operator&( struct AccessibilityAction { std::string name{""}; - better::optional label{}; + std::optional label{}; }; +inline static bool operator==( + AccessibilityAction const &lhs, + AccessibilityAction const &rhs) { + return lhs.name == rhs.name && lhs.label == rhs.label; +} + +inline static bool operator!=( + AccessibilityAction const &lhs, + AccessibilityAction const &rhs) { + return !(rhs == lhs); +} + struct AccessibilityState { bool disabled{false}; bool selected{false}; @@ -75,11 +88,27 @@ constexpr bool operator!=( return !(rhs == lhs); } +struct AccessibilityLabelledBy { + std::vector value{}; +}; + +inline static bool operator==( + AccessibilityLabelledBy const &lhs, + AccessibilityLabelledBy const &rhs) { + return lhs.value == rhs.value; +} + +inline static bool operator!=( + AccessibilityLabelledBy const &lhs, + AccessibilityLabelledBy const &rhs) { + return !(lhs == rhs); +} + struct AccessibilityValue { - better::optional min; - better::optional max; - better::optional now; - better::optional text{}; + std::optional min; + std::optional max; + std::optional now; + std::optional text{}; }; constexpr bool operator==( @@ -102,5 +131,11 @@ enum class ImportantForAccessibility { NoHideDescendants, }; +enum class AccessibilityLiveRegion { + None, + Polite, + Assertive, +}; + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index 4dda5214c6dfb5..d3a91fdfa353cb 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,102 +15,219 @@ namespace facebook { namespace react { +bool AccessibilityProps::enablePropIteratorSetter = false; + AccessibilityProps::AccessibilityProps( const PropsParserContext &context, AccessibilityProps const &sourceProps, RawProps const &rawProps) - : accessible(convertRawProp( - context, - rawProps, - "accessible", - sourceProps.accessible, - false)), - accessibilityTraits(convertRawProp( - context, - rawProps, - "accessibilityRole", - sourceProps.accessibilityTraits, - AccessibilityTraits::None)), - accessibilityState(convertRawProp( - context, - rawProps, - "accessibilityState", - sourceProps.accessibilityState, - {})), - accessibilityLabel(convertRawProp( - context, - rawProps, - "accessibilityLabel", - sourceProps.accessibilityLabel, - "")), - accessibilityHint(convertRawProp( - context, - rawProps, - "accessibilityHint", - sourceProps.accessibilityHint, - "")), - accessibilityValue(convertRawProp( - context, - rawProps, - "accessibilityValue", - sourceProps.accessibilityValue, - {})), - accessibilityActions(convertRawProp( - context, - rawProps, - "accessibilityActions", - sourceProps.accessibilityActions, - {})), - accessibilityViewIsModal(convertRawProp( - context, - rawProps, - "accessibilityViewIsModal", - sourceProps.accessibilityViewIsModal, - false)), - accessibilityElementsHidden(convertRawProp( - context, - rawProps, - "accessibilityElementsHidden", - sourceProps.accessibilityElementsHidden, - false)), - accessibilityIgnoresInvertColors(convertRawProp( - context, - rawProps, - "accessibilityIgnoresInvertColors", - sourceProps.accessibilityIgnoresInvertColors, - false)), - onAccessibilityTap(convertRawProp( - context, - rawProps, - "onAccessibilityTap", - sourceProps.onAccessibilityTap, - {})), - onAccessibilityMagicTap(convertRawProp( - context, - rawProps, - "onAccessibilityMagicTap", - sourceProps.onAccessibilityMagicTap, - {})), - onAccessibilityEscape(convertRawProp( - context, - rawProps, - "onAccessibilityEscape", - sourceProps.onAccessibilityEscape, - {})), - onAccessibilityAction(convertRawProp( - context, - rawProps, - "onAccessibilityAction", - sourceProps.onAccessibilityAction, - {})), - importantForAccessibility(convertRawProp( - context, - rawProps, - "importantForAccessibility", - sourceProps.importantForAccessibility, - ImportantForAccessibility::Auto)), + : accessible( + enablePropIteratorSetter ? sourceProps.accessible + : convertRawProp( + context, + rawProps, + "accessible", + sourceProps.accessible, + false)), + accessibilityState( + enablePropIteratorSetter ? sourceProps.accessibilityState + : convertRawProp( + context, + rawProps, + "accessibilityState", + sourceProps.accessibilityState, + {})), + accessibilityLabel( + enablePropIteratorSetter ? sourceProps.accessibilityLabel + : convertRawProp( + context, + rawProps, + "accessibilityLabel", + sourceProps.accessibilityLabel, + "")), + accessibilityLabelledBy( + enablePropIteratorSetter ? sourceProps.accessibilityLabelledBy + : convertRawProp( + context, + rawProps, + "accessibilityLabelledBy", + sourceProps.accessibilityLabelledBy, + {})), + accessibilityLiveRegion( + enablePropIteratorSetter ? sourceProps.accessibilityLiveRegion + : convertRawProp( + context, + rawProps, + "accessibilityLiveRegion", + sourceProps.accessibilityLiveRegion, + AccessibilityLiveRegion::None)), + accessibilityHint( + enablePropIteratorSetter ? sourceProps.accessibilityHint + : convertRawProp( + context, + rawProps, + "accessibilityHint", + sourceProps.accessibilityHint, + "")), + accessibilityLanguage( + enablePropIteratorSetter ? sourceProps.accessibilityLanguage + : convertRawProp( + context, + rawProps, + "accessibilityLanguage", + sourceProps.accessibilityLanguage, + "")), + accessibilityValue( + enablePropIteratorSetter ? sourceProps.accessibilityValue + : convertRawProp( + context, + rawProps, + "accessibilityValue", + sourceProps.accessibilityValue, + {})), + accessibilityActions( + enablePropIteratorSetter ? sourceProps.accessibilityActions + : convertRawProp( + context, + rawProps, + "accessibilityActions", + sourceProps.accessibilityActions, + {})), + accessibilityViewIsModal( + enablePropIteratorSetter ? sourceProps.accessibilityViewIsModal + : convertRawProp( + context, + rawProps, + "accessibilityViewIsModal", + sourceProps.accessibilityViewIsModal, + false)), + accessibilityElementsHidden( + enablePropIteratorSetter + ? sourceProps.accessibilityElementsHidden + : convertRawProp( + context, + rawProps, + "accessibilityElementsHidden", + sourceProps.accessibilityElementsHidden, + false)), + accessibilityIgnoresInvertColors( + enablePropIteratorSetter + ? sourceProps.accessibilityIgnoresInvertColors + : convertRawProp( + context, + rawProps, + "accessibilityIgnoresInvertColors", + sourceProps.accessibilityIgnoresInvertColors, + false)), + onAccessibilityTap( + enablePropIteratorSetter ? sourceProps.onAccessibilityTap + : convertRawProp( + context, + rawProps, + "onAccessibilityTap", + sourceProps.onAccessibilityTap, + {})), + onAccessibilityMagicTap( + enablePropIteratorSetter ? sourceProps.onAccessibilityMagicTap + : convertRawProp( + context, + rawProps, + "onAccessibilityMagicTap", + sourceProps.onAccessibilityMagicTap, + {})), + onAccessibilityEscape( + enablePropIteratorSetter ? sourceProps.onAccessibilityEscape + : convertRawProp( + context, + rawProps, + "onAccessibilityEscape", + sourceProps.onAccessibilityEscape, + {})), + onAccessibilityAction( + enablePropIteratorSetter ? sourceProps.onAccessibilityAction + : convertRawProp( + context, + rawProps, + "onAccessibilityAction", + sourceProps.onAccessibilityAction, + {})), + importantForAccessibility( + enablePropIteratorSetter ? sourceProps.importantForAccessibility + : convertRawProp( + context, + rawProps, + "importantForAccessibility", + sourceProps.importantForAccessibility, + ImportantForAccessibility::Auto)), testId( - convertRawProp(context, rawProps, "testID", sourceProps.testId, "")) { + enablePropIteratorSetter ? sourceProps.testId + : convertRawProp( + context, + rawProps, + "testID", + sourceProps.testId, + "")) { + // It is a (severe!) perf deoptimization to request props out-of-order. + // Thus, since we need to request the same prop twice here + // (accessibilityRole) we "must" do them subsequently here to prevent + // a regression. It is reasonable to ask if the `at` function can be improved; + // it probably can, but this is a fairly rare edge-case that (1) is easy-ish + // to work around here, and (2) would require very careful work to address + // this case and not regress the more common cases. + if (!enablePropIteratorSetter) { + const auto *rawPropValue = + rawProps.at("accessibilityRole", nullptr, nullptr); + AccessibilityTraits traits; + std::string roleString; + if (rawPropValue == nullptr || !rawPropValue->hasValue()) { + traits = AccessibilityTraits::None; + roleString = ""; + } else { + fromRawValue(context, *rawPropValue, traits); + fromRawValue(context, *rawPropValue, roleString); + } + accessibilityTraits = traits; + accessibilityRole = roleString; + } +} + +void AccessibilityProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + switch (hash) { + RAW_SET_PROP_SWITCH_CASE_BASIC(accessible, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityState, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLabel, std::string{""}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLabelledBy, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityHint, std::string{""}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityLanguage, std::string{""}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityValue, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityActions, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityViewIsModal, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityElementsHidden, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(accessibilityIgnoresInvertColors, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(onAccessibilityTap, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(onAccessibilityMagicTap, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(onAccessibilityEscape, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(onAccessibilityAction, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC( + importantForAccessibility, ImportantForAccessibility::Auto); + RAW_SET_PROP_SWITCH_CASE(testId, "testID", std::string{""}); + case CONSTEXPR_RAW_PROPS_KEY_HASH("accessibilityRole"): { + AccessibilityTraits traits = AccessibilityTraits::None; + std::string roleString = ""; + if (value.hasValue()) { + fromRawValue(context, value, traits); + fromRawValue(context, value, roleString); + } + + accessibilityTraits = traits; + accessibilityRole = roleString; + return; + } + } } #pragma mark - DebugStringConvertible diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/ReactCommon/react/renderer/components/view/AccessibilityProps.h index eab78469660526..e9e6aa7b3f09ec 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,13 +24,26 @@ class AccessibilityProps { AccessibilityProps const &sourceProps, RawProps const &rawProps); + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + + static bool enablePropIteratorSetter; + #pragma mark - Props bool accessible{false}; - AccessibilityTraits accessibilityTraits{AccessibilityTraits::None}; AccessibilityState accessibilityState; std::string accessibilityLabel{""}; + AccessibilityLabelledBy accessibilityLabelledBy{}; + AccessibilityLiveRegion accessibilityLiveRegion{ + AccessibilityLiveRegion::None}; + AccessibilityTraits accessibilityTraits{AccessibilityTraits::None}; + std::string accessibilityRole{""}; std::string accessibilityHint{""}; + std::string accessibilityLanguage{""}; AccessibilityValue accessibilityValue; std::vector accessibilityActions{}; bool accessibilityViewIsModal{false}; diff --git a/ReactCommon/react/renderer/components/view/Android.mk b/ReactCommon/react/renderer/components/view/Android.mk deleted file mode 100644 index 2f820d3cc5042b..00000000000000 --- a/ReactCommon/react/renderer/components/view/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_view - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug logger libjsi - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,logger) -$(call import-module,yogajni) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/view/BUCK b/ReactCommon/react/renderer/components/view/BUCK index b82e163974fe16..57552ca79fa12e 100644 --- a/ReactCommon/react/renderer/components/view/BUCK +++ b/ReactCommon/react/renderer/components/view/BUCK @@ -35,12 +35,13 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/view", ), - compiler_flags_enable_exceptions = False, - compiler_flags_enable_rtti = False, # YogaLayoutableShadowNode fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -52,7 +53,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, @@ -60,6 +61,7 @@ rn_xplat_cxx_library( react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("react/renderer/graphics:graphics"), + react_native_xplat_target("react/config:config"), react_native_xplat_target("logger:logger"), ], ) diff --git a/ReactCommon/react/renderer/components/view/CMakeLists.txt b/ReactCommon/react/renderer/components/view/CMakeLists.txt new file mode 100644 index 00000000000000..6320bd0bdfb033 --- /dev/null +++ b/ReactCommon/react/renderer/components/view/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB rrc_view_SRC CONFIGURE_DEPENDS *.cpp) +add_library(rrc_view SHARED ${rrc_view_SRC}) + +target_include_directories(rrc_view PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(rrc_view + folly_runtime + glog + glog_init + jsi + logger + react_debug + react_render_core + react_render_debug + react_render_graphics + yoga) diff --git a/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h b/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h index 0fe2def64c9413..045a5d752c69b5 100644 --- a/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h +++ b/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/PointerEvent.cpp b/ReactCommon/react/renderer/components/view/PointerEvent.cpp new file mode 100644 index 00000000000000..ce0627986f9133 --- /dev/null +++ b/ReactCommon/react/renderer/components/view/PointerEvent.cpp @@ -0,0 +1,48 @@ +/* + * 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. + */ + +#include "PointerEvent.h" + +namespace facebook { +namespace react { + +#if RN_DEBUG_STRING_CONVERTIBLE + +std::string getDebugName(PointerEvent const &pointerEvent) { + return "PointerEvent"; +} + +std::vector getDebugProps( + PointerEvent const &pointerEvent, + DebugStringConvertibleOptions options) { + return { + {"pointerId", getDebugDescription(pointerEvent.pointerId, options)}, + {"pressure", getDebugDescription(pointerEvent.pressure, options)}, + {"pointerType", getDebugDescription(pointerEvent.pointerType, options)}, + {"clientPoint", getDebugDescription(pointerEvent.clientPoint, options)}, + {"screenPoint", getDebugDescription(pointerEvent.screenPoint, options)}, + {"offsetPoint", getDebugDescription(pointerEvent.offsetPoint, options)}, + {"width", getDebugDescription(pointerEvent.width, options)}, + {"height", getDebugDescription(pointerEvent.height, options)}, + {"tiltX", getDebugDescription(pointerEvent.tiltX, options)}, + {"tiltY", getDebugDescription(pointerEvent.tiltY, options)}, + {"detail", getDebugDescription(pointerEvent.detail, options)}, + {"buttons", getDebugDescription(pointerEvent.buttons, options)}, + {"tangentialPressure", + getDebugDescription(pointerEvent.tangentialPressure, options)}, + {"twist", getDebugDescription(pointerEvent.twist, options)}, + {"ctrlKey", getDebugDescription(pointerEvent.ctrlKey, options)}, + {"shiftKey", getDebugDescription(pointerEvent.shiftKey, options)}, + {"altKey", getDebugDescription(pointerEvent.altKey, options)}, + {"metaKey", getDebugDescription(pointerEvent.metaKey, options)}, + }; +} + +#endif + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/PointerEvent.h b/ReactCommon/react/renderer/components/view/PointerEvent.h new file mode 100644 index 00000000000000..abe80ead90209e --- /dev/null +++ b/ReactCommon/react/renderer/components/view/PointerEvent.h @@ -0,0 +1,115 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +struct PointerEvent { + /* + * A unique identifier for the pointer causing the event. + */ + int pointerId; + /* + * The normalized pressure of the pointer input in the range 0 to 1, where 0 + * and 1 represent the minimum and maximum pressure the hardware is capable of + * detecting, respectively. + */ + Float pressure; + /* + * Indicates the device type that caused the event (mouse, pen, touch, etc.) + */ + std::string pointerType; + /* + * Point within the application's viewport at which the event occurred (as + * opposed to the coordinate within the page). + */ + Point clientPoint; + /* + * The X/Y coordinate of the pointer in global (screen) coordinates. + */ + Point screenPoint; + /* + * The X/Y coordinate of the pointer relative to the position of the padding + * edge of the target node. + */ + Point offsetPoint; + /* + * The width (magnitude on the X axis), in CSS pixels, of the contact geometry + * of the pointer + */ + Float width; + /* + * The height (magnitude on the y axis), in CSS pixels, of the contact + * geometry of the pointer + */ + Float height; + /* + * The plane angle (in degrees, in the range of -90 to 90) between the Y–Z + * plane and the plane containing both the pointer (e.g. pen stylus) axis and + * the Y axis. + */ + int tiltX; + /* + * The plane angle (in degrees, in the range of -90 to 90) between the X–Z + * plane and the plane containing both the pointer (e.g. pen stylus) axis and + * the X axis. + */ + int tiltY; + /* + * Returns a long with details about the event, depending on the event type. + */ + int detail; + /* + * The buttons being depressed (if any) when the mouse event was fired. + */ + int buttons; + /* + * The normalized tangential pressure of the pointer input (also known as + * barrel pressure or cylinder stress) in the range -1 to 1, where 0 is the + * neutral position of the control. + */ + Float tangentialPressure; + /* + * The clockwise rotation of the pointer (e.g. pen stylus) around its major + * axis in degrees, with a value in the range 0 to 359. + */ + int twist; + /* + * Returns true if the control key was down when the event was fired. + */ + bool ctrlKey; + /* + * Returns true if the shift key was down when the event was fired. + */ + bool shiftKey; + /* + * Returns true if the alt key was down when the event was fired. + */ + bool altKey; + /* + * Returns true if the meta key was down when the event was fired. + */ + bool metaKey; +}; + +#if RN_DEBUG_STRING_CONVERTIBLE + +std::string getDebugName(PointerEvent const &pointerEvent); +std::vector getDebugProps( + PointerEvent const &pointerEvent, + DebugStringConvertibleOptions options); + +#endif + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/Touch.cpp b/ReactCommon/react/renderer/components/view/Touch.cpp index 2b0c522fa389c6..15e5bfaaee55a9 100644 --- a/ReactCommon/react/renderer/components/view/Touch.cpp +++ b/ReactCommon/react/renderer/components/view/Touch.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/Touch.h b/ReactCommon/react/renderer/components/view/Touch.h index 91b6db7522b552..13383a0e5bbcb5 100644 --- a/ReactCommon/react/renderer/components/view/Touch.h +++ b/ReactCommon/react/renderer/components/view/Touch.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/TouchEvent.cpp b/ReactCommon/react/renderer/components/view/TouchEvent.cpp index 203a1bad0b0cad..7f8b9fda170cb9 100644 --- a/ReactCommon/react/renderer/components/view/TouchEvent.cpp +++ b/ReactCommon/react/renderer/components/view/TouchEvent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/TouchEvent.h b/ReactCommon/react/renderer/components/view/TouchEvent.h index 02f7ab4e636191..ad0e918f454599 100644 --- a/ReactCommon/react/renderer/components/view/TouchEvent.h +++ b/ReactCommon/react/renderer/components/view/TouchEvent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp b/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp index 1d8ed3e330409f..8eb4bc8d1444ab 100644 --- a/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -59,13 +59,48 @@ static jsi::Value touchEventPayload( return object; } +static jsi::Value pointerEventPayload( + jsi::Runtime &runtime, + PointerEvent const &event) { + auto object = jsi::Object(runtime); + object.setProperty(runtime, "pointerId", event.pointerId); + object.setProperty(runtime, "pressure", event.pressure); + object.setProperty(runtime, "pointerType", event.pointerType); + object.setProperty(runtime, "clientX", event.clientPoint.x); + object.setProperty(runtime, "clientY", event.clientPoint.y); + // x/y are an alias to clientX/Y + object.setProperty(runtime, "x", event.clientPoint.x); + object.setProperty(runtime, "y", event.clientPoint.y); + // since RN doesn't have a scrollable root, pageX/Y will always equal + // clientX/Y + object.setProperty(runtime, "pageX", event.clientPoint.x); + object.setProperty(runtime, "pageY", event.clientPoint.y); + object.setProperty(runtime, "screenX", event.screenPoint.x); + object.setProperty(runtime, "screenY", event.screenPoint.y); + object.setProperty(runtime, "offsetX", event.offsetPoint.x); + object.setProperty(runtime, "offsetY", event.offsetPoint.y); + object.setProperty(runtime, "width", event.width); + object.setProperty(runtime, "height", event.height); + object.setProperty(runtime, "tiltX", event.tiltX); + object.setProperty(runtime, "tiltY", event.tiltY); + object.setProperty(runtime, "detail", event.detail); + object.setProperty(runtime, "buttons", event.buttons); + object.setProperty(runtime, "tangentialPressure", event.tangentialPressure); + object.setProperty(runtime, "twist", event.twist); + object.setProperty(runtime, "ctrlKey", event.ctrlKey); + object.setProperty(runtime, "shiftKey", event.shiftKey); + object.setProperty(runtime, "altKey", event.altKey); + object.setProperty(runtime, "metaKey", event.metaKey); + return object; +} + void TouchEventEmitter::dispatchTouchEvent( - std::string const &type, + std::string type, TouchEvent const &event, EventPriority priority, RawEvent::Category category) const { dispatchEvent( - type, + std::move(type), [event](jsi::Runtime &runtime) { return touchEventPayload(runtime, event); }, @@ -73,6 +108,20 @@ void TouchEventEmitter::dispatchTouchEvent( category); } +void TouchEventEmitter::dispatchPointerEvent( + std::string type, + PointerEvent const &event, + EventPriority priority, + RawEvent::Category category) const { + dispatchEvent( + std::move(type), + [event](jsi::Runtime &runtime) { + return pointerEventPayload(runtime, event); + }, + priority, + category); +} + void TouchEventEmitter::onTouchStart(TouchEvent const &event) const { dispatchTouchEvent( "touchStart", @@ -103,5 +152,67 @@ void TouchEventEmitter::onTouchCancel(TouchEvent const &event) const { RawEvent::Category::ContinuousEnd); } +void TouchEventEmitter::onPointerCancel(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerCancel", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousEnd); +} + +void TouchEventEmitter::onPointerDown(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerDown", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousStart); +} + +void TouchEventEmitter::onPointerMove(const PointerEvent &event) const { + dispatchUniqueEvent("pointerMove", [event](jsi::Runtime &runtime) { + return pointerEventPayload(runtime, event); + }); +} + +void TouchEventEmitter::onPointerUp(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerUp", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousEnd); +} + +void TouchEventEmitter::onPointerEnter(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerEnter", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousStart); +} + +void TouchEventEmitter::onPointerLeave(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerLeave", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousEnd); +} + +void TouchEventEmitter::onPointerOver(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerOver", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousStart); +} + +void TouchEventEmitter::onPointerOut(const PointerEvent &event) const { + dispatchPointerEvent( + "pointerOut", + event, + EventPriority::AsynchronousBatched, + RawEvent::Category::ContinuousStart); +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/TouchEventEmitter.h b/ReactCommon/react/renderer/components/view/TouchEventEmitter.h index c225fbb9d6394b..18b86efb7d7074 100644 --- a/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +++ b/ReactCommon/react/renderer/components/view/TouchEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -29,12 +30,26 @@ class TouchEventEmitter : public EventEmitter { void onTouchEnd(TouchEvent const &event) const; void onTouchCancel(TouchEvent const &event) const; + void onPointerCancel(PointerEvent const &event) const; + void onPointerDown(PointerEvent const &event) const; + void onPointerMove(PointerEvent const &event) const; + void onPointerUp(PointerEvent const &event) const; + void onPointerEnter(PointerEvent const &event) const; + void onPointerLeave(PointerEvent const &event) const; + void onPointerOver(PointerEvent const &event) const; + void onPointerOut(PointerEvent const &event) const; + private: void dispatchTouchEvent( - std::string const &type, + std::string type, TouchEvent const &event, EventPriority priority, RawEvent::Category category) const; + void dispatchPointerEvent( + std::string type, + PointerEvent const &event, + EventPriority priority, + RawEvent::Category category) const; }; } // namespace react diff --git a/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h b/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h index 5379d71b946812..f9e04afb07e262 100644 --- a/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp b/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp index f978934cc239ba..4e98daa58feaf2 100644 --- a/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp +++ b/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,7 +12,7 @@ namespace react { #pragma mark - Accessibility -void ViewEventEmitter::onAccessibilityAction(const std::string &name) const { +void ViewEventEmitter::onAccessibilityAction(std::string const &name) const { dispatchEvent("accessibilityAction", [name](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); payload.setProperty(runtime, "actionName", name); diff --git a/ReactCommon/react/renderer/components/view/ViewEventEmitter.h b/ReactCommon/react/renderer/components/view/ViewEventEmitter.h index 1a4e17e84e5151..5ff128454b1a89 100644 --- a/ReactCommon/react/renderer/components/view/ViewEventEmitter.h +++ b/ReactCommon/react/renderer/components/view/ViewEventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -28,7 +28,7 @@ class ViewEventEmitter : public TouchEventEmitter { #pragma mark - Accessibility - void onAccessibilityAction(const std::string &name) const; + void onAccessibilityAction(std::string const &name) const; void onAccessibilityTap() const; void onAccessibilityMagicTap() const; void onAccessibilityEscape() const; diff --git a/ReactCommon/react/renderer/components/view/ViewProps.cpp b/ReactCommon/react/renderer/components/view/ViewProps.cpp index 1f6dfc06c39fbc..5be4a80699e40d 100644 --- a/ReactCommon/react/renderer/components/view/ViewProps.cpp +++ b/ReactCommon/react/renderer/components/view/ViewProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,146 +21,331 @@ namespace react { ViewProps::ViewProps( const PropsParserContext &context, ViewProps const &sourceProps, - RawProps const &rawProps) - : YogaStylableProps(context, sourceProps, rawProps), + RawProps const &rawProps, + bool shouldSetRawProps) + : YogaStylableProps(context, sourceProps, rawProps, shouldSetRawProps), AccessibilityProps(context, sourceProps, rawProps), - opacity(convertRawProp( - context, - rawProps, - "opacity", - sourceProps.opacity, - (Float)1.0)), - foregroundColor(convertRawProp( - context, - rawProps, - "foregroundColor", - sourceProps.foregroundColor, - {})), - backgroundColor(convertRawProp( - context, - rawProps, - "backgroundColor", - sourceProps.backgroundColor, - {})), - borderRadii(convertRawProp( - context, - rawProps, - "border", - "Radius", - sourceProps.borderRadii, - {})), - borderColors(convertRawProp( - context, - rawProps, - "border", - "Color", - sourceProps.borderColors, - {})), - borderStyles(convertRawProp( - context, - rawProps, - "border", - "Style", - sourceProps.borderStyles, - {})), - shadowColor(convertRawProp( - context, - rawProps, - "shadowColor", - sourceProps.shadowColor, - {})), - shadowOffset(convertRawProp( - context, - rawProps, - "shadowOffset", - sourceProps.shadowOffset, - {})), - shadowOpacity(convertRawProp( - context, - rawProps, - "shadowOpacity", - sourceProps.shadowOpacity, - {})), - shadowRadius(convertRawProp( - context, - rawProps, - "shadowRadius", - sourceProps.shadowRadius, - {})), - transform(convertRawProp( - context, - rawProps, - "transform", - sourceProps.transform, - {})), - backfaceVisibility(convertRawProp( - context, - rawProps, - "backfaceVisibility", - sourceProps.backfaceVisibility, - {})), - shouldRasterize(convertRawProp( - context, - rawProps, - "shouldRasterize", - sourceProps.shouldRasterize, - {})), + opacity( + Props::enablePropIteratorSetter ? sourceProps.opacity + : convertRawProp( + context, + rawProps, + "opacity", + sourceProps.opacity, + (Float)1.0)), + foregroundColor( + Props::enablePropIteratorSetter ? sourceProps.foregroundColor + : convertRawProp( + context, + rawProps, + "foregroundColor", + sourceProps.foregroundColor, + {})), + backgroundColor( + Props::enablePropIteratorSetter ? sourceProps.backgroundColor + : convertRawProp( + context, + rawProps, + "backgroundColor", + sourceProps.backgroundColor, + {})), + borderRadii( + Props::enablePropIteratorSetter ? sourceProps.borderRadii + : convertRawProp( + context, + rawProps, + "border", + "Radius", + sourceProps.borderRadii, + {})), + borderColors( + Props::enablePropIteratorSetter ? sourceProps.borderColors + : convertRawProp( + context, + rawProps, + "border", + "Color", + sourceProps.borderColors, + {})), + borderStyles( + Props::enablePropIteratorSetter ? sourceProps.borderStyles + : convertRawProp( + context, + rawProps, + "border", + "Style", + sourceProps.borderStyles, + {})), + shadowColor( + Props::enablePropIteratorSetter ? sourceProps.shadowColor + : convertRawProp( + context, + rawProps, + "shadowColor", + sourceProps.shadowColor, + {})), + shadowOffset( + Props::enablePropIteratorSetter ? sourceProps.shadowOffset + : convertRawProp( + context, + rawProps, + "shadowOffset", + sourceProps.shadowOffset, + {})), + shadowOpacity( + Props::enablePropIteratorSetter ? sourceProps.shadowOpacity + : convertRawProp( + context, + rawProps, + "shadowOpacity", + sourceProps.shadowOpacity, + {})), + shadowRadius( + Props::enablePropIteratorSetter ? sourceProps.shadowRadius + : convertRawProp( + context, + rawProps, + "shadowRadius", + sourceProps.shadowRadius, + {})), + transform( + Props::enablePropIteratorSetter ? sourceProps.transform + : convertRawProp( + context, + rawProps, + "transform", + sourceProps.transform, + {})), + backfaceVisibility( + Props::enablePropIteratorSetter ? sourceProps.backfaceVisibility + : convertRawProp( + context, + rawProps, + "backfaceVisibility", + sourceProps.backfaceVisibility, + {})), + shouldRasterize( + Props::enablePropIteratorSetter ? sourceProps.shouldRasterize + : convertRawProp( + context, + rawProps, + "shouldRasterize", + sourceProps.shouldRasterize, + {})), zIndex( - convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {})), - pointerEvents(convertRawProp( - context, - rawProps, - "pointerEvents", - sourceProps.pointerEvents, - {})), - hitSlop(convertRawProp( - context, - rawProps, - "hitSlop", - sourceProps.hitSlop, - {})), - onLayout(convertRawProp( - context, - rawProps, - "onLayout", - sourceProps.onLayout, - {})), - pointerEnter(convertRawProp( - context, - rawProps, - "pointerenter", - sourceProps.pointerEnter, - {})), - pointerLeave(convertRawProp( - context, - rawProps, - "pointerleave", - sourceProps.pointerLeave, - {})), - pointerMove(convertRawProp( - context, - rawProps, - "pointermove", - sourceProps.pointerMove, - {})), - collapsable(convertRawProp( - context, - rawProps, - "collapsable", - sourceProps.collapsable, - true)), - removeClippedSubviews(convertRawProp( - context, - rawProps, - "removeClippedSubviews", - sourceProps.removeClippedSubviews, - false)), - elevation(convertRawProp( - context, - rawProps, - "elevation", - sourceProps.elevation, - {})){}; + Props::enablePropIteratorSetter ? sourceProps.zIndex + : convertRawProp( + context, + rawProps, + "zIndex", + sourceProps.zIndex, + {})), + pointerEvents( + Props::enablePropIteratorSetter ? sourceProps.pointerEvents + : convertRawProp( + context, + rawProps, + "pointerEvents", + sourceProps.pointerEvents, + {})), + hitSlop( + Props::enablePropIteratorSetter ? sourceProps.hitSlop + : convertRawProp( + context, + rawProps, + "hitSlop", + sourceProps.hitSlop, + {})), + onLayout( + Props::enablePropIteratorSetter ? sourceProps.onLayout + : convertRawProp( + context, + rawProps, + "onLayout", + sourceProps.onLayout, + {})), + events( + Props::enablePropIteratorSetter + ? sourceProps.events + : convertRawProp(context, rawProps, sourceProps.events, {})), + collapsable( + Props::enablePropIteratorSetter ? sourceProps.collapsable + : convertRawProp( + context, + rawProps, + "collapsable", + sourceProps.collapsable, + true)), + removeClippedSubviews( + Props::enablePropIteratorSetter + ? sourceProps.removeClippedSubviews + : convertRawProp( + context, + rawProps, + "removeClippedSubviews", + sourceProps.removeClippedSubviews, + false)) +#ifdef ANDROID + , + elevation( + Props::enablePropIteratorSetter ? sourceProps.elevation + : convertRawProp( + context, + rawProps, + "elevation", + sourceProps.elevation, + {})), + nativeBackground( + Props::enablePropIteratorSetter ? sourceProps.nativeBackground + : convertRawProp( + context, + rawProps, + "nativeBackgroundAndroid", + sourceProps.nativeBackground, + {})), + nativeForeground( + Props::enablePropIteratorSetter ? sourceProps.nativeForeground + : convertRawProp( + context, + rawProps, + "nativeForegroundAndroid", + sourceProps.nativeForeground, + {})), + focusable( + Props::enablePropIteratorSetter ? sourceProps.focusable + : convertRawProp( + context, + rawProps, + "focusable", + sourceProps.focusable, + {})), + hasTVPreferredFocus( + Props::enablePropIteratorSetter ? sourceProps.hasTVPreferredFocus + : convertRawProp( + context, + rawProps, + "hasTVPreferredFocus", + sourceProps.hasTVPreferredFocus, + {})), + needsOffscreenAlphaCompositing( + Props::enablePropIteratorSetter + ? sourceProps.needsOffscreenAlphaCompositing + : convertRawProp( + context, + rawProps, + "needsOffscreenAlphaCompositing", + sourceProps.needsOffscreenAlphaCompositing, + {})), + renderToHardwareTextureAndroid( + Props::enablePropIteratorSetter + ? sourceProps.renderToHardwareTextureAndroid + : convertRawProp( + context, + rawProps, + "renderToHardwareTextureAndroid", + sourceProps.renderToHardwareTextureAndroid, + {})) + +#endif + {}; + +#define VIEW_EVENT_CASE(eventType, eventString) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(eventString): { \ + ViewEvents defaultViewEvents{}; \ + events[eventType] = ({ \ + bool res = defaultViewEvents[eventType]; \ + if (value.hasValue()) { \ + fromRawValue(context, value, res); \ + } \ + res; \ + }); \ + return; \ + } + +void ViewProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + // All Props structs setProp methods must always, unconditionally, + // call all super::setProp methods, since multiple structs may + // reuse the same values. + YogaStylableProps::setProp(context, hash, propName, value); + AccessibilityProps::setProp(context, hash, propName, value); + + switch (hash) { + RAW_SET_PROP_SWITCH_CASE_BASIC(opacity, (Float)1.0); + RAW_SET_PROP_SWITCH_CASE_BASIC(foregroundColor, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(backgroundColor, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(shadowColor, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOffset, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOpacity, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(shadowRadius, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(transform, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(backfaceVisibility, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(shouldRasterize, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(zIndex, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(pointerEvents, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(hitSlop, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(onLayout, {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(collapsable, true); + RAW_SET_PROP_SWITCH_CASE_BASIC(removeClippedSubviews, false); + // events field + VIEW_EVENT_CASE(ViewEvents::Offset::PointerEnter, "onPointerEnter"); + VIEW_EVENT_CASE( + ViewEvents::Offset::PointerEnterCapture, "onPointerEnterCapture"); + VIEW_EVENT_CASE(ViewEvents::Offset::PointerMove, "onPointerMove"); + VIEW_EVENT_CASE( + ViewEvents::Offset::PointerMoveCapture, "onPointerMoveCapture"); + VIEW_EVENT_CASE(ViewEvents::Offset::PointerLeave, "onPointerLeave"); + VIEW_EVENT_CASE( + ViewEvents::Offset::PointerLeaveCapture, "onPointerLeaveCapture"); + VIEW_EVENT_CASE(ViewEvents::Offset::PointerOver, "onPointerOver"); + VIEW_EVENT_CASE(ViewEvents::Offset::PointerOut, "onPointerOut"); + VIEW_EVENT_CASE( + ViewEvents::Offset::MoveShouldSetResponder, "onMoveShouldSetResponder"); + VIEW_EVENT_CASE( + ViewEvents::Offset::MoveShouldSetResponderCapture, + "onMoveShouldSetResponderCapture"); + VIEW_EVENT_CASE( + ViewEvents::Offset::StartShouldSetResponder, + "onStartShouldSetResponder"); + VIEW_EVENT_CASE( + ViewEvents::Offset::StartShouldSetResponderCapture, + "onStartShouldSetResponderCapture"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderGrant, "onResponderGrant"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderReject, "onResponderReject"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderStart, "onResponderStart"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderEnd, "onResponderEnd"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderRelease, "onResponderRelease"); + VIEW_EVENT_CASE(ViewEvents::Offset::ResponderMove, "ResponderMove"); + VIEW_EVENT_CASE( + ViewEvents::Offset::ResponderTerminate, "onResponderTerminate"); + VIEW_EVENT_CASE( + ViewEvents::Offset::ResponderTerminationRequest, + "onResponderTerminationRequest"); + VIEW_EVENT_CASE( + ViewEvents::Offset::ShouldBlockNativeResponder, + "onShouldBlockNativeResponder"); + VIEW_EVENT_CASE(ViewEvents::Offset::TouchStart, "onTouchStart"); + VIEW_EVENT_CASE(ViewEvents::Offset::TouchMove, "onTouchMove"); + VIEW_EVENT_CASE(ViewEvents::Offset::TouchEnd, "onTouchEnd"); + VIEW_EVENT_CASE(ViewEvents::Offset::TouchCancel, "onTouchCancel"); +#ifdef ANDROID + RAW_SET_PROP_SWITCH_CASE_BASIC(elevation, {}); + RAW_SET_PROP_SWITCH_CASE(nativeBackground, "nativeBackgroundAndroid", {}); + RAW_SET_PROP_SWITCH_CASE(nativeForeground, "nativeForegroundAndroid", {}); + RAW_SET_PROP_SWITCH_CASE_BASIC(focusable, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(hasTVPreferredFocus, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(needsOffscreenAlphaCompositing, false); + RAW_SET_PROP_SWITCH_CASE_BASIC(renderToHardwareTextureAndroid, false); +#endif + // BorderRadii + SET_CASCADED_RECTANGLE_CORNERS(borderRadii, "border", "Radius", value); + SET_CASCADED_RECTANGLE_EDGES(borderColors, "border", "Color", value); + SET_CASCADED_RECTANGLE_EDGES(borderStyles, "border", "Style", value); + } +} #pragma mark - Convenience Methods @@ -250,8 +435,6 @@ SharedDebugStringConvertibleList ViewProps::getDebugProps() const { return AccessibilityProps::getDebugProps() + YogaStylableProps::getDebugProps() + SharedDebugStringConvertibleList{ - debugStringConvertibleItem( - "zIndex", zIndex, defaultViewProps.zIndex.value_or(0)), debugStringConvertibleItem( "opacity", opacity, defaultViewProps.opacity), debugStringConvertibleItem( @@ -262,6 +445,8 @@ SharedDebugStringConvertibleList ViewProps::getDebugProps() const { "backgroundColor", backgroundColor, defaultViewProps.backgroundColor), + debugStringConvertibleItem( + "zIndex", zIndex, defaultViewProps.zIndex.value_or(0)), }; } #endif diff --git a/ReactCommon/react/renderer/components/view/ViewProps.h b/ReactCommon/react/renderer/components/view/ViewProps.h index 558105face731e..21a425dc73fe7e 100644 --- a/ReactCommon/react/renderer/components/view/ViewProps.h +++ b/ReactCommon/react/renderer/components/view/ViewProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -30,7 +32,14 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps { ViewProps( const PropsParserContext &context, ViewProps const &sourceProps, - RawProps const &rawProps); + RawProps const &rawProps, + bool shouldSetRawProps = true); + + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); #pragma mark - Props @@ -54,18 +63,14 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps { Transform transform{}; BackfaceVisibility backfaceVisibility{}; bool shouldRasterize{}; - better::optional zIndex{}; + std::optional zIndex{}; // Events PointerEventsMode pointerEvents{}; EdgeInsets hitSlop{}; bool onLayout{}; - bool pointerEnter{}; - - bool pointerLeave{}; - - bool pointerMove{}; + ViewEvents events{}; bool collapsable{true}; @@ -73,6 +78,18 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps { Float elevation{}; /* Android-only */ +#ifdef ANDROID + + std::optional nativeBackground{}; + std::optional nativeForeground{}; + + bool focusable{false}; + bool hasTVPreferredFocus{false}; + bool needsOffscreenAlphaCompositing{false}; + bool renderToHardwareTextureAndroid{false}; + +#endif + #pragma mark - Convenience Methods BorderMetrics resolveBorderMetrics(LayoutMetrics const &layoutMetrics) const; diff --git a/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h b/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h index cc4567abc69625..dfbd0fc380203f 100644 --- a/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h +++ b/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,9 +20,9 @@ namespace react { */ static inline void interpolateViewProps( Float animationProgress, - const SharedProps &oldPropsShared, - const SharedProps &newPropsShared, - SharedProps &interpolatedPropsShared) { + const Props::Shared &oldPropsShared, + const Props::Shared &newPropsShared, + Props::Shared &interpolatedPropsShared) { ViewProps const *oldViewProps = static_cast(oldPropsShared.get()); ViewProps const *newViewProps = @@ -44,10 +44,12 @@ static inline void interpolateViewProps( // mounting layer. Once we can remove this, we should change `rawProps` to // be const again. #ifdef ANDROID - interpolatedProps->rawProps["opacity"] = interpolatedProps->opacity; + if (!interpolatedProps->rawProps.isNull()) { + interpolatedProps->rawProps["opacity"] = interpolatedProps->opacity; - interpolatedProps->rawProps["transform"] = - (folly::dynamic)interpolatedProps->transform; + interpolatedProps->rawProps["transform"] = + (folly::dynamic)interpolatedProps->transform; + } #endif } diff --git a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp index e3958638f86ccf..61661c1af41615 100644 --- a/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #include "ViewShadowNode.h" +#include #include namespace facebook { @@ -13,6 +14,37 @@ namespace react { char const ViewComponentName[] = "View"; +static inline bool keepRawValuesInViewProps(PropsParserContext const &context) { + static bool shouldUseRawProps = true; + +#ifdef ANDROID + static bool initialized = false; + + if (!initialized) { + auto config = + context.contextContainer.find>( + "ReactNativeConfig"); + if (config.has_value()) { + initialized = true; + shouldUseRawProps = !config.value()->getBool( + "react_native_new_architecture:use_mapbuffer_for_viewprops"); + } + } +#endif + + return shouldUseRawProps; +} + +ViewShadowNodeProps::ViewShadowNodeProps( + PropsParserContext const &context, + ViewShadowNodeProps const &sourceProps, + RawProps const &rawProps) + : ViewProps( + context, + sourceProps, + rawProps, + keepRawValuesInViewProps(context)){}; + ViewShadowNode::ViewShadowNode( ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, @@ -33,26 +65,36 @@ void ViewShadowNode::initialize() noexcept { bool formsStackingContext = !viewProps.collapsable || viewProps.pointerEvents == PointerEventsMode::None || - viewProps.onLayout || viewProps.pointerEnter || viewProps.pointerLeave || - viewProps.pointerMove || !viewProps.nativeId.empty() || - viewProps.accessible || viewProps.opacity != 1.0 || - viewProps.transform != Transform{} || viewProps.elevation != 0 || + !viewProps.nativeId.empty() || viewProps.accessible || + viewProps.opacity != 1.0 || viewProps.transform != Transform{} || (viewProps.zIndex.has_value() && viewProps.yogaStyle.positionType() != YGPositionTypeStatic) || viewProps.yogaStyle.display() == YGDisplayNone || - viewProps.getClipsContentToBounds() || + viewProps.getClipsContentToBounds() || viewProps.events.bits.any() || isColorMeaningful(viewProps.shadowColor) || viewProps.accessibilityElementsHidden || viewProps.accessibilityViewIsModal || viewProps.importantForAccessibility != ImportantForAccessibility::Auto || viewProps.removeClippedSubviews; +#ifdef ANDROID + formsStackingContext = formsStackingContext || viewProps.elevation != 0; +#endif + bool formsView = formsStackingContext || isColorMeaningful(viewProps.backgroundColor) || isColorMeaningful(viewProps.foregroundColor) || !(viewProps.yogaStyle.border() == YGStyle::Edges{}) || !viewProps.testId.empty(); +#ifdef ANDROID + formsView = formsView || viewProps.nativeBackground.has_value() || + viewProps.nativeForeground.has_value() || viewProps.focusable || + viewProps.hasTVPreferredFocus || + viewProps.needsOffscreenAlphaCompositing || + viewProps.renderToHardwareTextureAndroid; +#endif + if (formsView) { traits_.set(ShadowNodeTraits::Trait::FormsView); } else { diff --git a/ReactCommon/react/renderer/components/view/ViewShadowNode.h b/ReactCommon/react/renderer/components/view/ViewShadowNode.h index 20ccc04d5f4504..d62f63ed6b8d2c 100644 --- a/ReactCommon/react/renderer/components/view/ViewShadowNode.h +++ b/ReactCommon/react/renderer/components/view/ViewShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,12 +15,24 @@ namespace react { extern const char ViewComponentName[]; +/** + * Implementation of the ViewProps that propagates feature flag. + */ +class ViewShadowNodeProps final : public ViewProps { + public: + ViewShadowNodeProps() = default; + ViewShadowNodeProps( + const PropsParserContext &context, + ViewShadowNodeProps const &sourceProps, + RawProps const &rawProps); +}; + /* * `ShadowNode` for component. */ class ViewShadowNode final : public ConcreteViewShadowNode< ViewComponentName, - ViewProps, + ViewShadowNodeProps, ViewEventEmitter> { public: static ShadowNodeTraits BaseTraits() { diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 0c5ccdf083c796..29ef3edf2e8742 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,7 +33,7 @@ static int FabricDefaultYogaLog( va_copy(args_copy, args); // Adding 1 to add space for terminating null character. - int size_s = vsnprintf(NULL, 0, format, args); + int size_s = vsnprintf(nullptr, 0, format, args); auto size = static_cast(size_s); std::vector buffer(size); @@ -479,7 +479,6 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { react_native_assert(!yogaNode_.isDirty()); auto contentFrame = Rect{}; - for (auto childYogaNode : yogaNode_.getChildren()) { auto &childNode = *static_cast(childYogaNode->getContext()); @@ -521,13 +520,34 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { auto layoutMetricsWithOverflowInset = childNode.getLayoutMetrics(); if (layoutMetricsWithOverflowInset.displayType != DisplayType::None) { + // The contentFrame should always union with existing child node layout + + // overflowInset. The transform may in a deferred animation and not + // applied yet. contentFrame.unionInPlace(insetBy( layoutMetricsWithOverflowInset.frame, layoutMetricsWithOverflowInset.overflowInset)); + + auto childTransform = childNode.getTransform(); + if (childTransform != Transform::Identity()) { + // The child node's transform matrix will affect the parent node's + // contentFrame. We need to union with child node's after transform + // layout here. + contentFrame.unionInPlace(insetBy( + layoutMetricsWithOverflowInset.frame * childTransform, + layoutMetricsWithOverflowInset.overflowInset * childTransform)); + } } } if (yogaNode_.getStyle().overflow() == YGOverflowVisible) { + // Note that the parent node's overflow layout is NOT affected by its + // transform matrix. That transform matrix is applied on the parent node as + // well as all of its child nodes, which won't cause changes on the + // overflowInset values. A special note on the scale transform -- the scaled + // layout may look like it's causing overflowInset changes, but it's purely + // cosmetic and will be handled by pixel density conversion logic later when + // render the view. The actual overflowInset value is not changed as if the + // transform is not happening here. layoutMetrics_.overflowInset = calculateOverflowInset(layoutMetrics_.frame, contentFrame); } else { @@ -681,44 +701,44 @@ void YogaLayoutableShadowNode::swapLeftAndRightInViewProps( auto &props = const_cast(typedCasting); // Swap border node values, borderRadii, borderColors and borderStyles. - if (props.borderRadii.topLeft.hasValue()) { + if (props.borderRadii.topLeft.has_value()) { props.borderRadii.topStart = props.borderRadii.topLeft; - props.borderRadii.topLeft.clear(); + props.borderRadii.topLeft.reset(); } - if (props.borderRadii.bottomLeft.hasValue()) { + if (props.borderRadii.bottomLeft.has_value()) { props.borderRadii.bottomStart = props.borderRadii.bottomLeft; - props.borderRadii.bottomLeft.clear(); + props.borderRadii.bottomLeft.reset(); } - if (props.borderRadii.topRight.hasValue()) { + if (props.borderRadii.topRight.has_value()) { props.borderRadii.topEnd = props.borderRadii.topRight; - props.borderRadii.topRight.clear(); + props.borderRadii.topRight.reset(); } - if (props.borderRadii.bottomRight.hasValue()) { + if (props.borderRadii.bottomRight.has_value()) { props.borderRadii.bottomEnd = props.borderRadii.bottomRight; - props.borderRadii.bottomRight.clear(); + props.borderRadii.bottomRight.reset(); } - if (props.borderColors.left.hasValue()) { + if (props.borderColors.left.has_value()) { props.borderColors.start = props.borderColors.left; - props.borderColors.left.clear(); + props.borderColors.left.reset(); } - if (props.borderColors.right.hasValue()) { + if (props.borderColors.right.has_value()) { props.borderColors.end = props.borderColors.right; - props.borderColors.right.clear(); + props.borderColors.right.reset(); } - if (props.borderStyles.left.hasValue()) { + if (props.borderStyles.left.has_value()) { props.borderStyles.start = props.borderStyles.left; - props.borderStyles.left.clear(); + props.borderStyles.left.reset(); } - if (props.borderStyles.right.hasValue()) { + if (props.borderStyles.right.has_value()) { props.borderStyles.end = props.borderStyles.right; - props.borderStyles.right.clear(); + props.borderStyles.right.reset(); } YGStyle::Edges const &border = props.yogaStyle.border(); diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h index 77ba8131145891..fe95d354930a99 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,7 +25,7 @@ namespace react { class YogaLayoutableShadowNode : public LayoutableShadowNode { public: - using UnsharedList = better::small_vector< + using UnsharedList = butter::small_vector< YogaLayoutableShadowNode *, kShadowNodeChildrenSmallVectorSize>; diff --git a/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp b/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp index d8c44f49f5c165..d021d03611c2ca 100644 --- a/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp +++ b/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,9 +22,107 @@ namespace react { YogaStylableProps::YogaStylableProps( const PropsParserContext &context, YogaStylableProps const &sourceProps, - RawProps const &rawProps) - : Props(context, sourceProps, rawProps), - yogaStyle(convertRawProp(context, rawProps, sourceProps.yogaStyle)){}; + RawProps const &rawProps, + bool shouldSetRawProps) + : Props(context, sourceProps, rawProps, shouldSetRawProps), + yogaStyle( + Props::enablePropIteratorSetter + ? sourceProps.yogaStyle + : convertRawProp(context, rawProps, sourceProps.yogaStyle)){}; + +template +static inline T const getFieldValue( + const PropsParserContext &context, + RawValue const &value, + T const defaultValue) { + if (value.hasValue()) { + T res; + fromRawValue(context, value, res); + return res; + } + + return defaultValue; +} + +#define REBUILD_FIELD_SWITCH_CASE2(field, fieldName) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \ + yogaStyle.field() = getFieldValue(context, value, defaults.field()); \ + return; \ + } + +#define REBUILD_FIELD_SWITCH_CASE(field) \ + REBUILD_FIELD_SWITCH_CASE2(field, #field) + +#define REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, index, fieldName) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \ + yogaStyle.field()[index] = \ + getFieldValue(context, value, defaults.field()[index]); \ + return; \ + } + +#define REBUILD_FIELD_YG_DIMENSION(field, widthStr, heightStr) \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, YGDimensionWidth, widthStr); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, YGDimensionHeight, heightStr); + +#define REBUILD_FIELD_YG_EDGES(field, prefix, suffix) \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeLeft, prefix "Left" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, YGEdgeTop, prefix "Top" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeRight, prefix "Right" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeBottom, prefix "Bottom" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeStart, prefix "Start" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, YGEdgeEnd, prefix "End" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeHorizontal, prefix "Horizontal" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \ + field, YGEdgeVertical, prefix "Vertical" suffix); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, YGEdgeAll, prefix "" suffix); + +#define REBUILD_FIELD_YG_EDGES_POSITION() \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeLeft, "left"); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeTop, "top"); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeRight, "right"); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeBottom, "bottom"); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeStart, "start"); \ + REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeEnd, "end"); + +void YogaStylableProps::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + static const auto defaults = YGStyle{}; + + Props::setProp(context, hash, propName, value); + + switch (hash) { + REBUILD_FIELD_SWITCH_CASE(direction); + REBUILD_FIELD_SWITCH_CASE(flexDirection); + REBUILD_FIELD_SWITCH_CASE(justifyContent); + REBUILD_FIELD_SWITCH_CASE(alignContent); + REBUILD_FIELD_SWITCH_CASE(alignItems); + REBUILD_FIELD_SWITCH_CASE(alignSelf); + REBUILD_FIELD_SWITCH_CASE(flexWrap); + REBUILD_FIELD_SWITCH_CASE(overflow); + REBUILD_FIELD_SWITCH_CASE(display); + REBUILD_FIELD_SWITCH_CASE(flex); + REBUILD_FIELD_SWITCH_CASE(flexGrow); + REBUILD_FIELD_SWITCH_CASE(flexShrink); + REBUILD_FIELD_SWITCH_CASE(flexBasis); + REBUILD_FIELD_SWITCH_CASE2(positionType, "position"); + REBUILD_FIELD_SWITCH_CASE(aspectRatio); + REBUILD_FIELD_YG_DIMENSION(dimensions, "width", "height"); + REBUILD_FIELD_YG_DIMENSION(minDimensions, "minWidth", "minHeight"); + REBUILD_FIELD_YG_DIMENSION(maxDimensions, "maxWidth", "maxHeight"); + REBUILD_FIELD_YG_EDGES_POSITION(); + REBUILD_FIELD_YG_EDGES(margin, "margin", ""); + REBUILD_FIELD_YG_EDGES(padding, "padding", ""); + REBUILD_FIELD_YG_EDGES(border, "border", "Width"); + } +} #pragma mark - DebugStringConvertible diff --git a/ReactCommon/react/renderer/components/view/YogaStylableProps.h b/ReactCommon/react/renderer/components/view/YogaStylableProps.h index 3d6e314d6c0fb6..86cf60e81be2ce 100644 --- a/ReactCommon/react/renderer/components/view/YogaStylableProps.h +++ b/ReactCommon/react/renderer/components/view/YogaStylableProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,7 +22,14 @@ class YogaStylableProps : public Props { YogaStylableProps( const PropsParserContext &context, YogaStylableProps const &sourceProps, - RawProps const &rawProps); + RawProps const &rawProps, + bool shouldSetRawProps = true); + + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); #pragma mark - Props diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index 92c52527cd55da..6659e9d7104db3 100644 --- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -133,7 +133,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AccessibilityState &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto selected = map.find("selected"); if (selected != map.end()) { fromRawValue(context, selected->second, result.selected); @@ -212,7 +212,7 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AccessibilityAction &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto name = map.find("name"); react_native_assert(name != map.end() && name->second.hasType()); @@ -232,7 +232,7 @@ inline void fromRawValue( const PropsParserContext &, const RawValue &value, AccessibilityValue &result) { - auto map = (better::map)value; + auto map = (butter::map)value; auto min = map.find("min"); if (min != map.end()) { @@ -263,5 +263,38 @@ inline void fromRawValue( } } +inline void fromRawValue( + const PropsParserContext &context, + const RawValue &value, + AccessibilityLabelledBy &result) { + if (value.hasType()) { + result.value.push_back((std::string)value); + } else if (value.hasType>()) { + result.value = (std::vector)value; + } +} + +inline void fromRawValue( + const PropsParserContext &context, + const RawValue &value, + AccessibilityLiveRegion &result) { + react_native_assert(value.hasType()); + if (value.hasType()) { + auto string = (std::string)value; + if (string == "none") { + result = AccessibilityLiveRegion::None; + } else if (string == "polite") { + result = AccessibilityLiveRegion::Polite; + } else if (string == "assertive") { + result = AccessibilityLiveRegion::Assertive; + } else { + LOG(ERROR) << "Unsupported AccessibilityLiveRegion value: " << string; + react_native_assert(false); + } + } else { + LOG(ERROR) << "Unsupported AccessibilityLiveRegion type"; + } +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/conversions.h b/ReactCommon/react/renderer/components/view/conversions.h index 36fc9d507f1366..f70c9f9b9b00cd 100644 --- a/ReactCommon/react/renderer/components/view/conversions.h +++ b/ReactCommon/react/renderer/components/view/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,7 @@ #pragma once -#include -#include +#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -98,9 +98,9 @@ inline YGValue yogaStyleValueFromFloat( return {(float)value, unit}; } -inline better::optional optionalFloatFromYogaValue( +inline std::optional optionalFloatFromYogaValue( const YGValue value, - better::optional base = {}) { + std::optional base = {}) { switch (value.unit) { case YGUnitUndefined: return {}; @@ -108,9 +108,8 @@ inline better::optional optionalFloatFromYogaValue( return floatFromYogaFloat(value.value); case YGUnitPercent: return base.has_value() - ? better::optional( - base.value() * floatFromYogaFloat(value.value)) - : better::optional(); + ? std::optional(base.value() * floatFromYogaFloat(value.value)) + : std::optional(); case YGUnitAuto: return {}; } @@ -393,8 +392,11 @@ inline void fromRawValue( YGUnitPercent}; return; } else { - result = YGValue{folly::to(stringValue), YGUnitPoint}; - return; + auto tryValue = folly::tryTo(stringValue); + if (tryValue.hasValue()) { + result = YGValue{tryValue.value(), YGUnitPoint}; + return; + } } } } @@ -444,14 +446,14 @@ inline void fromRawValue( auto configurations = static_cast>(value); for (const auto &configuration : configurations) { - if (!configuration.hasType>()) { + if (!configuration.hasType>()) { // TODO: The following checks have to be removed after codegen is shipped. // See T45151459. continue; } auto configurationPair = - static_cast>(configuration); + static_cast>(configuration); auto pair = configurationPair.begin(); auto operation = pair->first; auto ¶meters = pair->second; diff --git a/ReactCommon/react/renderer/components/view/primitives.h b/ReactCommon/react/renderer/components/view/primitives.h index 52e5f3f08c218f..16b02c2dd8c8a7 100644 --- a/ReactCommon/react/renderer/components/view/primitives.h +++ b/ReactCommon/react/renderer/components/view/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,17 +7,74 @@ #pragma once -#include #include #include + #include +#include #include +#include namespace facebook { namespace react { enum class PointerEventsMode { Auto, None, BoxNone, BoxOnly }; +struct ViewEvents { + std::bitset<32> bits{}; + + enum class Offset : std::size_t { + // Pointer events + PointerEnter = 0, + PointerMove = 1, + PointerLeave = 2, + + // PanResponder callbacks + MoveShouldSetResponder = 3, + MoveShouldSetResponderCapture = 4, + StartShouldSetResponder = 5, + StartShouldSetResponderCapture = 6, + ResponderGrant = 7, + ResponderReject = 8, + ResponderStart = 9, + ResponderEnd = 10, + ResponderRelease = 11, + ResponderMove = 12, + ResponderTerminate = 13, + ResponderTerminationRequest = 14, + ShouldBlockNativeResponder = 15, + + // Touch events + TouchStart = 16, + TouchMove = 17, + TouchEnd = 18, + TouchCancel = 19, + + // W3C Pointer Events + PointerEnterCapture = 23, + PointerLeaveCapture = 24, + PointerMoveCapture = 25, + PointerOver = 26, + PointerOut = 27, + }; + + constexpr bool operator[](const Offset offset) const { + return bits[static_cast(offset)]; + } + + std::bitset<32>::reference operator[](const Offset offset) { + return bits[static_cast(offset)]; + } +}; + +inline static bool operator==(ViewEvents const &lhs, ViewEvents const &rhs) { + return lhs.bits == rhs.bits; +} + +inline static bool operator!=(ViewEvents const &lhs, ViewEvents const &rhs) { + return lhs.bits != rhs.bits; +} + enum class BackfaceVisibility { Auto, Visible, Hidden }; enum class BorderStyle { Solid, Dotted, Dashed }; @@ -25,7 +82,7 @@ enum class BorderStyle { Solid, Dotted, Dashed }; template struct CascadedRectangleEdges { using Counterpart = RectangleEdges; - using OptionalT = better::optional; + using OptionalT = std::optional; OptionalT left{}; OptionalT top{}; @@ -86,7 +143,7 @@ struct CascadedRectangleEdges { template struct CascadedRectangleCorners { using Counterpart = RectangleCorners; - using OptionalT = better::optional; + using OptionalT = std::optional; OptionalT topLeft{}; OptionalT topRight{}; @@ -178,5 +235,48 @@ struct BorderMetrics { } }; +#ifdef ANDROID + +struct NativeDrawable { + enum class Kind { + Ripple, + ThemeAttr, + }; + + struct Ripple { + std::optional color{}; + bool borderless{false}; + std::optional rippleRadius{}; + + bool operator==(const Ripple &rhs) const { + return std::tie(this->color, this->borderless, this->rippleRadius) == + std::tie(rhs.color, rhs.borderless, rhs.rippleRadius); + } + }; + + Kind kind; + std::string themeAttr; + Ripple ripple; + + bool operator==(const NativeDrawable &rhs) const { + if (this->kind != rhs.kind) + return false; + switch (this->kind) { + case Kind::ThemeAttr: + return this->themeAttr == rhs.themeAttr; + case Kind::Ripple: + return this->ripple == rhs.ripple; + } + } + + bool operator!=(const NativeDrawable &rhs) const { + return !(*this == rhs); + } + + ~NativeDrawable() = default; +}; + +#endif + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/propsConversions.h b/ReactCommon/react/renderer/components/view/propsConversions.h index 5f91adc5cbdaef..f045dd3b9bc664 100644 --- a/ReactCommon/react/renderer/components/view/propsConversions.h +++ b/ReactCommon/react/renderer/components/view/propsConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,9 +11,13 @@ #include #include +#include + namespace facebook { namespace react { +// Nearly this entire file can be deleted when iterator-style Prop parsing +// ships fully for View static inline YGStyle::Dimensions convertRawProp( const PropsParserContext &context, RawProps const &rawProps, @@ -33,7 +37,7 @@ static inline YGStyle::Dimensions convertRawProp( rawProps, heightName, sourceValue[YGDimensionHeight], - defaultValue[YGDimensionWidth]); + defaultValue[YGDimensionHeight]); return dimensions; } @@ -299,6 +303,7 @@ static inline YGStyle convertRawProp( return yogaStyle; } +// This can be deleted when non-iterator ViewProp parsing is deleted template static inline CascadedRectangleCorners convertRawProp( const PropsParserContext &context, @@ -463,5 +468,227 @@ static inline CascadedRectangleEdges convertRawProp( return result; } +// This can be deleted when non-iterator ViewProp parsing is deleted +static inline ViewEvents convertRawProp( + const PropsParserContext &context, + RawProps const &rawProps, + ViewEvents const &sourceValue, + ViewEvents const &defaultValue) { + ViewEvents result{}; + using Offset = ViewEvents::Offset; + + result[Offset::PointerEnter] = convertRawProp( + context, + rawProps, + "onPointerEnter", + sourceValue[Offset::PointerEnter], + defaultValue[Offset::PointerEnter]); + result[Offset::PointerMove] = convertRawProp( + context, + rawProps, + "onPointerMove", + sourceValue[Offset::PointerMove], + defaultValue[Offset::PointerMove]); + result[Offset::PointerLeave] = convertRawProp( + context, + rawProps, + "onPointerLeave", + sourceValue[Offset::PointerLeave], + defaultValue[Offset::PointerLeave]); + + // Experimental W3C Pointer callbacks + result[Offset::PointerEnterCapture] = convertRawProp( + context, + rawProps, + "onPointerEnterCapture", + sourceValue[Offset::PointerEnterCapture], + defaultValue[Offset::PointerEnterCapture]); + result[Offset::PointerMoveCapture] = convertRawProp( + context, + rawProps, + "onPointerMoveCapture", + sourceValue[Offset::PointerMoveCapture], + defaultValue[Offset::PointerMoveCapture]); + result[Offset::PointerLeaveCapture] = convertRawProp( + context, + rawProps, + "onPointerLeaveCapture", + sourceValue[Offset::PointerLeaveCapture], + defaultValue[Offset::PointerLeaveCapture]); + result[Offset::PointerOver] = convertRawProp( + context, + rawProps, + "onPointerOver", + sourceValue[Offset::PointerOver], + defaultValue[Offset::PointerOver]); + result[Offset::PointerOut] = convertRawProp( + context, + rawProps, + "onPointerOut", + sourceValue[Offset::PointerOut], + defaultValue[Offset::PointerOut]); + + // PanResponder callbacks + result[Offset::MoveShouldSetResponder] = convertRawProp( + context, + rawProps, + "onMoveShouldSetResponder", + sourceValue[Offset::MoveShouldSetResponder], + defaultValue[Offset::MoveShouldSetResponder]); + result[Offset::MoveShouldSetResponderCapture] = convertRawProp( + context, + rawProps, + "onMoveShouldSetResponderCapture", + sourceValue[Offset::MoveShouldSetResponderCapture], + defaultValue[Offset::MoveShouldSetResponderCapture]); + result[Offset::StartShouldSetResponder] = convertRawProp( + context, + rawProps, + "onStartShouldSetResponder", + sourceValue[Offset::StartShouldSetResponder], + defaultValue[Offset::StartShouldSetResponder]); + result[Offset::StartShouldSetResponderCapture] = convertRawProp( + context, + rawProps, + "onStartShouldSetResponderCapture", + sourceValue[Offset::StartShouldSetResponderCapture], + defaultValue[Offset::StartShouldSetResponderCapture]); + result[Offset::ResponderGrant] = convertRawProp( + context, + rawProps, + "onResponderGrant", + sourceValue[Offset::ResponderGrant], + defaultValue[Offset::ResponderGrant]); + result[Offset::ResponderReject] = convertRawProp( + context, + rawProps, + "onResponderReject", + sourceValue[Offset::ResponderReject], + defaultValue[Offset::ResponderReject]); + result[Offset::ResponderStart] = convertRawProp( + context, + rawProps, + "onResponderStart", + sourceValue[Offset::ResponderStart], + defaultValue[Offset::ResponderStart]); + result[Offset::ResponderEnd] = convertRawProp( + context, + rawProps, + "onResponderEnd", + sourceValue[Offset::ResponderEnd], + defaultValue[Offset::ResponderEnd]); + result[Offset::ResponderRelease] = convertRawProp( + context, + rawProps, + "onResponderRelease", + sourceValue[Offset::ResponderRelease], + defaultValue[Offset::ResponderRelease]); + result[Offset::ResponderMove] = convertRawProp( + context, + rawProps, + "onResponderMove", + sourceValue[Offset::ResponderMove], + defaultValue[Offset::ResponderMove]); + result[Offset::ResponderTerminate] = convertRawProp( + context, + rawProps, + "onResponderTerminate", + sourceValue[Offset::ResponderTerminate], + defaultValue[Offset::ResponderTerminate]); + result[Offset::ResponderTerminationRequest] = convertRawProp( + context, + rawProps, + "onResponderTerminationRequest", + sourceValue[Offset::ResponderTerminationRequest], + defaultValue[Offset::ResponderTerminationRequest]); + result[Offset::ShouldBlockNativeResponder] = convertRawProp( + context, + rawProps, + "onShouldBlockNativeResponder", + sourceValue[Offset::ShouldBlockNativeResponder], + defaultValue[Offset::ShouldBlockNativeResponder]); + + // Touch events + result[Offset::TouchStart] = convertRawProp( + context, + rawProps, + "onTouchStart", + sourceValue[Offset::TouchStart], + defaultValue[Offset::TouchStart]); + result[Offset::TouchMove] = convertRawProp( + context, + rawProps, + "onTouchMove", + sourceValue[Offset::TouchMove], + defaultValue[Offset::TouchMove]); + result[Offset::TouchEnd] = convertRawProp( + context, + rawProps, + "onTouchEnd", + sourceValue[Offset::TouchEnd], + defaultValue[Offset::TouchEnd]); + result[Offset::TouchCancel] = convertRawProp( + context, + rawProps, + "onTouchCancel", + sourceValue[Offset::TouchCancel], + defaultValue[Offset::TouchCancel]); + + return result; +} + +#ifdef ANDROID + +static inline void fromRawValue( + const PropsParserContext &context, + RawValue const &rawValue, + NativeDrawable &result) { + auto map = (butter::map)rawValue; + + auto typeIterator = map.find("type"); + react_native_assert( + typeIterator != map.end() && typeIterator->second.hasType()); + std::string type = (std::string)typeIterator->second; + + if (type == "ThemeAttrAndroid") { + auto attrIterator = map.find("attribute"); + react_native_assert( + attrIterator != map.end() && + attrIterator->second.hasType()); + + result = NativeDrawable{ + .kind = NativeDrawable::Kind::ThemeAttr, + .themeAttr = (std::string)attrIterator->second, + }; + } else if (type == "RippleAndroid") { + auto color = map.find("color"); + auto borderless = map.find("borderless"); + auto rippleRadius = map.find("rippleRadius"); + + result = NativeDrawable{ + .kind = NativeDrawable::Kind::Ripple, + .ripple = + NativeDrawable::Ripple{ + .color = color != map.end() && color->second.hasType() + ? (int32_t)color->second + : std::optional{}, + .borderless = borderless != map.end() && + borderless->second.hasType() + ? (bool)borderless->second + : false, + .rippleRadius = rippleRadius != map.end() && + rippleRadius->second.hasType() + ? (Float)rippleRadius->second + : std::optional{}, + }, + }; + } else { + LOG(ERROR) << "Unknown native drawable type: " << type; + react_native_assert(false); + } +} + +#endif + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp b/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp index 840547d8e66838..691fb5b6bec922 100644 --- a/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp +++ b/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,9 @@ namespace facebook { namespace react { +// Note: the (x, y) origin is always relative to the parent node. You may use +// P482342650 to re-create this test case in playground. + // *******************************************************┌─ABCD:────┐**** // *******************************************************│ {70,-50} │**** // *******************************************************│ {30,60} │**** @@ -43,6 +46,8 @@ namespace react { // ***********************│ │************************************ // ***********************└──────────┘************************************ +enum TestCase { AS_IS, CLIPPING, TRANSFORM_SCALE, TRANSFORM_TRANSLATE }; + class LayoutTest : public ::testing::Test { protected: ComponentBuilder builder_; @@ -55,7 +60,7 @@ class LayoutTest : public ::testing::Test { LayoutTest() : builder_(simpleComponentBuilder()) {} - void initialize(bool enforceClippingForABC) { + void initialize(TestCase testCase) { // clang-format off auto element = Element() @@ -73,8 +78,9 @@ class LayoutTest : public ::testing::Test { .children({ Element() .reference(viewShadowNodeA_) + .tag(2) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.positionType() = YGPositionTypeAbsolute; @@ -85,8 +91,9 @@ class LayoutTest : public ::testing::Test { .children({ Element() .reference(viewShadowNodeAB_) - .props([] { - auto sharedProps = std::make_shared(); + .tag(3) + .props([=] { + auto sharedProps = std::make_shared(); auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.positionType() = YGPositionTypeAbsolute; @@ -94,17 +101,26 @@ class LayoutTest : public ::testing::Test { yogaStyle.position()[YGEdgeTop] = YGValue{10, YGUnitPoint}; yogaStyle.dimensions()[YGDimensionWidth] = YGValue{30, YGUnitPoint}; yogaStyle.dimensions()[YGDimensionHeight] = YGValue{90, YGUnitPoint}; + + if (testCase == TRANSFORM_SCALE) { + props.transform = props.transform * Transform::Scale(2, 2, 1); + } + + if (testCase == TRANSFORM_TRANSLATE) { + props.transform = props.transform * Transform::Translate(10, 10, 0); + } return sharedProps; }) .children({ Element() .reference(viewShadowNodeABC_) + .tag(4) .props([=] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; - if (enforceClippingForABC) { + if (testCase == CLIPPING) { yogaStyle.overflow() = YGOverflowHidden; } @@ -118,8 +134,9 @@ class LayoutTest : public ::testing::Test { .children({ Element() .reference(viewShadowNodeABCD_) + .tag(5) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.positionType() = YGPositionTypeAbsolute; @@ -132,8 +149,9 @@ class LayoutTest : public ::testing::Test { }), Element() .reference(viewShadowNodeABE_) + .tag(6) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.positionType() = YGPositionTypeAbsolute; @@ -154,32 +172,191 @@ class LayoutTest : public ::testing::Test { } }; +// Test the layout as described above with no extra changes TEST_F(LayoutTest, overflowInsetTest) { - initialize(false); + initialize(AS_IS); + + auto layoutMetricsA = viewShadowNodeA_->getLayoutMetrics(); - auto layoutMetrics = viewShadowNodeA_->getLayoutMetrics(); + EXPECT_EQ(layoutMetricsA.frame.size.width, 50); + EXPECT_EQ(layoutMetricsA.frame.size.height, 50); - EXPECT_EQ(layoutMetrics.frame.size.width, 50); - EXPECT_EQ(layoutMetrics.frame.size.height, 50); + EXPECT_EQ(layoutMetricsA.overflowInset.left, -50); + EXPECT_EQ(layoutMetricsA.overflowInset.top, -30); + EXPECT_EQ(layoutMetricsA.overflowInset.right, -80); + EXPECT_EQ(layoutMetricsA.overflowInset.bottom, -50); - EXPECT_EQ(layoutMetrics.overflowInset.left, -50); - EXPECT_EQ(layoutMetrics.overflowInset.top, -30); - EXPECT_EQ(layoutMetrics.overflowInset.right, -80); - EXPECT_EQ(layoutMetrics.overflowInset.bottom, -50); + auto layoutMetricsABC = viewShadowNodeABC_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsABC.frame.size.width, 110); + EXPECT_EQ(layoutMetricsABC.frame.size.height, 20); + + EXPECT_EQ(layoutMetricsABC.overflowInset.left, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.top, -50); + EXPECT_EQ(layoutMetricsABC.overflowInset.right, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.bottom, 0); } +// Test when box ABC has clipping (aka overflow hidden) TEST_F(LayoutTest, overflowInsetWithClippingTest) { - initialize(true); + initialize(CLIPPING); + + auto layoutMetricsA = viewShadowNodeA_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsA.frame.size.width, 50); + EXPECT_EQ(layoutMetricsA.frame.size.height, 50); + + EXPECT_EQ(layoutMetricsA.overflowInset.left, -50); + EXPECT_EQ(layoutMetricsA.overflowInset.top, 0); + EXPECT_EQ(layoutMetricsA.overflowInset.right, -80); + EXPECT_EQ(layoutMetricsA.overflowInset.bottom, -50); + + auto layoutMetricsABC = viewShadowNodeABC_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsABC.frame.size.width, 110); + EXPECT_EQ(layoutMetricsABC.frame.size.height, 20); + + EXPECT_EQ(layoutMetricsABC.overflowInset.left, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.top, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.right, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.bottom, 0); +} + +// Test when box AB translate (10, 10, 0) in transform. The parent node's +// overflowInset will be affected, but the transformed node and its child nodes +// are not affected. Here is an example: +// +// ┌────────────────┐ ┌────────────────┐ +// │Original Layout │ │ Translate AB │ +// └────────────────┘ └────────────────┘ +// ─────▶ +// ┌ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ┐ ┌ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ─ ┐ +// │ A │ │ A │ +// │ │ │ │ │ │ │ │ +// ─ ─ ─ ─│─ ─ ─┌───┐┼ ─ ─ ─ ─ │ │ +// │ │ │AB ││ │ │ ┌ ─ ─ ┼ ─ ─ ─ ┬──┴┬ ─ ─ ─ ─ ┤ +// └─────┤ ├┘ └───────┤AB │ +// │ │┌──┴─────────┤ │ │ │ │ │ +// ││ABC │ │┌──┴─────────┐ +// │ │└──┬─────────┤ │ │ │ ││ABC │ +// ┌───ABD───────┴─┐ │ │ │└──┬─────────┘ +// ├─────────────┬─┘ │ │ │ │ ├───ABD───────┴─┐ │ │ +// ─ ─ ─ ─ ─ ─ ─└───┘─ ─ ─ ─ ─ ▼ └─────────────┬─┘ │ +// └ ┴ ─ ─ ─ ─ ─ ─ ┴───┴ ─ ─ ─ ─ ┘ + +TEST_F(LayoutTest, overflowInsetTransformTranslateTest) { + initialize(TRANSFORM_TRANSLATE); + + auto layoutMetricsA = viewShadowNodeA_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsA.frame.size.width, 50); + EXPECT_EQ(layoutMetricsA.frame.size.height, 50); + + // Change on parent node + // The top/left values are NOT changing as overflowInset is union of before + // and after transform layout. In this case, we move to the right and bottom, + // so the left and top is not changing, while right and bottom values are + // increased. + EXPECT_EQ(layoutMetricsA.overflowInset.left, -50); + EXPECT_EQ(layoutMetricsA.overflowInset.top, -30); + EXPECT_EQ(layoutMetricsA.overflowInset.right, -90); + EXPECT_EQ(layoutMetricsA.overflowInset.bottom, -60); + + auto layoutMetricsAB = viewShadowNodeAB_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsAB.frame.size.width, 30); + EXPECT_EQ(layoutMetricsAB.frame.size.height, 90); + + // No change on self node with translate transform + EXPECT_EQ(layoutMetricsAB.overflowInset.left, -60); + EXPECT_EQ(layoutMetricsAB.overflowInset.top, -40); + EXPECT_EQ(layoutMetricsAB.overflowInset.right, -90); + EXPECT_EQ(layoutMetricsAB.overflowInset.bottom, 0); + + auto layoutMetricsABC = viewShadowNodeABC_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsABC.frame.size.width, 110); + EXPECT_EQ(layoutMetricsABC.frame.size.height, 20); + + // No change on child node + EXPECT_EQ(layoutMetricsABC.overflowInset.left, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.top, -50); + EXPECT_EQ(layoutMetricsABC.overflowInset.right, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.bottom, 0); +} + +// Test when box AB scaled 2X in transform. The parent node's overflowInset will +// be affected. However, the transformed node and its child nodes only appears +// to be affected (dashed arrow). Since all transform is cosmetic only, the +// actual values are NOT changed. It will be converted later when mapping the +// values to pixels during rendering. Here is an example: +// +// ┌────────────────┐ ┌────────────────┐ +// │Original Layout │ │ Scale AB │ +// └────────────────┘ └────────────────┘ +// ─────▶ +// ┌ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ─ ┐ +// │ A │ │ A │ +// │ │ │ │ ├ ─ ─ ─ ─ ─ ┼ ─ ─┌─────┤─ ─ ─ ─ ─ ┤ +// ─ ─ ─ ─│─ ─ ─┌───┐┼ ─ ─ ─ ─ │ │AB │ ─ ─ ─▶ +// │ │ │AB ││ │ │ │ │ │ │ +// └─────┤ ├┘ └────┤ │ +// │ │┌──┴─────────┤ │ │ ┌───┴──────────┤ +// ││ABC │ │ │ABC │ +// │ │└──┬─────────┤ │ │ │ │ │ +// ┌───ABD───────┴─┐ │ │ │ └───┬──────────┘ +// ├─────────────┬─┘ │ │ │ ├────────────────┴──┐ │ │ +// ─ ─ ─ ─ ─ ─ ─└───┘─ ─ ─ ─ ─ ▼ │ ABD │ │ +// ├────────────────┬──┘ │ │ +// ─ ─ ─ ─ ─ ─ ─ ─ ┴─────┴ ─ ─ ─ ─ ─ + +TEST_F(LayoutTest, overflowInsetTransformScaleTest) { + initialize(TRANSFORM_SCALE); + + auto layoutMetricsA = viewShadowNodeA_->getLayoutMetrics(); + + EXPECT_EQ(layoutMetricsA.frame.size.width, 50); + EXPECT_EQ(layoutMetricsA.frame.size.height, 50); + + // Change on parent node when a child view scale up + // Note that AB scale up from its center point. The numbers are calculated + // assuming AB's center point is not moving. + EXPECT_EQ(layoutMetricsA.overflowInset.left, -125); + EXPECT_EQ(layoutMetricsA.overflowInset.top, -115); + EXPECT_EQ(layoutMetricsA.overflowInset.right, -185); + EXPECT_EQ(layoutMetricsA.overflowInset.bottom, -95); + + auto layoutMetricsAB = viewShadowNodeAB_->getLayoutMetrics(); + + // The frame of box AB won't actually scale up. The transform matrix is + // purely cosmetic and should apply later in mounting phase. + EXPECT_EQ(layoutMetricsAB.frame.size.width, 30); + EXPECT_EQ(layoutMetricsAB.frame.size.height, 90); + + // No change on self node with scale transform. This may sound a bit + // surprising, but the overflowInset values will be scaled up via pixel + // density ratio along with width/height of the view. When we do hit-testing, + // the overflowInset value will appears to be doubled as expected. + EXPECT_EQ(layoutMetricsAB.overflowInset.left, -60); + EXPECT_EQ(layoutMetricsAB.overflowInset.top, -40); + EXPECT_EQ(layoutMetricsAB.overflowInset.right, -90); + EXPECT_EQ(layoutMetricsAB.overflowInset.bottom, 0); - auto layoutMetrics = viewShadowNodeA_->getLayoutMetrics(); + auto layoutMetricsABC = viewShadowNodeABC_->getLayoutMetrics(); - EXPECT_EQ(layoutMetrics.frame.size.width, 50); - EXPECT_EQ(layoutMetrics.frame.size.height, 50); + // The frame of box ABC won't actually scale up. The transform matrix is + // purely cosmatic and should apply later in mounting phase. + EXPECT_EQ(layoutMetricsABC.frame.size.width, 110); + EXPECT_EQ(layoutMetricsABC.frame.size.height, 20); - EXPECT_EQ(layoutMetrics.overflowInset.left, -50); - EXPECT_EQ(layoutMetrics.overflowInset.top, 0); - EXPECT_EQ(layoutMetrics.overflowInset.right, -80); - EXPECT_EQ(layoutMetrics.overflowInset.bottom, -50); + // The overflowInset of ABC won't change either. This may sound a bit + // surprising, but the overflowInset values will be scaled up via pixel + // density ratio along with width/height of the view. When we do hit-testing, + // the overflowInset value will appears to be doubled as expected. + EXPECT_EQ(layoutMetricsABC.overflowInset.left, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.top, -50); + EXPECT_EQ(layoutMetricsABC.overflowInset.right, 0); + EXPECT_EQ(layoutMetricsABC.overflowInset.bottom, 0); } } // namespace react diff --git a/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp b/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp index 8da0ed46ea6e30..67c7eda979a1dc 100644 --- a/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp +++ b/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -49,7 +49,7 @@ class YogaDirtyFlagTest : public ::testing::Test { /* * Some non-default props. */ - auto mutableViewProps = std::make_shared(); + auto mutableViewProps = std::make_shared(); auto &props = *mutableViewProps; props.nativeId = "native Id"; props.opacity = 0.5; @@ -111,7 +111,7 @@ TEST_F(YogaDirtyFlagTest, changingNonLayoutSubPropsMustNotDirtyYogaNode) { */ auto newRootShadowNode = rootShadowNode_->cloneTree( innerShadowNode_->getFamily(), [](ShadowNode const &oldShadowNode) { - auto viewProps = std::make_shared(); + auto viewProps = std::make_shared(); auto &props = *viewProps; props.nativeId = "some new native Id"; @@ -135,7 +135,7 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) { */ auto newRootShadowNode = rootShadowNode_->cloneTree( innerShadowNode_->getFamily(), [](ShadowNode const &oldShadowNode) { - auto viewProps = std::make_shared(); + auto viewProps = std::make_shared(); auto &props = *viewProps; props.yogaStyle.alignContent() = YGAlignBaseline; diff --git a/ReactCommon/react/renderer/core/Android.mk b/ReactCommon/react/renderer/core/Android.mk deleted file mode 100644 index 32a8ddf5efe2cb..00000000000000 --- a/ReactCommon/react/renderer/core/Android.mk +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_core - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libfolly_json libjsi libfolly_futures libreact_utils libreact_debug libreact_render_debug libreact_render_graphics libglog - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/core/BUCK b/ReactCommon/react/renderer/core/BUCK index d4d9420c193e41..0e079897c475cc 100644 --- a/ReactCommon/react/renderer/core/BUCK +++ b/ReactCommon/react/renderer/core/BUCK @@ -32,12 +32,13 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/core", ), - compiler_flags_enable_exceptions = False, - compiler_flags_enable_rtti = False, # Needed for DebugStringConvertible - need to find a non-RTTI way to do this / enable RTTI for debug builds only. Also EventBeat/AsyncEventBeat fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -49,7 +50,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp index 64d8df3288ce72..87a59051a89031 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.h b/ReactCommon/react/renderer/core/BatchedEventQueue.h index ea18dcf3d928b6..f663321f02f2fb 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.h +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/CMakeLists.txt b/ReactCommon/react/renderer/core/CMakeLists.txt new file mode 100644 index 00000000000000..890e6e68c8d5f7 --- /dev/null +++ b/ReactCommon/react/renderer/core/CMakeLists.txt @@ -0,0 +1,22 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_core_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_core SHARED ${react_render_core_SRC}) + +target_include_directories(react_render_core PUBLIC ${REACT_COMMON_DIR}) +target_link_libraries(react_render_core + folly_runtime + glog + jsi + react_debug + react_render_debug + react_render_graphics + react_utils) diff --git a/ReactCommon/react/renderer/core/ComponentDescriptor.cpp b/ReactCommon/react/renderer/core/ComponentDescriptor.cpp index dae316ad361219..9afdf8788605c0 100644 --- a/ReactCommon/react/renderer/core/ComponentDescriptor.cpp +++ b/ReactCommon/react/renderer/core/ComponentDescriptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ComponentDescriptor.h b/ReactCommon/react/renderer/core/ComponentDescriptor.h index e0bac0845eadc2..84d35c6c1f53b8 100644 --- a/ReactCommon/react/renderer/core/ComponentDescriptor.h +++ b/ReactCommon/react/renderer/core/ComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace facebook { @@ -101,20 +102,20 @@ class ComponentDescriptor { * will be used. * Must return an object which is NOT pointer equal to `props`. */ - virtual SharedProps cloneProps( + virtual Props::Shared cloneProps( const PropsParserContext &context, - const SharedProps &props, + const Props::Shared &props, const RawProps &rawProps) const = 0; /* * Creates a new `Props` of a particular type with all values interpolated * between `props` and `newProps`. */ - virtual SharedProps interpolateProps( + virtual Props::Shared interpolateProps( const PropsParserContext &context, - float animationProgress, - const SharedProps &props, - const SharedProps &newProps) const = 0; + Float animationProgress, + const Props::Shared &props, + const Props::Shared &newProps) const = 0; /* * Create an initial State object that represents (and contains) an initial diff --git a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 08193e7609f32b..77c60b0a1356dd 100644 --- a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,6 +19,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -93,9 +94,9 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { concreteNonConstParentShadowNode->appendChild(childShadowNode); } - virtual SharedProps cloneProps( + virtual Props::Shared cloneProps( const PropsParserContext &context, - const SharedProps &props, + const Props::Shared &props, const RawProps &rawProps) const override { // Optimization: // Quite often nodes are constructed with default/empty props: the base @@ -108,22 +109,36 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { rawProps.parse(rawPropsParser_, context); - return ShadowNodeT::Props(context, rawProps, props); + // Call old-style constructor + auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props); + + // Use the new-style iterator + // Note that we just check if `Props` has this flag set, no matter + // the type of ShadowNode; it acts as the single global flag. + if (Props::enablePropIteratorSetter) { + rawProps.iterateOverValues([&](RawPropsPropNameHash hash, + const char *propName, + RawValue const &fn) { + shadowNodeProps.get()->setProp(context, hash, propName, fn); + }); + } + + return shadowNodeProps; }; - SharedProps interpolateProps( + Props::Shared interpolateProps( const PropsParserContext &context, - float animationProgress, - const SharedProps &props, - const SharedProps &newProps) const override { + Float animationProgress, + const Props::Shared &props, + const Props::Shared &newProps) const override { #ifdef ANDROID // On Android only, the merged props should have the same RawProps as the // final props struct - SharedProps interpolatedPropsShared = + Props::Shared interpolatedPropsShared = (newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps) : cloneProps(context, newProps, {})); #else - SharedProps interpolatedPropsShared = cloneProps(context, newProps, {}); + Props::Shared interpolatedPropsShared = cloneProps(context, newProps, {}); #endif if (ConcreteShadowNode::BaseTraits().check( @@ -178,6 +193,18 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { } protected: + /* + * Called immediatelly after `ShadowNode` is created or cloned. + * + * Override this method to pass information from custom `ComponentDescriptor` + * to new instance of `ShadowNode`. + * + * Example usages: + * - Inject image manager to `ImageShadowNode` in + * `ImageComponentDescriptor`. + * - Set `ShadowNode`'s size from state in + * `ModalHostViewComponentDescriptor`. + */ virtual void adopt(ShadowNode::Unshared const &shadowNode) const { // Default implementation does nothing. react_native_assert( diff --git a/ReactCommon/react/renderer/core/ConcreteShadowNode.h b/ReactCommon/react/renderer/core/ConcreteShadowNode.h index 537aa6dcbf205e..e8bbf9d08fdf0b 100644 --- a/ReactCommon/react/renderer/core/ConcreteShadowNode.h +++ b/ReactCommon/react/renderer/core/ConcreteShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,6 +47,7 @@ class ConcreteShadowNode : public BaseShadowNodeT { using ConcreteProps = PropsT; using SharedConcreteProps = std::shared_ptr; + using UnsharedConcreteProps = std::shared_ptr; using ConcreteEventEmitter = EventEmitterT; using SharedConcreteEventEmitter = std::shared_ptr; using SharedConcreteShadowNode = std::shared_ptr; @@ -69,11 +70,11 @@ class ConcreteShadowNode : public BaseShadowNodeT { return BaseShadowNodeT::BaseTraits(); } - static SharedConcreteProps Props( + static UnsharedConcreteProps Props( const PropsParserContext &context, RawProps const &rawProps, - SharedProps const &baseProps = nullptr) { - return std::make_shared( + Props::Shared const &baseProps = nullptr) { + return std::make_shared( context, baseProps ? static_cast(*baseProps) : PropsT(), rawProps); diff --git a/ReactCommon/react/renderer/core/ConcreteState.h b/ReactCommon/react/renderer/core/ConcreteState.h index c4f8bef37e1d2b..d7615e3926bb63 100644 --- a/ReactCommon/react/renderer/core/ConcreteState.h +++ b/ReactCommon/react/renderer/core/ConcreteState.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/DynamicPropsUtilities.cpp b/ReactCommon/react/renderer/core/DynamicPropsUtilities.cpp index 428ae4f3b83073..f4e03a822d595c 100644 --- a/ReactCommon/react/renderer/core/DynamicPropsUtilities.cpp +++ b/ReactCommon/react/renderer/core/DynamicPropsUtilities.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/DynamicPropsUtilities.h b/ReactCommon/react/renderer/core/DynamicPropsUtilities.h index 9e7283cb8fc331..d251f20b757031 100644 --- a/ReactCommon/react/renderer/core/DynamicPropsUtilities.h +++ b/ReactCommon/react/renderer/core/DynamicPropsUtilities.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventBeat.cpp b/ReactCommon/react/renderer/core/EventBeat.cpp index 0275e7820b56ee..6675fb0e43acad 100644 --- a/ReactCommon/react/renderer/core/EventBeat.cpp +++ b/ReactCommon/react/renderer/core/EventBeat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,10 +7,13 @@ #include "EventBeat.h" +#include + namespace facebook { namespace react { -EventBeat::EventBeat(SharedOwnerBox const &ownerBox) : ownerBox_(ownerBox) {} +EventBeat::EventBeat(SharedOwnerBox ownerBox) + : ownerBox_(std::move(ownerBox)) {} void EventBeat::request() const { isRequested_ = true; @@ -32,8 +35,8 @@ void EventBeat::induce() const { // Default implementation does nothing. } -void EventBeat::setBeatCallback(const BeatCallback &beatCallback) { - beatCallback_ = beatCallback; +void EventBeat::setBeatCallback(BeatCallback beatCallback) { + beatCallback_ = std::move(beatCallback); } } // namespace react diff --git a/ReactCommon/react/renderer/core/EventBeat.h b/ReactCommon/react/renderer/core/EventBeat.h index 1e20c2ec937d09..05388edd5bf6bf 100644 --- a/ReactCommon/react/renderer/core/EventBeat.h +++ b/ReactCommon/react/renderer/core/EventBeat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,7 +47,7 @@ class EventBeat { using BeatCallback = std::function; - EventBeat(SharedOwnerBox const &ownerBox); + EventBeat(SharedOwnerBox ownerBox); virtual ~EventBeat() = default; @@ -73,7 +73,7 @@ class EventBeat { * Sets the beat callback function. * The callback is must be called on the proper thread. */ - void setBeatCallback(const BeatCallback &beatCallback); + void setBeatCallback(BeatCallback beatCallback); protected: /* diff --git a/ReactCommon/react/renderer/core/EventDispatcher.cpp b/ReactCommon/react/renderer/core/EventDispatcher.cpp index 3cfe35f3e0cf60..34f68f4bf3b88f 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,7 +17,7 @@ namespace facebook { namespace react { EventDispatcher::EventDispatcher( - EventQueueProcessor eventProcessor, + EventQueueProcessor const &eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox) @@ -36,6 +36,10 @@ EventDispatcher::EventDispatcher( void EventDispatcher::dispatchEvent(RawEvent &&rawEvent, EventPriority priority) const { + // Allows the event listener to interrupt default event dispatch + if (eventListeners_.willDispatchEvent(rawEvent)) { + return; + } getEventQueue(priority).enqueueEvent(std::move(rawEvent)); } @@ -46,6 +50,10 @@ void EventDispatcher::dispatchStateUpdate( } void EventDispatcher::dispatchUniqueEvent(RawEvent &&rawEvent) const { + // Allows the event listener to interrupt default event dispatch + if (eventListeners_.willDispatchEvent(rawEvent)) { + return; + } asynchronousBatchedQueue_->enqueueUniqueEvent(std::move(rawEvent)); } @@ -62,5 +70,18 @@ const EventQueue &EventDispatcher::getEventQueue(EventPriority priority) const { } } +void EventDispatcher::addListener( + const std::shared_ptr &listener) const { + eventListeners_.addListener(listener); +} + +/* + * Removes provided event listener to the event dispatcher. + */ +void EventDispatcher::removeListener( + const std::shared_ptr &listener) const { + eventListeners_.removeListener(listener); +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/core/EventDispatcher.h b/ReactCommon/react/renderer/core/EventDispatcher.h index f81ccd7cc26861..19f1fabb7e7b70 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/ReactCommon/react/renderer/core/EventDispatcher.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,7 @@ class EventDispatcher { using Weak = std::weak_ptr; EventDispatcher( - EventQueueProcessor eventProcessor, + EventQueueProcessor const &eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox); @@ -52,6 +53,18 @@ class EventDispatcher { void dispatchStateUpdate(StateUpdate &&stateUpdate, EventPriority priority) const; +#pragma mark - Event listeners + /* + * Adds provided event listener to the event dispatcher. + */ + void addListener(const std::shared_ptr &listener) const; + + /* + * Removes provided event listener to the event dispatcher. + */ + void removeListener( + const std::shared_ptr &listener) const; + private: EventQueue const &getEventQueue(EventPriority priority) const; @@ -59,6 +72,8 @@ class EventDispatcher { std::unique_ptr synchronousBatchedQueue_; std::unique_ptr asynchronousUnbatchedQueue_; std::unique_ptr asynchronousBatchedQueue_; + + mutable EventListenerContainer eventListeners_; }; } // namespace react diff --git a/ReactCommon/react/renderer/core/EventEmitter.cpp b/ReactCommon/react/renderer/core/EventEmitter.cpp index cbc4dfd29b82f9..894ddf8eddd2e0 100644 --- a/ReactCommon/react/renderer/core/EventEmitter.cpp +++ b/ReactCommon/react/renderer/core/EventEmitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,9 +22,9 @@ namespace react { * Capitalizes the first letter of the event type and adds "top" prefix if * necessary (e.g. "layout" becames "topLayout"). */ -static std::string normalizeEventType(const std::string &type) { - auto prefixedType = type; - if (type.find("top", 0) != 0) { +static std::string normalizeEventType(std::string type) { + auto prefixedType = std::move(type); + if (prefixedType.find("top", 0) != 0) { prefixedType.insert(0, "top"); prefixedType[3] = static_cast(toupper(prefixedType[3])); } @@ -50,12 +50,12 @@ EventEmitter::EventEmitter( eventDispatcher_(std::move(eventDispatcher)) {} void EventEmitter::dispatchEvent( - const std::string &type, + std::string type, const folly::dynamic &payload, EventPriority priority, RawEvent::Category category) const { dispatchEvent( - type, + std::move(type), [payload](jsi::Runtime &runtime) { return valueFromDynamic(runtime, payload); }, @@ -64,19 +64,19 @@ void EventEmitter::dispatchEvent( } void EventEmitter::dispatchUniqueEvent( - const std::string &type, + std::string type, const folly::dynamic &payload) const { - dispatchUniqueEvent(type, [payload](jsi::Runtime &runtime) { + dispatchUniqueEvent(std::move(type), [payload](jsi::Runtime &runtime) { return valueFromDynamic(runtime, payload); }); } void EventEmitter::dispatchEvent( - const std::string &type, + std::string type, const ValueFactory &payloadFactory, EventPriority priority, RawEvent::Category category) const { - SystraceSection s("EventEmitter::dispatchEvent"); + SystraceSection s("EventEmitter::dispatchEvent", "type", type); auto eventDispatcher = eventDispatcher_.lock(); if (!eventDispatcher) { @@ -85,12 +85,15 @@ void EventEmitter::dispatchEvent( eventDispatcher->dispatchEvent( RawEvent( - normalizeEventType(type), payloadFactory, eventTarget_, category), + normalizeEventType(std::move(type)), + payloadFactory, + eventTarget_, + category), priority); } void EventEmitter::dispatchUniqueEvent( - const std::string &type, + std::string type, const ValueFactory &payloadFactory) const { SystraceSection s("EventEmitter::dispatchUniqueEvent"); @@ -100,7 +103,7 @@ void EventEmitter::dispatchUniqueEvent( } eventDispatcher->dispatchUniqueEvent(RawEvent( - normalizeEventType(type), + normalizeEventType(std::move(type)), payloadFactory, eventTarget_, RawEvent::Category::Continuous)); diff --git a/ReactCommon/react/renderer/core/EventEmitter.h b/ReactCommon/react/renderer/core/EventEmitter.h index f2f484b0d398c3..1f5afceab2feb3 100644 --- a/ReactCommon/react/renderer/core/EventEmitter.h +++ b/ReactCommon/react/renderer/core/EventEmitter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -68,24 +68,23 @@ class EventEmitter { * Is used by particular subclasses only. */ void dispatchEvent( - const std::string &type, + std::string type, const ValueFactory &payloadFactory = EventEmitter::defaultPayloadFactory(), EventPriority priority = EventPriority::AsynchronousBatched, RawEvent::Category category = RawEvent::Category::Unspecified) const; void dispatchEvent( - const std::string &type, + std::string type, const folly::dynamic &payload, EventPriority priority = EventPriority::AsynchronousBatched, RawEvent::Category category = RawEvent::Category::Unspecified) const; - void dispatchUniqueEvent( - const std::string &type, - const folly::dynamic &payload) const; + void dispatchUniqueEvent(std::string type, const folly::dynamic &payload) + const; void dispatchUniqueEvent( - const std::string &type, + std::string type, const ValueFactory &payloadFactory = EventEmitter::defaultPayloadFactory()) const; diff --git a/ReactCommon/react/renderer/core/EventHandler.h b/ReactCommon/react/renderer/core/EventHandler.h index ecadae3d653655..6deb74bf83b1be 100644 --- a/ReactCommon/react/renderer/core/EventHandler.h +++ b/ReactCommon/react/renderer/core/EventHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventListener.cpp b/ReactCommon/react/renderer/core/EventListener.cpp new file mode 100644 index 00000000000000..48f5793292dc7b --- /dev/null +++ b/ReactCommon/react/renderer/core/EventListener.cpp @@ -0,0 +1,39 @@ +/* + * 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. + */ + +#include "EventListener.h" + +namespace facebook::react { + +bool EventListenerContainer::willDispatchEvent(const RawEvent &event) { + std::shared_lock lock(mutex_); + + bool handled = false; + for (auto const &listener : eventListeners_) { + handled = handled || listener->operator()(event); + } + return handled; +} + +void EventListenerContainer::addListener( + const std::shared_ptr &listener) { + std::unique_lock lock(mutex_); + + eventListeners_.push_back(listener); +} + +void EventListenerContainer::removeListener( + const std::shared_ptr &listener) { + std::unique_lock lock(mutex_); + + auto it = std::find(eventListeners_.begin(), eventListeners_.end(), listener); + if (it != eventListeners_.end()) { + eventListeners_.erase(it); + } +} + +} // namespace facebook::react diff --git a/ReactCommon/react/renderer/core/EventListener.h b/ReactCommon/react/renderer/core/EventListener.h new file mode 100644 index 00000000000000..f9176b514cbfa0 --- /dev/null +++ b/ReactCommon/react/renderer/core/EventListener.h @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include + +#include + +namespace facebook { +namespace react { + +/** + * Listener for events dispatched to JS runtime. + * Return `true` to interrupt default dispatch to JS event emitter, `false` to + * pass through to default handlers. + */ +using EventListener = std::function; + +class EventListenerContainer { + public: + /* + * Invoke listeners in this container with the event. + * Returns true if event was handled by the listener, false to continue + * default dispatch. + */ + bool willDispatchEvent(const RawEvent &event); + + void addListener(const std::shared_ptr &listener); + void removeListener(const std::shared_ptr &listener); + + private: + butter::shared_mutex mutex_; + std::vector> eventListeners_; +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/core/EventPipe.h b/ReactCommon/react/renderer/core/EventPipe.h index 3e9ac127e6bb06..e64281fc6868d8 100644 --- a/ReactCommon/react/renderer/core/EventPipe.h +++ b/ReactCommon/react/renderer/core/EventPipe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventPriority.h b/ReactCommon/react/renderer/core/EventPriority.h index 8611f105800e0e..bde3b9a36aa9fb 100644 --- a/ReactCommon/react/renderer/core/EventPriority.h +++ b/ReactCommon/react/renderer/core/EventPriority.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventQueue.cpp b/ReactCommon/react/renderer/core/EventQueue.cpp index 4d10e4c74423ac..ef111d4b56d256 100644 --- a/ReactCommon/react/renderer/core/EventQueue.cpp +++ b/ReactCommon/react/renderer/core/EventQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,7 +19,7 @@ EventQueue::EventQueue( : eventProcessor_(std::move(eventProcessor)), eventBeat_(std::move(eventBeat)) { eventBeat_->setBeatCallback( - std::bind(&EventQueue::onBeat, this, std::placeholders::_1)); + [this](jsi::Runtime &runtime) { onBeat(runtime); }); } void EventQueue::enqueueEvent(RawEvent &&rawEvent) const { diff --git a/ReactCommon/react/renderer/core/EventQueue.h b/ReactCommon/react/renderer/core/EventQueue.h index d0f9da84426dfa..3a3196dbb52178 100644 --- a/ReactCommon/react/renderer/core/EventQueue.h +++ b/ReactCommon/react/renderer/core/EventQueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventQueueProcessor.cpp b/ReactCommon/react/renderer/core/EventQueueProcessor.cpp index 40b813e155aa93..59ea4506a8f730 100644 --- a/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +++ b/ReactCommon/react/renderer/core/EventQueueProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventQueueProcessor.h b/ReactCommon/react/renderer/core/EventQueueProcessor.h index 933cc9a207961c..8fa3433ea41943 100644 --- a/ReactCommon/react/renderer/core/EventQueueProcessor.h +++ b/ReactCommon/react/renderer/core/EventQueueProcessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/EventTarget.cpp b/ReactCommon/react/renderer/core/EventTarget.cpp index b8d84547016ade..9a6d115b272885 100644 --- a/ReactCommon/react/renderer/core/EventTarget.cpp +++ b/ReactCommon/react/renderer/core/EventTarget.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -40,8 +40,10 @@ void EventTarget::retain(jsi::Runtime &runtime) const { // particular implementation of JSI was able to detect this inconsistency and // dealt with it, but some JSI implementation may not support this feature and // that case will lead to a crash in those environments. - react_native_assert(!strongInstanceHandle_.isNull()); - react_native_assert(!strongInstanceHandle_.isUndefined()); + + // TODO: Replace with mustfix once mustfix is ready in React Native. + // react_native_assert(!strongInstanceHandle_.isNull()); + // react_native_assert(!strongInstanceHandle_.isUndefined()); } void EventTarget::release(jsi::Runtime &runtime) const { diff --git a/ReactCommon/react/renderer/core/EventTarget.h b/ReactCommon/react/renderer/core/EventTarget.h index 92f382a96c4965..8807ef4b2806fa 100644 --- a/ReactCommon/react/renderer/core/EventTarget.h +++ b/ReactCommon/react/renderer/core/EventTarget.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutConstraints.cpp b/ReactCommon/react/renderer/core/LayoutConstraints.cpp index f7a9697e829e16..db92606051df2a 100644 --- a/ReactCommon/react/renderer/core/LayoutConstraints.cpp +++ b/ReactCommon/react/renderer/core/LayoutConstraints.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutConstraints.h b/ReactCommon/react/renderer/core/LayoutConstraints.h index 26b4c419e38c6b..fd21538a0f7f52 100644 --- a/ReactCommon/react/renderer/core/LayoutConstraints.h +++ b/ReactCommon/react/renderer/core/LayoutConstraints.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutContext.h b/ReactCommon/react/renderer/core/LayoutContext.h index dcd441028eb51e..f2a4ae55e7e7d4 100644 --- a/ReactCommon/react/renderer/core/LayoutContext.h +++ b/ReactCommon/react/renderer/core/LayoutContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutMetrics.cpp b/ReactCommon/react/renderer/core/LayoutMetrics.cpp index 26a3feaafeb5b9..8e92f2f07a137c 100644 --- a/ReactCommon/react/renderer/core/LayoutMetrics.cpp +++ b/ReactCommon/react/renderer/core/LayoutMetrics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutMetrics.h b/ReactCommon/react/renderer/core/LayoutMetrics.h index f094e2c55276e7..2ba3b5dfc07d48 100644 --- a/ReactCommon/react/renderer/core/LayoutMetrics.h +++ b/ReactCommon/react/renderer/core/LayoutMetrics.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutPrimitives.h b/ReactCommon/react/renderer/core/LayoutPrimitives.h index b0981f6f73677f..aa1845172fd819 100644 --- a/ReactCommon/react/renderer/core/LayoutPrimitives.h +++ b/ReactCommon/react/renderer/core/LayoutPrimitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 3e8a531306a019..c5684692257915 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -56,7 +56,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( // Step 1. // Creating a list of nodes that form a chain from the descender node to // ancestor node inclusively. - auto shadowNodeList = better::small_vector{}; + auto shadowNodeList = butter::small_vector{}; // Finding the measured node. // The last element in the `AncestorList` is a pair of a parent of the node @@ -203,7 +203,7 @@ Float LayoutableShadowNode::lastBaseline(Size size) const { } ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint( - ShadowNode::Shared node, + ShadowNode::Shared const &node, Point point) { auto layoutableShadowNode = traitCast(node.get()); diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/ReactCommon/react/renderer/core/LayoutableShadowNode.h index a2653102cbfeb4..35dd55e7514543 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ class LayoutableShadowNode : public ShadowNode { bool includeViewportOffset{false}; }; - using UnsharedList = better:: + using UnsharedList = butter:: small_vector; /* @@ -133,7 +133,7 @@ class LayoutableShadowNode : public ShadowNode { * parameter. */ static ShadowNode::Shared findNodeAtPoint( - ShadowNode::Shared node, + ShadowNode::Shared const &node, Point point); /* diff --git a/ReactCommon/react/renderer/core/Props.cpp b/ReactCommon/react/renderer/core/Props.cpp index f502fccfdf241b..ad1c01c5c2855f 100644 --- a/ReactCommon/react/renderer/core/Props.cpp +++ b/ReactCommon/react/renderer/core/Props.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,22 +13,42 @@ namespace facebook { namespace react { +bool Props::enablePropIteratorSetter = false; + Props::Props( const PropsParserContext &context, const Props &sourceProps, - const RawProps &rawProps) - : nativeId(convertRawProp( - context, - rawProps, - "nativeID", - sourceProps.nativeId, - {})), + const RawProps &rawProps, + const bool shouldSetRawProps) + : nativeId( + enablePropIteratorSetter ? sourceProps.nativeId + : convertRawProp( + context, + rawProps, + "nativeID", + sourceProps.nativeId, + {})), revision(sourceProps.revision + 1) #ifdef ANDROID , - rawProps((folly::dynamic)rawProps) + rawProps( + shouldSetRawProps ? (folly::dynamic)rawProps + : /* null */ folly::dynamic()) #endif - {}; +{ +} + +void Props::setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value) { + switch (hash) { + case CONSTEXPR_RAW_PROPS_KEY_HASH("nativeID"): + fromRawValue(context, value, nativeId, {}); + return; + } +} } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/core/Props.h b/ReactCommon/react/renderer/core/Props.h index 5d99a0139a1e85..9c0735695069f2 100644 --- a/ReactCommon/react/renderer/core/Props.h +++ b/ReactCommon/react/renderer/core/Props.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -18,10 +19,6 @@ namespace facebook { namespace react { -class Props; - -using SharedProps = std::shared_ptr; - /* * Represents the most generic props object. */ @@ -33,9 +30,28 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { Props( const PropsParserContext &context, const Props &sourceProps, - RawProps const &rawProps); + RawProps const &rawProps, + bool shouldSetRawProps = true); virtual ~Props() = default; + static bool enablePropIteratorSetter; + + /** + * Set a prop value via iteration (see enableIterator above). + * If setProp is defined for a particular props struct, it /must/ + * be called every time setProp is called on the hierarchy. + * For example, ViewProps overrides setProp and so ViewProps must + * explicitly call Props::setProp every time ViewProps::setProp is + * called. This is because a single prop from JS can be reused + * multiple times for different values in the hierarchy. For example, if + * ViewProps uses "propX", Props may also use "propX". + */ + void setProp( + const PropsParserContext &context, + RawPropsPropNameHash hash, + const char *propName, + RawValue const &value); + std::string nativeId; /* diff --git a/ReactCommon/react/renderer/core/PropsMacros.h b/ReactCommon/react/renderer/core/PropsMacros.h new file mode 100644 index 00000000000000..1e7a6c51a14ce6 --- /dev/null +++ b/ReactCommon/react/renderer/core/PropsMacros.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +// We need to use clang pragmas inside of a macro below, +// so we need to pull out the "if" statement here. +#if __clang__ +#define CLANG_PRAGMA(s) _Pragma(s) +#else +#define CLANG_PRAGMA(s) +#endif + +// Get hash at compile-time. sizeof(str) - 1 == strlen +#define CONSTEXPR_RAW_PROPS_KEY_HASH(s) \ + ({ \ + CLANG_PRAGMA("clang diagnostic push") \ + CLANG_PRAGMA("clang diagnostic ignored \"-Wshadow\"") \ + constexpr RawPropsPropNameHash propNameHash = \ + folly::hash::fnv32_buf(s, sizeof(s) - 1); \ + propNameHash; \ + CLANG_PRAGMA("clang diagnostic pop") \ + }) + +#define RAW_PROPS_KEY_HASH(s) folly::hash::fnv32_buf(s, std::strlen(s)) + +// Convenience for building setProps switch statements. +// This injects `fromRawValue` into source; each file that uses +// this macro must import the proper, respective headers required. +#define RAW_SET_PROP_SWITCH_CASE(field, jsPropName, defaultValue) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(jsPropName): \ + fromRawValue(context, value, field, defaultValue); \ + return; + +// Convenience for building setProps switch statements where the field name is +// the same as the string identifier +#define RAW_SET_PROP_SWITCH_CASE_BASIC(field, defaultValue) \ + RAW_SET_PROP_SWITCH_CASE(field, #field, defaultValue) + +#define CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, field, fieldNameString, value) \ + case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldNameString): { \ + if (!value.hasValue()) { \ + decltype(struct) defaultValues{}; \ + struct.field = defaultValues.field; \ + return; \ + } \ + fromRawValue(context, value, struct.field); \ + return; \ + } + +#define SET_CASCADED_RECTANGLE_CORNERS(struct, prefix, suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, topLeft, prefix "TopLeft" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, topRight, prefix "TopRight" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, bottomLeft, prefix "BottomLeft" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, bottomRight, prefix "BottomRight" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, topStart, prefix "TopStart" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, topEnd, prefix "TopEnd" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, bottomStart, prefix "BottomStart" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, bottomEnd, prefix "BottomEnd" suffix, rawValue) + +#define SET_CASCADED_RECTANGLE_EDGES(struct, prefix, suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, left, prefix "Left" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, right, prefix "Right" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, top, prefix "Top" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, bottom, prefix "Bottom" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, start, prefix "Start" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, end, prefix "End" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, horizontal, prefix "Horizontal" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, vertical, prefix "Vertical" suffix, rawValue) \ + CASE_STATEMENT_SET_FIELD_VALUE_INDEXED( \ + struct, all, prefix "" suffix, rawValue) diff --git a/ReactCommon/react/renderer/core/PropsParserContext.h b/ReactCommon/react/renderer/core/PropsParserContext.h index df4b16d70a5966..7297fbba321e86 100644 --- a/ReactCommon/react/renderer/core/PropsParserContext.h +++ b/ReactCommon/react/renderer/core/PropsParserContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawEvent.cpp b/ReactCommon/react/renderer/core/RawEvent.cpp index 3abace5171e2e0..1c7c5b8dc3e92f 100644 --- a/ReactCommon/react/renderer/core/RawEvent.cpp +++ b/ReactCommon/react/renderer/core/RawEvent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawEvent.h b/ReactCommon/react/renderer/core/RawEvent.h index ff50464d4a3e6f..bd57b7e37c6a50 100644 --- a/ReactCommon/react/renderer/core/RawEvent.h +++ b/ReactCommon/react/renderer/core/RawEvent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawProps.cpp b/ReactCommon/react/renderer/core/RawProps.cpp index 4776ce5ac81086..454e2bed304262 100644 --- a/ReactCommon/react/renderer/core/RawProps.cpp +++ b/ReactCommon/react/renderer/core/RawProps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,7 @@ #include "RawProps.h" #include +#include #include namespace facebook { @@ -92,5 +93,12 @@ const RawValue *RawProps::at( return parser_->at(*this, RawPropsKey{prefix, name, suffix}); } +void RawProps::iterateOverValues( + std::function< + void(RawPropsPropNameHash, const char *, RawValue const &)> const &fn) + const { + return parser_->iterateOverValues(*this, fn); +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/core/RawProps.h b/ReactCommon/react/renderer/core/RawProps.h index 3cb96eca5fedc4..4e86e289cc1c5d 100644 --- a/ReactCommon/react/renderer/core/RawProps.h +++ b/ReactCommon/react/renderer/core/RawProps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,16 +8,15 @@ #pragma once #include +#include -#include -#include -#include +#include +#include #include #include #include #include -#include #include #include #include @@ -98,6 +97,15 @@ class RawProps final { const RawValue *at(char const *name, char const *prefix, char const *suffix) const noexcept; + /** + * Iterator functions: for when you want to iterate over values in-order + * instead of using `at` to access values randomly. + */ + void iterateOverValues( + std::function< + void(RawPropsPropNameHash, const char *, RawValue const &)> const &fn) + const; + private: friend class RawPropsParser; @@ -126,10 +134,10 @@ class RawProps final { * Parsed artefacts: * To be used by `RawPropParser`. */ - mutable better:: + mutable butter:: small_vector keyIndexToValueIndex_; - mutable better:: + mutable butter:: small_vector values_; }; diff --git a/ReactCommon/react/renderer/core/RawPropsKey.cpp b/ReactCommon/react/renderer/core/RawPropsKey.cpp index 35c8283f5e24a4..de7820dc7baa0c 100644 --- a/ReactCommon/react/renderer/core/RawPropsKey.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKey.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,7 @@ #include "RawPropsKey.h" +#include #include #include @@ -44,18 +45,18 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) } RawPropsKey::operator std::string() const noexcept { - char buffer[kPropNameLengthHardCap]; + auto buffer = std::array(); RawPropsPropNameLength length = 0; - render(buffer, &length); + render(buffer.data(), &length); react_native_assert(length < kPropNameLengthHardCap); - return std::string{buffer, length}; + return std::string{buffer.data(), length}; } static bool areFieldsEqual(char const *lhs, char const *rhs) { if (lhs == nullptr || rhs == nullptr) { return lhs == rhs; } - return std::string(lhs) == std::string(rhs); + return lhs == rhs || strcmp(lhs, rhs) == 0; } bool operator==(RawPropsKey const &lhs, RawPropsKey const &rhs) noexcept { diff --git a/ReactCommon/react/renderer/core/RawPropsKey.h b/ReactCommon/react/renderer/core/RawPropsKey.h index 097b153dd518b1..510600cddecd51 100644 --- a/ReactCommon/react/renderer/core/RawPropsKey.h +++ b/ReactCommon/react/renderer/core/RawPropsKey.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp b/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp index af24fdb4a986b7..d978bf4eed7f21 100644 --- a/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKeyMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawPropsKeyMap.h b/ReactCommon/react/renderer/core/RawPropsKeyMap.h index 3c300a314090f1..f71dd094e5da95 100644 --- a/ReactCommon/react/renderer/core/RawPropsKeyMap.h +++ b/ReactCommon/react/renderer/core/RawPropsKeyMap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -55,8 +55,8 @@ class RawPropsKeyMap final { Item const &rhs) noexcept; static bool hasSameName(Item const &lhs, Item const &rhs) noexcept; - better::small_vector items_{}; - better::small_vector + butter::small_vector items_{}; + butter::small_vector buckets_{}; }; diff --git a/ReactCommon/react/renderer/core/RawPropsParser.cpp b/ReactCommon/react/renderer/core/RawPropsParser.cpp index db098e9fab5bc7..882a4a935a57e2 100644 --- a/ReactCommon/react/renderer/core/RawPropsParser.cpp +++ b/ReactCommon/react/renderer/core/RawPropsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,7 @@ #include "RawPropsParser.h" #include +#include #include #include @@ -33,7 +34,8 @@ RawValue const *RawPropsParser::at( // 1))) or n*n - (1/2)(n*(n+1)). If there are 100 props, this will result in // 4950 lookups and equality checks on initialization of the parser, which // happens exactly once per component. - for (int i = 0; i < size_; i++) { + size_t size = keys_.size(); + for (int i = 0; i < size; i++) { if (keys_[i] == key) { return nullptr; } @@ -41,8 +43,7 @@ RawValue const *RawPropsParser::at( // This is not thread-safe part; this happens only during initialization of // a `ComponentDescriptor` where it is actually safe. keys_.push_back(key); - nameToIndex_.insert(key, static_cast(size_)); - size_++; + nameToIndex_.insert(key, static_cast(size)); return nullptr; } @@ -69,7 +70,7 @@ RawValue const *RawPropsParser::at( do { rawProps.keyIndexCursor_++; - if (UNLIKELY(rawProps.keyIndexCursor_ >= size_)) { + if (UNLIKELY(rawProps.keyIndexCursor_ >= keys_.size())) { #ifdef REACT_NATIVE_DEBUG if (resetLoop) { LOG(ERROR) << "Looked up RawProps key that does not exist: " @@ -93,10 +94,18 @@ void RawPropsParser::postPrepare() noexcept { } void RawPropsParser::preparse(RawProps const &rawProps) const noexcept { - rawProps.keyIndexToValueIndex_.resize(size_, kRawPropsValueIndexEmpty); + const size_t keyCount = keys_.size(); + rawProps.keyIndexToValueIndex_.resize(keyCount, kRawPropsValueIndexEmpty); // Resetting the cursor, the next increment will give `0`. - rawProps.keyIndexCursor_ = size_ - 1; + rawProps.keyIndexCursor_ = static_cast(keyCount - 1); + + // If the Props constructor doesn't use ::at at all, we might be + // able to skip this entirely (in those cases, the Props struct probably + // uses setProp instead). + if (keyCount == 0) { + return; + } switch (rawProps.mode_) { case RawProps::Mode::Empty: @@ -122,6 +131,7 @@ void RawPropsParser::preparse(RawProps const &rawProps) const noexcept { auto keyIndex = nameToIndex_.at( name.data(), static_cast(name.size())); + if (keyIndex == kRawPropsValueIndexEmpty) { continue; } @@ -144,6 +154,7 @@ void RawPropsParser::preparse(RawProps const &rawProps) const noexcept { auto keyIndex = nameToIndex_.at( name.data(), static_cast(name.size())); + if (keyIndex == kRawPropsValueIndexEmpty) { continue; } @@ -157,5 +168,58 @@ void RawPropsParser::preparse(RawProps const &rawProps) const noexcept { } } +/** + * To be used by RawProps only. Value iterator functions. + */ +void RawPropsParser::iterateOverValues( + RawProps const &rawProps, + std::function< + void(RawPropsPropNameHash, const char *, RawValue const &)> const + &visit) const { + switch (rawProps.mode_) { + case RawProps::Mode::Empty: + return; + + case RawProps::Mode::JSI: { + auto &runtime = *rawProps.runtime_; + if (!rawProps.value_.isObject()) { + LOG(ERROR) << "Preparse props: rawProps value is not object"; + } + react_native_assert(rawProps.value_.isObject()); + auto object = rawProps.value_.asObject(runtime); + + auto names = object.getPropertyNames(runtime); + auto count = names.size(runtime); + + for (size_t i = 0; i < count; i++) { + auto nameValue = names.getValueAtIndex(runtime, i).getString(runtime); + auto value = object.getProperty(runtime, nameValue); + + auto name = nameValue.utf8(runtime); + + auto nameHash = RAW_PROPS_KEY_HASH(name.c_str()); + auto rawValue = RawValue(jsi::dynamicFromValue(runtime, value)); + + visit(nameHash, name.c_str(), rawValue); + } + + break; + } + + case RawProps::Mode::Dynamic: { + auto const &dynamic = rawProps.dynamic_; + + for (auto const &pair : dynamic.items()) { + auto name = pair.first.getString(); + + auto nameHash = RAW_PROPS_KEY_HASH(name.c_str()); + auto rawValue = RawValue{pair.second}; + visit(nameHash, name.c_str(), rawValue); + } + break; + } + } +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/core/RawPropsParser.h b/ReactCommon/react/renderer/core/RawPropsParser.h index 5d37cefd8c3bac..c112f6247cbd57 100644 --- a/ReactCommon/react/renderer/core/RawPropsParser.h +++ b/ReactCommon/react/renderer/core/RawPropsParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ #pragma once -#include -#include +#include +#include #include #include #include @@ -76,10 +76,18 @@ class RawPropsParser final { RawValue const *at(RawProps const &rawProps, RawPropsKey const &key) const noexcept; - mutable better::small_vector + /** + * To be used by RawProps only. Value iterator functions. + */ + void iterateOverValues( + RawProps const &rawProps, + std::function< + void(RawPropsPropNameHash, const char *, RawValue const &)> const &fn) + const; + + mutable butter::small_vector keys_{}; mutable RawPropsKeyMap nameToIndex_{}; - mutable int size_{0}; mutable bool ready_{false}; }; diff --git a/ReactCommon/react/renderer/core/RawPropsPrimitives.h b/ReactCommon/react/renderer/core/RawPropsPrimitives.h index 97896332f1f22e..355496cc27fd74 100644 --- a/ReactCommon/react/renderer/core/RawPropsPrimitives.h +++ b/ReactCommon/react/renderer/core/RawPropsPrimitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,7 @@ #pragma once +#include #include namespace facebook { @@ -20,6 +21,7 @@ static_assert( sizeof(RawPropsValueIndex) == 1, "RawPropsValueIndex must be one byte size."); using RawPropsPropNameLength = uint8_t; +using RawPropsPropNameHash = uint32_t; /* * The number which is *usually* bigger than a number of explicitly specified diff --git a/ReactCommon/react/renderer/core/RawValue.cpp b/ReactCommon/react/renderer/core/RawValue.cpp index 3193bf6e7cd5e5..d274c78a8b59a1 100644 --- a/ReactCommon/react/renderer/core/RawValue.cpp +++ b/ReactCommon/react/renderer/core/RawValue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/RawValue.h b/ReactCommon/react/renderer/core/RawValue.h index 16cab0bd7b9c4a..d541f11a16ed9d 100644 --- a/ReactCommon/react/renderer/core/RawValue.h +++ b/ReactCommon/react/renderer/core/RawValue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,11 +7,13 @@ #pragma once -#include +#include #include #include #include +#include + #include namespace facebook { @@ -78,7 +80,7 @@ class RawValue { /* * Copy constructor and copy assignment operator would be private and only for * internal use, but it's needed for user-code that does `auto val = - * (better::map)rawVal;` + * (butter::map)rawVal;` */ RawValue(RawValue const &other) noexcept : dynamic_(other.dynamic_) {} @@ -185,7 +187,7 @@ class RawValue { template static bool checkValueType( const folly::dynamic &dynamic, - better::map *type) noexcept { + butter::map *type) noexcept { if (!dynamic.isObject()) { return false; } @@ -267,11 +269,11 @@ class RawValue { } template - static better::map castValue( + static butter::map castValue( const folly::dynamic &dynamic, - better::map *type) noexcept { + butter::map *type) noexcept { react_native_assert(dynamic.isObject()); - auto result = better::map{}; + auto result = butter::map{}; for (const auto &item : dynamic.items()) { react_native_assert(item.first.isString()); result[item.first.getString()] = castValue(item.second, (T *)nullptr); diff --git a/ReactCommon/react/renderer/core/ReactEventPriority.h b/ReactCommon/react/renderer/core/ReactEventPriority.h index 3ef8b5728ebd43..b3c17f90ba30b0 100644 --- a/ReactCommon/react/renderer/core/ReactEventPriority.h +++ b/ReactCommon/react/renderer/core/ReactEventPriority.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ReactPrimitives.h b/ReactCommon/react/renderer/core/ReactPrimitives.h index 28738394bf9e9d..823811306494e2 100644 --- a/ReactCommon/react/renderer/core/ReactPrimitives.h +++ b/ReactCommon/react/renderer/core/ReactPrimitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/Sealable.cpp b/ReactCommon/react/renderer/core/Sealable.cpp index 2326a4ed7b2f70..abb839c8ea65ea 100644 --- a/ReactCommon/react/renderer/core/Sealable.cpp +++ b/ReactCommon/react/renderer/core/Sealable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,7 +35,7 @@ Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) { other.ensureUnsealed(); }; -Sealable::~Sealable() noexcept {}; +Sealable::~Sealable() noexcept = default; Sealable &Sealable::operator=(const Sealable &other) { ensureUnsealed(); diff --git a/ReactCommon/react/renderer/core/Sealable.h b/ReactCommon/react/renderer/core/Sealable.h index f57c42eda5ac2b..c92d9a7380076e 100644 --- a/ReactCommon/react/renderer/core/Sealable.h +++ b/ReactCommon/react/renderer/core/Sealable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNode.cpp b/ReactCommon/react/renderer/core/ShadowNode.cpp index 4c7258c4cbb77a..203d86e95b0be9 100644 --- a/ReactCommon/react/renderer/core/ShadowNode.cpp +++ b/ReactCommon/react/renderer/core/ShadowNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,7 +9,7 @@ #include "DynamicPropsUtilities.h" #include "ShadowNodeFragment.h" -#include +#include #include #include @@ -17,12 +17,14 @@ #include #include +#include + namespace facebook { namespace react { -SharedShadowNodeSharedList ShadowNode::emptySharedShadowNodeSharedList() { +ShadowNode::SharedListOfShared ShadowNode::emptySharedShadowNodeSharedList() { static const auto emptySharedShadowNodeSharedList = - std::make_shared(); + std::make_shared(); return emptySharedShadowNodeSharedList; } @@ -34,7 +36,7 @@ SharedShadowNodeSharedList ShadowNode::emptySharedShadowNodeSharedList() { * Background Executor and should be removed once reimplementation of JNI layer * is finished. */ -SharedProps ShadowNode::propsForClonedShadowNode( +Props::Shared ShadowNode::propsForClonedShadowNode( ShadowNode const &sourceShadowNode, Props::Shared const &props) { #ifdef ANDROID @@ -58,7 +60,7 @@ bool ShadowNode::sameFamily(const ShadowNode &first, const ShadowNode &second) { ShadowNode::ShadowNode( ShadowNodeFragment const &fragment, - ShadowNodeFamily::Shared const &family, + ShadowNodeFamily::Shared family, ShadowNodeTraits traits) : #if RN_DEBUG_STRING_CONVERTIBLE @@ -70,7 +72,7 @@ ShadowNode::ShadowNode( : emptySharedShadowNodeSharedList()), state_(fragment.state), orderIndex_(0), - family_(family), + family_(std::move(family)), traits_(traits) { react_native_assert(props_); react_native_assert(children_); @@ -129,7 +131,7 @@ ComponentHandle ShadowNode::getComponentHandle() const { return family_->getComponentHandle(); } -const SharedShadowNodeList &ShadowNode::getChildren() const { +const ShadowNode::ListOfShared &ShadowNode::getChildren() const { return *children_; } @@ -137,7 +139,7 @@ ShadowNodeTraits ShadowNode::getTraits() const { return traits_; } -const SharedProps &ShadowNode::getProps() const { +const Props::Shared &ShadowNode::getProps() const { return props_; } @@ -178,7 +180,7 @@ void ShadowNode::sealRecursive() const { props_->seal(); - for (auto child : *children_) { + for (auto const &child : *children_) { child->sealRecursive(); } } @@ -190,7 +192,7 @@ void ShadowNode::appendChild(const ShadowNode::Shared &child) { cloneChildrenIfShared(); auto nonConstChildren = - std::const_pointer_cast(children_); + std::const_pointer_cast(children_); nonConstChildren->push_back(child); child->family_->setParent(family_); @@ -235,7 +237,7 @@ void ShadowNode::cloneChildrenIfShared() { } traits_.unset(ShadowNodeTraits::Trait::ChildrenAreShared); - children_ = std::make_shared(*children_); + children_ = std::make_shared(*children_); } void ShadowNode::setMounted(bool mounted) const { @@ -253,8 +255,8 @@ ShadowNodeFamily const &ShadowNode::getFamily() const { ShadowNode::Unshared ShadowNode::cloneTree( ShadowNodeFamily const &shadowNodeFamily, - std::function - callback) const { + std::function const + &callback) const { auto ancestors = shadowNodeFamily.getAncestors(*this); if (ancestors.empty()) { @@ -283,7 +285,7 @@ ShadowNode::Unshared ShadowNode::cloneTree( childNode = parentNode.clone({ ShadowNodeFragment::propsPlaceholder(), - std::make_shared(children), + std::make_shared(children), }); } @@ -306,7 +308,7 @@ std::string ShadowNode::getDebugValue() const { SharedDebugStringConvertibleList ShadowNode::getDebugChildren() const { auto debugChildren = SharedDebugStringConvertibleList{}; - for (auto child : *children_) { + for (auto const &child : *children_) { auto debugChild = std::dynamic_pointer_cast(child); if (debugChild) { diff --git a/ReactCommon/react/renderer/core/ShadowNode.h b/ReactCommon/react/renderer/core/ShadowNode.h index 1ef71355f06f1d..8264065ffb2ee6 100644 --- a/ReactCommon/react/renderer/core/ShadowNode.h +++ b/ReactCommon/react/renderer/core/ShadowNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -28,15 +28,6 @@ static constexpr const int kShadowNodeChildrenSmallVectorSize = 8; class ComponentDescriptor; struct ShadowNodeFragment; -class ShadowNode; - -// Deprecated: Use ShadowNode::Shared instead -using SharedShadowNode = std::shared_ptr; -using WeakShadowNode = std::weak_ptr; -using SharedShadowNodeList = - better::small_vector; -using SharedShadowNodeSharedList = std::shared_ptr; -using SharedShadowNodeUnsharedList = std::shared_ptr; class ShadowNode : public Sealable, public DebugStringConvertible { public: @@ -44,20 +35,20 @@ class ShadowNode : public Sealable, public DebugStringConvertible { using Weak = std::weak_ptr; using Unshared = std::shared_ptr; using ListOfShared = - better::small_vector; + butter::small_vector; using ListOfWeak = - better::small_vector; + butter::small_vector; using SharedListOfShared = std::shared_ptr; using UnsharedListOfShared = std::shared_ptr; using UnsharedListOfWeak = std::shared_ptr; - using AncestorList = better::small_vector< + using AncestorList = butter::small_vector< std::pair< std::reference_wrapper /* parentNode */, int /* childIndex */>, 64>; - static SharedShadowNodeSharedList emptySharedShadowNodeSharedList(); + static SharedListOfShared emptySharedShadowNodeSharedList(); /* * Returns `true` if nodes belong to the same family (they were cloned one @@ -80,7 +71,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible { */ ShadowNode( ShadowNodeFragment const &fragment, - ShadowNodeFamily::Shared const &family, + ShadowNodeFamily::Shared family, ShadowNodeTraits traits); /* @@ -103,7 +94,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible { /* * Clones the shadow node using stored `cloneFunction`. */ - ShadowNode::Unshared clone(const ShadowNodeFragment &fragment) const; + Unshared clone(const ShadowNodeFragment &fragment) const; /* * Clones the node (and partially the tree starting from the node) by @@ -112,10 +103,10 @@ class ShadowNode : public Sealable, public DebugStringConvertible { * * Returns `nullptr` if the operation cannot be performed successfully. */ - ShadowNode::Unshared cloneTree( + Unshared cloneTree( ShadowNodeFamily const &shadowNodeFamily, - std::function - callback) const; + std::function const &callback) + const; #pragma mark - Getters @@ -127,8 +118,8 @@ class ShadowNode : public Sealable, public DebugStringConvertible { */ ShadowNodeTraits getTraits() const; - SharedProps const &getProps() const; - SharedShadowNodeList const &getChildren() const; + Props::Shared const &getProps() const; + ListOfShared const &getChildren() const; SharedEventEmitter const &getEventEmitter() const; Tag getTag() const; SurfaceId getSurfaceId() const; @@ -165,10 +156,10 @@ class ShadowNode : public Sealable, public DebugStringConvertible { #pragma mark - Mutating Methods - void appendChild(ShadowNode::Shared const &child); + void appendChild(Shared const &child); void replaceChild( ShadowNode const &oldChild, - ShadowNode::Shared const &newChild, + Shared const &newChild, int suggestedIndex = -1); /* @@ -195,8 +186,8 @@ class ShadowNode : public Sealable, public DebugStringConvertible { #endif protected: - SharedProps props_; - SharedShadowNodeSharedList children_; + Props::Shared props_; + SharedListOfShared children_; State::Shared state_; int orderIndex_; @@ -216,7 +207,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible { mutable std::atomic hasBeenMounted_{false}; - static SharedProps propsForClonedShadowNode( + static Props::Shared propsForClonedShadowNode( ShadowNode const &sourceShadowNode, Props::Shared const &props); diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index f4c0644255601d..73d022bf2efb94 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,6 +12,8 @@ #include #include +#include + namespace facebook { namespace react { @@ -21,7 +23,7 @@ ShadowNodeFamily::ShadowNodeFamily( ShadowNodeFamilyFragment const &fragment, EventDispatcher::Weak eventDispatcher, ComponentDescriptor const &componentDescriptor) - : eventDispatcher_(eventDispatcher), + : eventDispatcher_(std::move(eventDispatcher)), tag_(fragment.tag), surfaceId_(fragment.surfaceId), eventEmitter_(fragment.eventEmitter), @@ -57,7 +59,7 @@ const ComponentDescriptor &ShadowNodeFamily::getComponentDescriptor() const { AncestorList ShadowNodeFamily::getAncestors( ShadowNode const &ancestorShadowNode) const { - auto families = better::small_vector{}; + auto families = butter::small_vector{}; auto ancestorFamily = ancestorShadowNode.family_.get(); auto family = this; @@ -78,7 +80,7 @@ AncestorList ShadowNodeFamily::getAncestors( auto childIndex = 0; for (const auto &childNode : *parentNode->children_) { if (childNode->family_.get() == childFamily) { - ancestors.push_back({*parentNode, childIndex}); + ancestors.emplace_back(*parentNode, childIndex); parentNode = childNode.get(); found = true; break; @@ -96,12 +98,12 @@ AncestorList ShadowNodeFamily::getAncestors( } State::Shared ShadowNodeFamily::getMostRecentState() const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); return mostRecentState_; } void ShadowNodeFamily::setMostRecentState(State::Shared const &state) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); /* * Checking and setting `isObsolete_` prevents old states to be recommitted @@ -122,7 +124,7 @@ void ShadowNodeFamily::setMostRecentState(State::Shared const &state) const { std::shared_ptr ShadowNodeFamily::getMostRecentStateIfObsolete( State const &state) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); if (!state.isObsolete_) { return {}; } diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.h b/ReactCommon/react/renderer/core/ShadowNodeFamily.h index 07746e35501be6..a4ed371ff790c3 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.h +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include #include @@ -32,7 +32,7 @@ class ShadowNodeFamily final { using Shared = std::shared_ptr; using Weak = std::weak_ptr; - using AncestorList = better::small_vector< + using AncestorList = butter::small_vector< std::pair< std::reference_wrapper /* parentNode */, int /* childIndex */>, @@ -101,7 +101,7 @@ class ShadowNodeFamily final { EventDispatcher::Weak eventDispatcher_; mutable std::shared_ptr mostRecentState_; - mutable better::shared_mutex mutex_; + mutable butter::shared_mutex mutex_; /* * Deprecated. diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.cpp b/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.cpp index a16da43177392b..c744700c3fd742 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.h b/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.h index af380d6ff6c5d1..2f7aa4b148d96d 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.h +++ b/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNodeFragment.cpp b/ReactCommon/react/renderer/core/ShadowNodeFragment.cpp index 37b11150c13677..02793cc1245097 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFragment.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFragment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNodeFragment.h b/ReactCommon/react/renderer/core/ShadowNodeFragment.h index 6fbdc49451c708..f1b95afa3fdd08 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFragment.h +++ b/ReactCommon/react/renderer/core/ShadowNodeFragment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNodeTraits.cpp b/ReactCommon/react/renderer/core/ShadowNodeTraits.cpp index 6e200c32be3722..999581dd1d9bcc 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeTraits.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeTraits.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ShadowNodeTraits.h b/ReactCommon/react/renderer/core/ShadowNodeTraits.h index 7c02f4bea94a6a..d222f74d896243 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeTraits.h +++ b/ReactCommon/react/renderer/core/ShadowNodeTraits.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/State.cpp b/ReactCommon/react/renderer/core/State.cpp index e740557d362093..85c07a13fa193d 100644 --- a/ReactCommon/react/renderer/core/State.cpp +++ b/ReactCommon/react/renderer/core/State.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,16 +12,20 @@ #include #include +#include + namespace facebook { namespace react { -State::State(StateData::Shared const &data, State const &state) - : family_(state.family_), data_(data), revision_(state.revision_ + 1){}; +State::State(StateData::Shared data, State const &state) + : family_(state.family_), + data_(std::move(data)), + revision_(state.revision_ + 1){}; -State::State( - StateData::Shared const &data, - ShadowNodeFamily::Shared const &family) - : family_(family), data_(data), revision_{State::initialRevisionValue} {}; +State::State(StateData::Shared data, ShadowNodeFamily::Shared const &family) + : family_(family), + data_(std::move(data)), + revision_{State::initialRevisionValue} {}; State::Shared State::getMostRecentState() const { auto family = family_.lock(); diff --git a/ReactCommon/react/renderer/core/State.h b/ReactCommon/react/renderer/core/State.h index ce5b51fe065e03..6777bc5ca02a9a 100644 --- a/ReactCommon/react/renderer/core/State.h +++ b/ReactCommon/react/renderer/core/State.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -34,9 +34,9 @@ class State { * Constructors are protected to make calling them directly with * type-erasured arguments impossible. */ - explicit State(StateData::Shared const &data, State const &state); + explicit State(StateData::Shared data, State const &state); explicit State( - StateData::Shared const &data, + StateData::Shared data, ShadowNodeFamily::Shared const &family); public: diff --git a/ReactCommon/react/renderer/core/StateData.h b/ReactCommon/react/renderer/core/StateData.h index 36e098d1cd647d..8f08b1bb6e60fc 100644 --- a/ReactCommon/react/renderer/core/StateData.h +++ b/ReactCommon/react/renderer/core/StateData.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/StatePipe.h b/ReactCommon/react/renderer/core/StatePipe.h index ac79fad1a1d947..ace25817209a6e 100644 --- a/ReactCommon/react/renderer/core/StatePipe.h +++ b/ReactCommon/react/renderer/core/StatePipe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/StateUpdate.cpp b/ReactCommon/react/renderer/core/StateUpdate.cpp index 5c910c13177a82..ebbca947aa9e4a 100644 --- a/ReactCommon/react/renderer/core/StateUpdate.cpp +++ b/ReactCommon/react/renderer/core/StateUpdate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/StateUpdate.h b/ReactCommon/react/renderer/core/StateUpdate.h index 890e56d141092b..b275d06e4bb569 100644 --- a/ReactCommon/react/renderer/core/StateUpdate.h +++ b/ReactCommon/react/renderer/core/StateUpdate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp b/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp index 98210411f7482d..acdcfdcbf38383 100644 --- a/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/UnbatchedEventQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/UnbatchedEventQueue.h b/ReactCommon/react/renderer/core/UnbatchedEventQueue.h index 7bf94054658b69..a3626babb6ecf4 100644 --- a/ReactCommon/react/renderer/core/UnbatchedEventQueue.h +++ b/ReactCommon/react/renderer/core/UnbatchedEventQueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/ValueFactory.h b/ReactCommon/react/renderer/core/ValueFactory.h index e5956d39dc2c3c..37adc1bea96146 100644 --- a/ReactCommon/react/renderer/core/ValueFactory.h +++ b/ReactCommon/react/renderer/core/ValueFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/conversions.h b/ReactCommon/react/renderer/core/conversions.h index 70dda9a9f5589c..726aaa81ff0439 100644 --- a/ReactCommon/react/renderer/core/conversions.h +++ b/ReactCommon/react/renderer/core/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/propsConversions.h b/ReactCommon/react/renderer/core/propsConversions.h index 55e78f24303ac7..adbc07860736a0 100644 --- a/ReactCommon/react/renderer/core/propsConversions.h +++ b/ReactCommon/react/renderer/core/propsConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,8 @@ #pragma once -#include +#include + #include #include #include @@ -19,6 +20,35 @@ namespace facebook { namespace react { +/** + * Use this only when a prop update has definitely been sent from JS; + * essentially, cases where rawValue is virtually guaranteed to not be a + * nullptr. + */ +template +void fromRawValue( + const PropsParserContext &context, + RawValue const &rawValue, + T &result, + T defaultValue) { + if (!rawValue.hasValue()) { + result = std::move(defaultValue); + return; + } + + fromRawValue(context, rawValue, result); +} + +template +void fromRawValue( + const PropsParserContext &context, + RawValue const &rawValue, + std::optional &result) { + T res{}; + fromRawValue(context, rawValue, res); + result = std::optional(res); +} + template void fromRawValue( const PropsParserContext &context, @@ -106,12 +136,12 @@ T convertRawProp( } template -static better::optional convertRawProp( +static std::optional convertRawProp( const PropsParserContext &context, RawProps const &rawProps, char const *name, - better::optional const &sourceValue, - better::optional const &defaultValue, + std::optional const &sourceValue, + std::optional const &defaultValue, char const *namePrefix = nullptr, char const *nameSuffix = nullptr) { const auto *rawValue = rawProps.at(name, namePrefix, nameSuffix); @@ -128,7 +158,7 @@ static better::optional convertRawProp( T result; fromRawValue(context, *rawValue, result); - return better::optional{result}; + return std::optional{result}; } } // namespace react diff --git a/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp b/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp index 35a12911b250a1..33bd463ab3f2eb 100644 --- a/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp +++ b/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,7 +27,7 @@ TEST(ComponentDescriptorTest, createShadowNode) { PropsParserContext parserContext{-1, contextContainer}; const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); + Props::Shared props = descriptor->cloneProps(parserContext, nullptr, raw); auto family = descriptor->createFamily( ShadowNodeFamilyFragment{ @@ -37,7 +37,7 @@ TEST(ComponentDescriptorTest, createShadowNode) { }, nullptr); - SharedShadowNode node = descriptor->createShadowNode( + ShadowNode::Shared node = descriptor->createShadowNode( ShadowNodeFragment{ /* .props = */ props, }, @@ -61,7 +61,7 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { PropsParserContext parserContext{-1, contextContainer}; const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); + Props::Shared props = descriptor->cloneProps(parserContext, nullptr, raw); auto family = descriptor->createFamily( ShadowNodeFamilyFragment{ /* .tag = */ 9, @@ -69,12 +69,12 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { /* .eventEmitter = */ nullptr, }, nullptr); - SharedShadowNode node = descriptor->createShadowNode( + ShadowNode::Shared node = descriptor->createShadowNode( ShadowNodeFragment{ /* .props = */ props, }, family); - SharedShadowNode cloned = descriptor->cloneShadowNode(*node, {}); + ShadowNode::Shared cloned = descriptor->cloneShadowNode(*node, {}); EXPECT_STREQ(cloned->getComponentName(), "Test"); EXPECT_EQ(cloned->getTag(), 9); @@ -96,7 +96,7 @@ TEST(ComponentDescriptorTest, appendChild) { PropsParserContext parserContext{-1, contextContainer}; const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); - SharedProps props = descriptor->cloneProps(parserContext, nullptr, raw); + Props::Shared props = descriptor->cloneProps(parserContext, nullptr, raw); auto family1 = descriptor->createFamily( ShadowNodeFamilyFragment{ /* .tag = */ 1, @@ -104,7 +104,7 @@ TEST(ComponentDescriptorTest, appendChild) { /* .eventEmitter = */ nullptr, }, nullptr); - SharedShadowNode node1 = descriptor->createShadowNode( + ShadowNode::Shared node1 = descriptor->createShadowNode( ShadowNodeFragment{ /* .props = */ props, }, @@ -116,7 +116,7 @@ TEST(ComponentDescriptorTest, appendChild) { /* .eventEmitter = */ nullptr, }, nullptr); - SharedShadowNode node2 = descriptor->createShadowNode( + ShadowNode::Shared node2 = descriptor->createShadowNode( ShadowNodeFragment{ /* .props = */ props, }, @@ -128,7 +128,7 @@ TEST(ComponentDescriptorTest, appendChild) { /* .eventEmitter = */ nullptr, }, nullptr); - SharedShadowNode node3 = descriptor->createShadowNode( + ShadowNode::Shared node3 = descriptor->createShadowNode( ShadowNodeFragment{ /* .props = */ props, }, diff --git a/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp b/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp index 0b2d025d08ad40..f5e49e72793530 100644 --- a/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/DynamicPropsUtilitiesTest.cpp b/ReactCommon/react/renderer/core/tests/DynamicPropsUtilitiesTest.cpp index b6666ad0842a6f..1ebb12b3a81cd2 100644 --- a/ReactCommon/react/renderer/core/tests/DynamicPropsUtilitiesTest.cpp +++ b/ReactCommon/react/renderer/core/tests/DynamicPropsUtilitiesTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp index 268a6a0aca903f..feb6c16973a921 100644 --- a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp +++ b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp b/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp index 37f1c4106db603..dc53b11ab0b00f 100644 --- a/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp +++ b/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -45,9 +45,9 @@ TEST(FindNodeAtPointTest, withoutTransform) { }) }) }); - + auto parentShadowNode = builder.build(element); - + EXPECT_EQ( LayoutableShadowNode::findNodeAtPoint(parentShadowNode, {115, 115})->getTag(), 3); EXPECT_EQ(LayoutableShadowNode::findNodeAtPoint(parentShadowNode, {105, 105})->getTag(), 2); @@ -91,7 +91,7 @@ TEST(FindNodeAtPointTest, viewIsTranslated) { }) }) }); - + auto parentShadowNode = builder.build(element); EXPECT_EQ( @@ -125,7 +125,7 @@ TEST(FindNodeAtPointTest, viewIsScaled) { Element() .tag(3) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); sharedProps->transform = Transform::Scale(0.5, 0.5, 0); return sharedProps; }) @@ -137,7 +137,7 @@ TEST(FindNodeAtPointTest, viewIsScaled) { }) }) }); - + auto parentShadowNode = builder.build(element); EXPECT_EQ( @@ -175,9 +175,9 @@ TEST(FindNodeAtPointTest, overlappingViews) { shadowNode.setLayoutMetrics(layoutMetrics); }) }); - + auto parentShadowNode = builder.build(element); - + EXPECT_EQ( LayoutableShadowNode::findNodeAtPoint(parentShadowNode, {50, 50})->getTag(), 3); } @@ -198,7 +198,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) { Element() .tag(2) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); sharedProps->zIndex = 1; auto &yogaStyle = sharedProps->yogaStyle; yogaStyle.positionType() = YGPositionTypeAbsolute; @@ -219,11 +219,9 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) { shadowNode.setLayoutMetrics(layoutMetrics); }) }); - + auto parentShadowNode = builder.build(element); - + EXPECT_EQ( LayoutableShadowNode::findNodeAtPoint(parentShadowNode, {50, 50})->getTag(), 2); } - - diff --git a/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp b/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp index c6dc5f68b5bfac..55c761c9542457 100644 --- a/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -148,7 +148,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedNode) { shadowNode.setLayoutMetrics(layoutMetrics); }) .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); sharedProps->transform = Transform::Scale(0.5, 0.5, 1); return sharedProps; }) @@ -199,7 +199,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedParent) { .children({ Element() .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); sharedProps->transform = Transform::Scale(0.5, 0.5, 1); return sharedProps; }) @@ -280,7 +280,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameTransformedNode) { auto element = Element() .props([] { - auto sharedProps = std::make_shared(); + auto sharedProps = std::make_shared(); sharedProps->transform = Transform::Scale(2, 2, 1); return sharedProps; }) diff --git a/ReactCommon/react/renderer/core/tests/PrimitivesTest.cpp b/ReactCommon/react/renderer/core/tests/PrimitivesTest.cpp index f3b4d9bafbea0e..2827d9b45d5826 100644 --- a/ReactCommon/react/renderer/core/tests/PrimitivesTest.cpp +++ b/ReactCommon/react/renderer/core/tests/PrimitivesTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index e54b623c9984b6..fe90800696579b 100644 --- a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp b/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp index 0009baeed7b09e..238b4e579a76d2 100644 --- a/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp +++ b/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp b/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp index 7039e56cfdfa8b..7a403ede529d5f 100644 --- a/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp +++ b/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -85,8 +85,8 @@ class ShadowNodeTest : public ::testing::Test { familyABB, traits); - auto nodeABChildren = std::make_shared( - SharedShadowNodeList{nodeABA_, nodeABB_}); + auto nodeABChildren = std::make_shared( + ShadowNode::ListOfShared{nodeABA_, nodeABB_}); auto familyAB = std::make_shared( ShadowNodeFamilyFragment{ @@ -120,8 +120,8 @@ class ShadowNodeTest : public ::testing::Test { familyAC, traits); - auto nodeAChildren = std::make_shared( - SharedShadowNodeList{nodeAA_, nodeAB_, nodeAC_}); + auto nodeAChildren = std::make_shared( + ShadowNode::ListOfShared{nodeAA_, nodeAB_, nodeAC_}); auto familyA = std::make_shared( ShadowNodeFamilyFragment{ diff --git a/ReactCommon/react/renderer/core/tests/TestComponent.h b/ReactCommon/react/renderer/core/tests/TestComponent.h index a396f1ba6217b6..0e9931cc46aea5 100644 --- a/ReactCommon/react/renderer/core/tests/TestComponent.h +++ b/ReactCommon/react/renderer/core/tests/TestComponent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp b/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp index 2f7f6e96242e65..30e186ed7c4e00 100644 --- a/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp +++ b/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,10 +25,10 @@ auto viewComponentDescriptor = ViewComponentDescriptor{ auto emptyPropsDynamic = folly::parseJson("{}"); auto propsString = std::string{ - "{\"flex\": 1, \"padding\": 10, \"position\": \"absolute\", \"display\": \"none\", \"nativeID\": \"some-id\", \"direction\": \"rtl\"}"}; + R"({"flex": 1, "padding": 10, "position": "absolute", "display": "none", "nativeID": "some-id", "direction": "rtl"})"}; auto propsDynamic = folly::parseJson(propsString); auto propsStringWithSomeUnsupportedProps = std::string{ - "{\"someName1\": 1, \"someName2\": 10, \"someName3\": \"absolute\", \"someName4\": \"none\", \"someName5\": \"some-id\", \"someName6\": \"rtl\"}"}; + R"({"someName1": 1, "someName2": 10, "someName3": "absolute", "someName4": "none", "someName5": "some-id", "someName6": "rtl"})"}; auto unsupportedPropsDynamic = folly::parseJson(propsStringWithSomeUnsupportedProps); @@ -43,33 +43,42 @@ static void emptyPropCreation(benchmark::State &state) { BENCHMARK(emptyPropCreation); static void propParsingEmptyRawProps(benchmark::State &state) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; for (auto _ : state) { viewComponentDescriptor.cloneProps( - sharedSourceProps, RawProps{emptyPropsDynamic}); + parserContext, sharedSourceProps, RawProps{emptyPropsDynamic}); } } BENCHMARK(propParsingEmptyRawProps); static void propParsingRegularRawProps(benchmark::State &state) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; for (auto _ : state) { viewComponentDescriptor.cloneProps( - sharedSourceProps, RawProps{propsDynamic}); + parserContext, sharedSourceProps, RawProps{propsDynamic}); } } BENCHMARK(propParsingRegularRawProps); static void propParsingUnsupportedRawProps(benchmark::State &state) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; for (auto _ : state) { viewComponentDescriptor.cloneProps( - sharedSourceProps, RawProps{unsupportedPropsDynamic}); + parserContext, sharedSourceProps, RawProps{unsupportedPropsDynamic}); } } BENCHMARK(propParsingUnsupportedRawProps); static void propParsingRegularRawPropsWithNoSourceProps( benchmark::State &state) { + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; for (auto _ : state) { - viewComponentDescriptor.cloneProps(nullptr, RawProps{propsDynamic}); + viewComponentDescriptor.cloneProps( + parserContext, nullptr, RawProps{propsDynamic}); } } BENCHMARK(propParsingRegularRawPropsWithNoSourceProps); diff --git a/ReactCommon/react/renderer/core/tests/traitCastTest.cpp b/ReactCommon/react/renderer/core/tests/traitCastTest.cpp index e68e4b16663357..1154257792ab43 100644 --- a/ReactCommon/react/renderer/core/tests/traitCastTest.cpp +++ b/ReactCommon/react/renderer/core/tests/traitCastTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/debug/Android.mk b/ReactCommon/react/renderer/debug/Android.mk deleted file mode 100644 index e856283cc6a4f6..00000000000000 --- a/ReactCommon/react/renderer/debug/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_debug - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libfolly_json - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) diff --git a/ReactCommon/react/renderer/debug/BUCK b/ReactCommon/react/renderer/debug/BUCK index 73bed3edf81134..d103d00f3b6ae0 100644 --- a/ReactCommon/react/renderer/debug/BUCK +++ b/ReactCommon/react/renderer/debug/BUCK @@ -36,7 +36,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -47,10 +50,10 @@ rn_xplat_cxx_library( visibility = ["PUBLIC"], deps = [ "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("react/debug:debug"), ], ) diff --git a/ReactCommon/react/renderer/debug/CMakeLists.txt b/ReactCommon/react/renderer/debug/CMakeLists.txt new file mode 100644 index 00000000000000..44c5fd4c92dece --- /dev/null +++ b/ReactCommon/react/renderer/debug/CMakeLists.txt @@ -0,0 +1,15 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_debug_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_debug SHARED ${react_render_debug_SRC}) + +target_include_directories(react_render_debug PUBLIC ${REACT_COMMON_DIR}) +target_link_libraries(react_render_debug folly_runtime) diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp index 7e2aa50e669a9e..fde19f4163a29e 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp +++ b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,7 +26,7 @@ std::string DebugStringConvertible::getDebugChildrenDescription( auto trailing = options.format ? std::string{"\n"} : std::string{""}; auto childrenString = std::string{""}; - for (auto child : getDebugChildren()) { + for (auto const &child : getDebugChildren()) { if (!child) { continue; } @@ -52,7 +52,7 @@ std::string DebugStringConvertible::getDebugPropsDescription( auto propsString = std::string{""}; - for (auto prop : getDebugProps()) { + for (auto const &prop : getDebugProps()) { if (!prop) { continue; } diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertible.h b/ReactCommon/react/renderer/debug/DebugStringConvertible.h index 8833211cd2599d..a9a1ef02b4e349 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertible.h +++ b/ReactCommon/react/renderer/debug/DebugStringConvertible.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.cpp b/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.cpp index 73606d87424a41..9f074600c74e48 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.cpp +++ b/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,17 +7,22 @@ #include "DebugStringConvertibleItem.h" +#include + namespace facebook { namespace react { #if RN_DEBUG_STRING_CONVERTIBLE DebugStringConvertibleItem::DebugStringConvertibleItem( - const std::string &name, - const std::string &value, - const SharedDebugStringConvertibleList &props, - const SharedDebugStringConvertibleList &children) - : name_(name), value_(value), debugProps_(props), children_(children) {} + std::string name, + std::string value, + SharedDebugStringConvertibleList props, + SharedDebugStringConvertibleList children) + : name_(std::move(name)), + value_(std::move(value)), + debugProps_(std::move(props)), + children_(std::move(children)) {} std::string DebugStringConvertibleItem::getDebugName() const { return name_; diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.h b/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.h index 600113d810a46b..6f01c8b7e13676 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.h +++ b/ReactCommon/react/renderer/debug/DebugStringConvertibleItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,10 +24,10 @@ class DebugStringConvertibleItem : public DebugStringConvertible { DebugStringConvertibleItem(const DebugStringConvertibleItem &item) = default; DebugStringConvertibleItem( - const std::string &name = "", - const std::string &value = "", - const SharedDebugStringConvertibleList &props = {}, - const SharedDebugStringConvertibleList &children = {}); + std::string name = "", + std::string value = "", + SharedDebugStringConvertibleList props = {}, + SharedDebugStringConvertibleList children = {}); std::string getDebugName() const override; std::string getDebugValue() const override; diff --git a/ReactCommon/react/renderer/debug/SystraceSection.h b/ReactCommon/react/renderer/debug/SystraceSection.h index 603c823b4e5132..d3ccd0b4827e29 100644 --- a/ReactCommon/react/renderer/debug/SystraceSection.h +++ b/ReactCommon/react/renderer/debug/SystraceSection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h b/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h index a41054e2207ba6..6fde6333157a61 100644 --- a/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h +++ b/ReactCommon/react/renderer/debug/debugStringConvertibleUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include #include #include @@ -34,9 +34,9 @@ debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) { template inline SharedDebugStringConvertible debugStringConvertibleItem( std::string name, - better::optional value, + std::optional value, T defaultValue = {}) { - if (!value.hasValue()) { + if (!value.has_value()) { return nullptr; } diff --git a/ReactCommon/react/renderer/debug/flags.h b/ReactCommon/react/renderer/debug/flags.h index 698c9a55fc528e..0239bf6b0c77ff 100644 --- a/ReactCommon/react/renderer/debug/flags.h +++ b/ReactCommon/react/renderer/debug/flags.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/debug/tests/DebugStringConvertibleTest.cpp b/ReactCommon/react/renderer/debug/tests/DebugStringConvertibleTest.cpp index 1220542c01e23f..fa0210739172d3 100644 --- a/ReactCommon/react/renderer/debug/tests/DebugStringConvertibleTest.cpp +++ b/ReactCommon/react/renderer/debug/tests/DebugStringConvertibleTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/BUCK b/ReactCommon/react/renderer/element/BUCK index 6db4cf614b9848..860b323355b842 100644 --- a/ReactCommon/react/renderer/element/BUCK +++ b/ReactCommon/react/renderer/element/BUCK @@ -34,7 +34,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ diff --git a/ReactCommon/react/renderer/element/ComponentBuilder.cpp b/ReactCommon/react/renderer/element/ComponentBuilder.cpp index c1438bb63aafd8..e6e1dd300bead6 100644 --- a/ReactCommon/react/renderer/element/ComponentBuilder.cpp +++ b/ReactCommon/react/renderer/element/ComponentBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,12 +7,14 @@ #include "ComponentBuilder.h" +#include + namespace facebook { namespace react { ComponentBuilder::ComponentBuilder( - ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry) - : componentDescriptorRegistry_(componentDescriptorRegistry){}; + ComponentDescriptorRegistry::Shared componentDescriptorRegistry) + : componentDescriptorRegistry_(std::move(componentDescriptorRegistry)){}; ShadowNode::Unshared ComponentBuilder::build( ElementFragment const &elementFragment) const { diff --git a/ReactCommon/react/renderer/element/ComponentBuilder.h b/ReactCommon/react/renderer/element/ComponentBuilder.h index b47ba81bd5c45b..458323c309c917 100644 --- a/ReactCommon/react/renderer/element/ComponentBuilder.h +++ b/ReactCommon/react/renderer/element/ComponentBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,7 +27,7 @@ namespace react { class ComponentBuilder final { public: ComponentBuilder( - ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry); + ComponentDescriptorRegistry::Shared componentDescriptorRegistry); /* * Copyable and movable. diff --git a/ReactCommon/react/renderer/element/Element.cpp b/ReactCommon/react/renderer/element/Element.cpp index cf72b623347d17..0960746950ca34 100644 --- a/ReactCommon/react/renderer/element/Element.cpp +++ b/ReactCommon/react/renderer/element/Element.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/Element.h b/ReactCommon/react/renderer/element/Element.h index b6e36a789effd4..67233ae3380024 100644 --- a/ReactCommon/react/renderer/element/Element.h +++ b/ReactCommon/react/renderer/element/Element.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/ElementFragment.cpp b/ReactCommon/react/renderer/element/ElementFragment.cpp index 4421f09d3065ed..14cae7836e6dde 100644 --- a/ReactCommon/react/renderer/element/ElementFragment.cpp +++ b/ReactCommon/react/renderer/element/ElementFragment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/ElementFragment.h b/ReactCommon/react/renderer/element/ElementFragment.h index fd0807a2cece9e..6a14ed154804d3 100644 --- a/ReactCommon/react/renderer/element/ElementFragment.h +++ b/ReactCommon/react/renderer/element/ElementFragment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/testUtils.h b/ReactCommon/react/renderer/element/testUtils.h index 4452c17c52d6fd..2d6a07141a668a 100644 --- a/ReactCommon/react/renderer/element/testUtils.h +++ b/ReactCommon/react/renderer/element/testUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/element/tests/ElementTest.cpp b/ReactCommon/react/renderer/element/tests/ElementTest.cpp index ad79f4b6565738..85860fcc2d8438 100644 --- a/ReactCommon/react/renderer/element/tests/ElementTest.cpp +++ b/ReactCommon/react/renderer/element/tests/ElementTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,7 +26,7 @@ TEST(ElementTest, testNormalCases) { auto shadowNodeAB = std::shared_ptr{}; auto shadowNodeABA = std::shared_ptr{}; - auto propsAA = std::make_shared(); + auto propsAA = std::make_shared(); propsAA->nativeId = "node AA"; // clang-format off @@ -51,7 +51,7 @@ TEST(ElementTest, testNormalCases) { .reference(shadowNodeAB) .tag(3) .props([]() { - auto props = std::make_shared(); + auto props = std::make_shared(); props->nativeId = "node AB"; return props; }) @@ -60,7 +60,7 @@ TEST(ElementTest, testNormalCases) { .reference(shadowNodeABA) .tag(4) .props([]() { - auto props = std::make_shared(); + auto props = std::make_shared(); props->nativeId = "node ABA"; return props; }) diff --git a/ReactCommon/react/renderer/graphics/Android.mk b/ReactCommon/react/renderer/graphics/Android.mk deleted file mode 100644 index 94e3adbce79a1d..00000000000000 --- a/ReactCommon/react/renderer/graphics/Android.mk +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_graphics - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/graphics/*.cpp) - -LOCAL_SHARED_LIBRARIES := libfolly_json libreact_debug libfb libfbjni libfolly_json glog - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbjni) -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/graphics/BUCK b/ReactCommon/react/renderer/graphics/BUCK index 34748db242729b..11617a7c884daa 100644 --- a/ReactCommon/react/renderer/graphics/BUCK +++ b/ReactCommon/react/renderer/graphics/BUCK @@ -91,7 +91,10 @@ rn_xplat_cxx_library( "platform/ios/**/*.mm", ], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -102,10 +105,10 @@ rn_xplat_cxx_library( visibility = ["PUBLIC"], deps = [ react_native_xplat_target("react/debug:debug"), - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", ], diff --git a/ReactCommon/react/renderer/graphics/CMakeLists.txt b/ReactCommon/react/renderer/graphics/CMakeLists.txt new file mode 100644 index 00000000000000..a52ce0bfe1fdbd --- /dev/null +++ b/ReactCommon/react/renderer/graphics/CMakeLists.txt @@ -0,0 +1,25 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_graphics_SRC CONFIGURE_DEPENDS + *.cpp + platform/cxx/react/renderer/graphics/*.cpp) + +add_library(react_render_graphics + SHARED + ${react_render_graphics_SRC}) + +target_include_directories(react_render_graphics + PUBLIC + ${REACT_COMMON_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/platform/cxx/ + ) + +target_link_libraries(react_render_graphics glog fb fbjni folly_runtime react_debug) diff --git a/ReactCommon/react/renderer/graphics/ColorComponents.h b/ReactCommon/react/renderer/graphics/ColorComponents.h index 8dce73d31590aa..870a8c33ce7ad3 100644 --- a/ReactCommon/react/renderer/graphics/ColorComponents.h +++ b/ReactCommon/react/renderer/graphics/ColorComponents.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/Geometry.h b/ReactCommon/react/renderer/graphics/Geometry.h index db3c3de4ffb1fa..409ee06667f8e3 100644 --- a/ReactCommon/react/renderer/graphics/Geometry.h +++ b/ReactCommon/react/renderer/graphics/Geometry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/Point.h b/ReactCommon/react/renderer/graphics/Point.h index 41c0c4d0e280a0..fe05894862f455 100644 --- a/ReactCommon/react/renderer/graphics/Point.h +++ b/ReactCommon/react/renderer/graphics/Point.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/React-graphics.podspec b/ReactCommon/react/renderer/graphics/React-graphics.podspec index bb4913623839ce..3f7ff0da5be7ba 100644 --- a/ReactCommon/react/renderer/graphics/React-graphics.podspec +++ b/ReactCommon/react/renderer/graphics/React-graphics.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.source = source s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.source_files = "**/*.{m,mm,cpp,h}" diff --git a/ReactCommon/react/renderer/graphics/Rect.h b/ReactCommon/react/renderer/graphics/Rect.h index 19db0b44b6ac1f..8cb12dda0d05c4 100644 --- a/ReactCommon/react/renderer/graphics/Rect.h +++ b/ReactCommon/react/renderer/graphics/Rect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/RectangleCorners.h b/ReactCommon/react/renderer/graphics/RectangleCorners.h index 771dc9f24b8e09..438ee96a77d544 100644 --- a/ReactCommon/react/renderer/graphics/RectangleCorners.h +++ b/ReactCommon/react/renderer/graphics/RectangleCorners.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/RectangleEdges.h b/ReactCommon/react/renderer/graphics/RectangleEdges.h index 616abe07e7b253..2deae70b306c1a 100644 --- a/ReactCommon/react/renderer/graphics/RectangleEdges.h +++ b/ReactCommon/react/renderer/graphics/RectangleEdges.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -39,8 +39,13 @@ struct RectangleEdges { bool isUniform() const noexcept { return left == top && left == right && left == bottom; } + + static RectangleEdges const ZERO; }; +template +constexpr RectangleEdges const RectangleEdges::ZERO = {}; + template RectangleEdges operator+( RectangleEdges const &lhs, diff --git a/ReactCommon/react/renderer/graphics/Size.h b/ReactCommon/react/renderer/graphics/Size.h index 9c093cfd8ca894..c5e3e8a44bb50b 100644 --- a/ReactCommon/react/renderer/graphics/Size.h +++ b/ReactCommon/react/renderer/graphics/Size.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/Transform.cpp b/ReactCommon/react/renderer/graphics/Transform.cpp index 90a588b84ad62d..d34246fa17ebc3 100644 --- a/ReactCommon/react/renderer/graphics/Transform.cpp +++ b/ReactCommon/react/renderer/graphics/Transform.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -360,6 +360,14 @@ Rect operator*(Rect const &rect, Transform const &transform) { transformedA, transformedB, transformedC, transformedD); } +EdgeInsets operator*(EdgeInsets const &edgeInsets, Transform const &transform) { + return EdgeInsets{ + edgeInsets.left * transform.matrix[0], + edgeInsets.top * transform.matrix[5], + edgeInsets.right * transform.matrix[0], + edgeInsets.bottom * transform.matrix[5]}; +} + Vector operator*(Transform const &transform, Vector const &vector) { return { vector.x * transform.at(0, 0) + vector.y * transform.at(1, 0) + diff --git a/ReactCommon/react/renderer/graphics/Transform.h b/ReactCommon/react/renderer/graphics/Transform.h index a346c713acc428..a275afb1944183 100644 --- a/ReactCommon/react/renderer/graphics/Transform.h +++ b/ReactCommon/react/renderer/graphics/Transform.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -165,21 +165,27 @@ struct Transform { }; /* - * Applies tranformation to the given point. + * Applies transformation to the given point. */ Point operator*(Point const &point, Transform const &transform); /* - * Applies tranformation to the given size. + * Applies transformation to the given size. */ Size operator*(Size const &size, Transform const &transform); /* - * Applies tranformation to the given rect. + * Applies transformation to the given rect. * ONLY SUPPORTS scale and translation transformation. */ Rect operator*(Rect const &rect, Transform const &transform); +/* + * Applies tranformation to the given EdgeInsets. + * ONLY SUPPORTS scale transformation. + */ +EdgeInsets operator*(EdgeInsets const &edgeInsets, Transform const &transform); + Vector operator*(Transform const &transform, Vector const &vector); } // namespace react diff --git a/ReactCommon/react/renderer/graphics/conversions.h b/ReactCommon/react/renderer/graphics/conversions.h index a30d03daf644a5..8e28bdcb4d6372 100644 --- a/ReactCommon/react/renderer/graphics/conversions.h +++ b/ReactCommon/react/renderer/graphics/conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -51,17 +51,7 @@ inline void fromRawValue( #ifdef ANDROID -inline folly::dynamic toDynamic(const SharedColor &color) { - ColorComponents components = colorComponentsFromColor(color); - auto ratio = 255.f; - return ( - ((int)round(components.alpha * ratio) & 0xff) << 24 | - ((int)round(components.red * ratio) & 0xff) << 16 | - ((int)round(components.green * ratio) & 0xff) << 8 | - ((int)round(components.blue * ratio) & 0xff)); -} - -inline int toMapBuffer(const SharedColor &color) { +inline int toAndroidRepr(const SharedColor &color) { ColorComponents components = colorComponentsFromColor(color); auto ratio = 255.f; return ( @@ -88,8 +78,8 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, Point &result) { - if (value.hasType>()) { - auto map = (better::map)value; + if (value.hasType>()) { + auto map = (butter::map)value; for (const auto &pair : map) { if (pair.first == "x") { result.x = pair.second; @@ -119,8 +109,8 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, Size &result) { - if (value.hasType>()) { - auto map = (better::map)value; + if (value.hasType>()) { + auto map = (butter::map)value; for (const auto &pair : map) { if (pair.first == "width") { result.width = pair.second; @@ -156,10 +146,11 @@ inline void fromRawValue( if (value.hasType()) { auto number = (Float)value; result = {number, number, number, number}; + return; } - if (value.hasType>()) { - auto map = (better::map)value; + if (value.hasType>()) { + auto map = (butter::map)value; for (const auto &pair : map) { if (pair.first == "top") { result.top = pair.second; @@ -202,8 +193,8 @@ inline void fromRawValue( return; } - if (value.hasType>()) { - auto map = (better::map)value; + if (value.hasType>()) { + auto map = (butter::map)value; for (const auto &pair : map) { if (pair.first == "topLeft") { result.topLeft = pair.second; diff --git a/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.h b/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.h index 950dd1ad842642..be78b82b5826cd 100644 --- a/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.h +++ b/ReactCommon/react/renderer/graphics/platform/android/react/renderer/graphics/PlatformColorParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,36 +21,24 @@ inline ColorComponents parsePlatformColor( const RawValue &value) { ColorComponents colorComponents = {0, 0, 0, 0}; - if (value.hasType>>()) { - auto map = (better::map>)value; - auto resourcePaths = map["resource_paths"]; - auto dynamicResourcePaths = folly::dynamic::array(); - for (const auto &resourcePath : resourcePaths) { - dynamicResourcePaths.push_back(resourcePath); - } - folly::dynamic dynamicPlatformColor = folly::dynamic::object(); - dynamicPlatformColor["resource_paths"] = dynamicResourcePaths; - - auto fabricUIManager = + if (value.hasType>>()) { + const auto &fabricUIManager = context.contextContainer.at>( "FabricUIManager"); - static auto getColorFromJava = - facebook::jni::findClassStatic( - "com/facebook/react/fabric/FabricUIManager") - ->getMethod("getColor"); + fabricUIManager->getClass() + ->getMethod)>("getColor"); - jni::local_ref dynamicPlatformColorRNM = - ReadableNativeMap::newObjectCxxArgs(dynamicPlatformColor); - jni::local_ref dynamicPlatformColorRM = - jni::make_local(reinterpret_cast( - dynamicPlatformColorRNM.get())); + auto map = (butter::map>)value; + auto &resourcePaths = map["resource_paths"]; + auto javaResourcePaths = + jni::JArrayClass::newArray(resourcePaths.size()); + for (int i = 0; i < resourcePaths.size(); i++) { + javaResourcePaths->setElement(i, *jni::make_jstring(resourcePaths[i])); + } auto color = getColorFromJava( - fabricUIManager, context.surfaceId, dynamicPlatformColorRM.get()); - - dynamicPlatformColorRM.reset(); - dynamicPlatformColorRNM.reset(); + fabricUIManager, context.surfaceId, *javaResourcePaths); auto argb = (int64_t)color; auto ratio = 255.f; diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp index 455ce60dc53718..02c6bf82d4abbc 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,7 +27,7 @@ SharedColor colorFromComponents(ColorComponents components) { ((int)round(components.blue * ratio) & 0xff)); } -ColorComponents colorComponentsFromColor(SharedColor sharedColor) { +ColorComponents colorComponentsFromColor(SharedColor const &sharedColor) { float ratio = 255; Color color = *sharedColor; return ColorComponents{ diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h index 34c7f6f53f3eb8..7de09df3adc5db 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -61,7 +61,7 @@ class SharedColor { bool isColorMeaningful(SharedColor const &color) noexcept; SharedColor colorFromComponents(ColorComponents components); -ColorComponents colorComponentsFromColor(SharedColor color); +ColorComponents colorComponentsFromColor(SharedColor const &color); SharedColor clearColor(); SharedColor blackColor(); diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h index b15a893bee1f18..ef2c55c93ff24f 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/PlatformColorParser.h b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/PlatformColorParser.h index c48403ba22ab71..83809d751b011a 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/PlatformColorParser.h +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/PlatformColorParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/platform/ios/Color.cpp b/ReactCommon/react/renderer/graphics/platform/ios/Color.cpp index 0c42253b94e9d5..61da5e26797f1c 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/Color.cpp +++ b/ReactCommon/react/renderer/graphics/platform/ios/Color.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/platform/ios/Color.h b/ReactCommon/react/renderer/graphics/platform/ios/Color.h index 5078b43f1e4b7f..0a50fa455ad54f 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/Color.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/Color.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include diff --git a/ReactCommon/react/renderer/graphics/platform/ios/Float.h b/ReactCommon/react/renderer/graphics/platform/ios/Float.h index 2346e7b75f8d2f..4bee49ced99ecb 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/Float.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/Float.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h b/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h index 3437b280760d99..28922fff67b282 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,8 +18,8 @@ namespace react { inline ColorComponents parsePlatformColor( const PropsParserContext &context, const RawValue &value) { - if (value.hasType>()) { - auto items = (better::map)value; + if (value.hasType>()) { + auto items = (butter::map)value; if (items.find("semantic") != items.end() && items.at("semantic").hasType>()) { auto semanticItems = (std::vector)items.at("semantic"); diff --git a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.h b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.h index 6994c1e0b856e8..64eab12620bf9a 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm index 6143162af52886..f11b2af9e40e8e 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm +++ b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/rounding.h b/ReactCommon/react/renderer/graphics/rounding.h index b43b9d494d4b21..bbdc7d33e161eb 100644 --- a/ReactCommon/react/renderer/graphics/rounding.h +++ b/ReactCommon/react/renderer/graphics/rounding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/tests/GraphicsTest.cpp b/ReactCommon/react/renderer/graphics/tests/GraphicsTest.cpp index 7a59aa1ac77036..b338ccd0b1d525 100644 --- a/ReactCommon/react/renderer/graphics/tests/GraphicsTest.cpp +++ b/ReactCommon/react/renderer/graphics/tests/GraphicsTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/graphics/tests/TransformTest.cpp b/ReactCommon/react/renderer/graphics/tests/TransformTest.cpp index 9c40fc341f49e3..bcd0641d62f903 100644 --- a/ReactCommon/react/renderer/graphics/tests/TransformTest.cpp +++ b/ReactCommon/react/renderer/graphics/tests/TransformTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,7 +8,7 @@ #include #include -#include +#include using namespace facebook::react; diff --git a/ReactCommon/react/renderer/imagemanager/Android.mk b/ReactCommon/react/renderer/imagemanager/Android.mk deleted file mode 100644 index 83f3ae91f45e5c..00000000000000 --- a/ReactCommon/react/renderer/imagemanager/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_imagemanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/imagemanager/*.cpp) - -LOCAL_SHARED_LIBRARIES := libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_mounting libreact_debug - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/imagemanager/BUCK b/ReactCommon/react/renderer/imagemanager/BUCK index 557d5f3c294ce4..bba253a74f9ef5 100644 --- a/ReactCommon/react/renderer/imagemanager/BUCK +++ b/ReactCommon/react/renderer/imagemanager/BUCK @@ -18,39 +18,23 @@ APPLE_COMPILER_FLAGS = get_apple_compiler_flags() rn_xplat_cxx_library( name = "imagemanager", srcs = glob( - [ - "*.cpp", - ], + ["*.cpp"], exclude = glob(["tests/**/*.cpp"]), ), + headers = subdir_glob( + [("", "*.h")], + prefix = "", + ), header_namespace = "", exported_headers = subdir_glob( - [ - ("", "*.h"), - ("platform/cxx", "**/*.h"), - ], + [("", "*.h")], prefix = "react/renderer/imagemanager", ), contacts = ["oncall+react_native@xmail.facebook.com"], - fbandroid_exported_headers = subdir_glob( - [ - ("", "*.h"), - ("platform/cxx", "**/*.h"), - ], - prefix = "react/renderer/imagemanager", - ), - fbandroid_headers = subdir_glob( - [ - ("", "*.h"), - ("platform/cxx", "**/*.h"), - ], - prefix = "", - ), - fbandroid_srcs = glob( - [ - "platform/cxx/**/*.cpp", - ], - ), + cxx_srcs = glob(["platform/cxx/**/*.cpp"]), + # FIXME: android relies on stubs implemented for the cxx platform + fbandroid_srcs = glob(["platform/cxx/**/*.cpp"]), + fbandroid_tests_override = [], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags() + [ "-DLOG_TAG=\"ReactNative\"", @@ -86,7 +70,10 @@ rn_xplat_cxx_library( "platform/ios/**/*.mm", ], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -96,7 +83,7 @@ rn_xplat_cxx_library( tests = [":tests"], visibility = ["PUBLIC"], deps = [ - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:molly", YOGA_CXX_TARGET, react_native_xplat_target("react/debug:debug"), @@ -118,7 +105,7 @@ fb_xplat_cxx_test( "-Wall", ], contacts = ["oncall+react_native@xmail.facebook.com"], - platforms = (ANDROID, APPLE, CXX), + platforms = (APPLE, CXX), deps = [ ":imagemanager", "//xplat/folly:molly", diff --git a/ReactCommon/react/renderer/imagemanager/CMakeLists.txt b/ReactCommon/react/renderer/imagemanager/CMakeLists.txt new file mode 100644 index 00000000000000..c27b11febcc364 --- /dev/null +++ b/ReactCommon/react/renderer/imagemanager/CMakeLists.txt @@ -0,0 +1,34 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_imagemanager_SRC CONFIGURE_DEPENDS + *.cpp + platform/cxx/react/renderer/imagemanager/*.cpp) + +add_library(react_render_imagemanager + SHARED + ${react_render_imagemanager_SRC}) + +target_include_directories(react_render_imagemanager + PUBLIC + ${REACT_COMMON_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/platform/cxx/ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +target_link_libraries(react_render_imagemanager + folly_runtime + react_debug + react_render_core + react_render_debug + react_render_graphics + react_render_mounting + yoga) diff --git a/ReactCommon/react/renderer/imagemanager/ImageManager.h b/ReactCommon/react/renderer/imagemanager/ImageManager.h index a6023e8e3d9f39..f76912bf778de7 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageManager.h +++ b/ReactCommon/react/renderer/imagemanager/ImageManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/ImageRequest.h b/ReactCommon/react/renderer/imagemanager/ImageRequest.h index 2c181d3b9b28f5..7d46def8a2c3a1 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageRequest.h +++ b/ReactCommon/react/renderer/imagemanager/ImageRequest.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,7 +29,7 @@ class ImageRequest final { * The default constructor */ ImageRequest( - const ImageSource &imageSource, + ImageSource imageSource, std::shared_ptr telemetry); /* diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponse.cpp b/ReactCommon/react/renderer/imagemanager/ImageResponse.cpp index 361e5fe7f88541..cde6adeb67bdf2 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponse.cpp +++ b/ReactCommon/react/renderer/imagemanager/ImageResponse.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,13 +7,15 @@ #include "ImageResponse.h" +#include + namespace facebook { namespace react { ImageResponse::ImageResponse( - const std::shared_ptr &image, - const std::shared_ptr &metadata) - : image_(image), metadata_(metadata) {} + std::shared_ptr image, + std::shared_ptr metadata) + : image_(std::move(image)), metadata_(std::move(metadata)) {} std::shared_ptr ImageResponse::getImage() const { return image_; diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponse.h b/ReactCommon/react/renderer/imagemanager/ImageResponse.h index 23cc49f65bf680..41a32e0251c46a 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponse.h +++ b/ReactCommon/react/renderer/imagemanager/ImageResponse.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -23,9 +23,7 @@ class ImageResponse final { Failed, }; - ImageResponse( - const std::shared_ptr &image, - const std::shared_ptr &metadata); + ImageResponse(std::shared_ptr image, std::shared_ptr metadata); std::shared_ptr getImage() const; diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponseObserver.h b/ReactCommon/react/renderer/imagemanager/ImageResponseObserver.h index edb94835c7b6cb..5e3bca02cecf1b 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponseObserver.h +++ b/ReactCommon/react/renderer/imagemanager/ImageResponseObserver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp index c75fa5b4c19f79..46dea634105c2a 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp +++ b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.h b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.h index 6b1f8301588197..696d90569aa18e 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.h +++ b/ReactCommon/react/renderer/imagemanager/ImageResponseObserverCoordinator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -59,7 +59,7 @@ class ImageResponseObserverCoordinator { * List of observers. * Mutable: protected by mutex_. */ - mutable better::small_vector observers_; + mutable butter::small_vector observers_; /* * Current status of image loading. diff --git a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp index 40524e5b0ff0f6..3373ce8b7939fd 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp +++ b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h index 1ffaffd0a4aa0c..2169590dbaadad 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h +++ b/ReactCommon/react/renderer/imagemanager/ImageTelemetry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp index 245c3b5e7a783b..b7f1274e351c34 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequest.cpp b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequest.cpp index 9f811bc4d4a3d2..c270971dd27766 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequest.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,13 +7,15 @@ #include "ImageRequest.h" +#include + namespace facebook { namespace react { ImageRequest::ImageRequest( - const ImageSource &imageSource, + ImageSource imageSource, std::shared_ptr telemetry) - : imageSource_(imageSource), telemetry_(telemetry) { + : imageSource_(std::move(imageSource)), telemetry_(std::move(telemetry)) { // Not implemented. } diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageManager.mm b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageManager.mm index 3d37911aaf1a34..9b833ae1a43d94 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageManager.mm +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp index ac01f5b1c1903f..1998d291731502 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/ImageRequest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,9 +11,9 @@ namespace facebook { namespace react { ImageRequest::ImageRequest( - ImageSource const &imageSource, + ImageSource imageSource, std::shared_ptr telemetry) - : imageSource_(imageSource), telemetry_(telemetry) { + : imageSource_(std::move(imageSource)), telemetry_(std::move(telemetry)) { coordinator_ = std::make_shared(); } diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.h b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.h index 0b5814990ce490..88130fe075573f 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.h +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm index 4922b96ef03d3f..1f4b4eabaa2ce2 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -86,7 +86,7 @@ - (ImageRequest)requestImage:(ImageSource)imageSource surfaceId:(SurfaceId)surfa return; } - observerCoordinator->nativeImageResponseProgress(progress / (float)total); + observerCoordinator->nativeImageResponseProgress((float)progress / (float)total); }; RCTImageURLLoaderRequest *loaderRequest = diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManagerProtocol.h b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManagerProtocol.h index a48d24ed313dee..30bfbf391e3596 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManagerProtocol.h +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImageManagerProtocol.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImagePrimitivesConversions.h b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImagePrimitivesConversions.h index ec37101afa1b0c..d72e61c63f0afb 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImagePrimitivesConversions.h +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTImagePrimitivesConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.h b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.h index c48c0b077ef39d..c0ef180bc22d6e 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.h +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.mm b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.mm index 19aeafdc30094b..dd7c9936ac9562 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.mm +++ b/ReactCommon/react/renderer/imagemanager/platform/ios/RCTSyncImageManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -71,7 +71,7 @@ - (ImageRequest)requestImage:(ImageSource)imageSource surfaceId:(SurfaceId)surfa return; } - observerCoordinator->nativeImageResponseProgress(progress / (float)total); + observerCoordinator->nativeImageResponseProgress((float)progress / (float)total); }; RCTImageURLLoaderRequest *loaderRequest = diff --git a/ReactCommon/react/renderer/imagemanager/primitives.h b/ReactCommon/react/renderer/imagemanager/primitives.h index dd95a542e46930..0d9ec9fc25392b 100644 --- a/ReactCommon/react/renderer/imagemanager/primitives.h +++ b/ReactCommon/react/renderer/imagemanager/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/imagemanager/tests/ImageManagerTest.cpp b/ReactCommon/react/renderer/imagemanager/tests/ImageManagerTest.cpp index d9395d5647327b..e3823f879e985c 100644 --- a/ReactCommon/react/renderer/imagemanager/tests/ImageManagerTest.cpp +++ b/ReactCommon/react/renderer/imagemanager/tests/ImageManagerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/leakchecker/Android.mk b/ReactCommon/react/renderer/leakchecker/Android.mk deleted file mode 100644 index 48056bc8dd260d..00000000000000 --- a/ReactCommon/react/renderer/leakchecker/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_leakchecker - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libruntimeexecutor libreact_render_core glog - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,react/renderer/core) -$(call import-module,glog) -$(call import-module,runtimeexecutor) diff --git a/ReactCommon/react/renderer/leakchecker/BUCK b/ReactCommon/react/renderer/leakchecker/BUCK index c0796f177a32c7..a43bcc961c9dcd 100644 --- a/ReactCommon/react/renderer/leakchecker/BUCK +++ b/ReactCommon/react/renderer/leakchecker/BUCK @@ -33,7 +33,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ diff --git a/ReactCommon/react/renderer/leakchecker/CMakeLists.txt b/ReactCommon/react/renderer/leakchecker/CMakeLists.txt new file mode 100644 index 00000000000000..d7657198d942df --- /dev/null +++ b/ReactCommon/react/renderer/leakchecker/CMakeLists.txt @@ -0,0 +1,18 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_leakchecker_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_leakchecker SHARED ${react_render_leakchecker_SRC}) + +target_include_directories(react_render_leakchecker PUBLIC ${REACT_COMMON_DIR}) +target_link_libraries(react_render_leakchecker + glog + react_render_core + runtimeexecutor) diff --git a/ReactCommon/react/renderer/leakchecker/LeakChecker.cpp b/ReactCommon/react/renderer/leakchecker/LeakChecker.cpp index a72e485665f2e1..b0ef65609a1704 100644 --- a/ReactCommon/react/renderer/leakchecker/LeakChecker.cpp +++ b/ReactCommon/react/renderer/leakchecker/LeakChecker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,11 +10,13 @@ #include #include +#include + namespace facebook { namespace react { -LeakChecker::LeakChecker(RuntimeExecutor const &runtimeExecutor) - : runtimeExecutor_(runtimeExecutor) {} +LeakChecker::LeakChecker(RuntimeExecutor runtimeExecutor) + : runtimeExecutor_(std::move(runtimeExecutor)) {} void LeakChecker::uiManagerDidCreateShadowNodeFamily( ShadowNodeFamily::Shared const &shadowNodeFamily) const { diff --git a/ReactCommon/react/renderer/leakchecker/LeakChecker.h b/ReactCommon/react/renderer/leakchecker/LeakChecker.h index a9bb3dd004096c..c88b34a5e1a2d6 100644 --- a/ReactCommon/react/renderer/leakchecker/LeakChecker.h +++ b/ReactCommon/react/renderer/leakchecker/LeakChecker.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,7 +20,7 @@ using GarbageCollectionTrigger = std::function; class LeakChecker final { public: - LeakChecker(RuntimeExecutor const &runtimeExecutor); + LeakChecker(RuntimeExecutor runtimeExecutor); void uiManagerDidCreateShadowNodeFamily( ShadowNodeFamily::Shared const &shadowNodeFamily) const; diff --git a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp index ffb2e161d485f6..a2279a5ed626bf 100644 --- a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp +++ b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.h b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.h index 702eb05152ec72..d8b0e8b777ffbb 100644 --- a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.h +++ b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mapbuffer/Android.mk b/ReactCommon/react/renderer/mapbuffer/Android.mk deleted file mode 100644 index 57c51b2ec4c915..00000000000000 --- a/ReactCommon/react/renderer/mapbuffer/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_mapbuffer - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := glog libglog_init libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbgloginit) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/mapbuffer/BUCK b/ReactCommon/react/renderer/mapbuffer/BUCK index 8e57a23c7575f9..a20926efa5872b 100644 --- a/ReactCommon/react/renderer/mapbuffer/BUCK +++ b/ReactCommon/react/renderer/mapbuffer/BUCK @@ -32,7 +32,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = ANDROID, preprocessor_flags = [ @@ -44,7 +47,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", react_native_xplat_target("react/debug:debug"), ], diff --git a/ReactCommon/react/renderer/mapbuffer/CMakeLists.txt b/ReactCommon/react/renderer/mapbuffer/CMakeLists.txt new file mode 100644 index 00000000000000..fe3648152f51bd --- /dev/null +++ b/ReactCommon/react/renderer/mapbuffer/CMakeLists.txt @@ -0,0 +1,15 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_mapbuffer_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_mapbuffer SHARED ${react_render_mapbuffer_SRC}) + +target_include_directories(react_render_mapbuffer PUBLIC ${REACT_COMMON_DIR}) +target_link_libraries(react_render_mapbuffer glog glog_init react_debug) diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp index 80e76dfb4f2e03..94d8c87bd323a4 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,43 +12,54 @@ using namespace facebook::react; namespace facebook { namespace react { -// TODO T83483191: Extend MapBuffer C++ implementation to support basic random -// access -MapBuffer::MapBuffer(uint8_t *const data, int32_t dataSize) { - react_native_assert( - (data != nullptr) && "Error trying to build an invalid MapBuffer"); - - // Should we move the memory here or document it? - data_ = data; +static inline int32_t bucketOffset(int32_t index) { + return sizeof(MapBuffer::Header) + sizeof(MapBuffer::Bucket) * index; +} - count_ = 0; - memcpy( - reinterpret_cast(&count_), - reinterpret_cast(data_ + HEADER_COUNT_OFFSET), - UINT16_SIZE); +static inline int32_t valueOffset(int32_t bucketIndex) { + return bucketOffset(bucketIndex) + offsetof(MapBuffer::Bucket, data); +} - // TODO T83483191: extract memcpy calls into an inline function to simplify - // the code - dataSize_ = 0; - memcpy( - reinterpret_cast(&dataSize_), - reinterpret_cast(data_ + HEADER_BUFFER_SIZE_OFFSET), - INT_SIZE); +// TODO T83483191: Extend MapBuffer C++ implementation to support basic random +// access +MapBuffer::MapBuffer(std::vector data) : bytes_(std::move(data)) { + auto header = reinterpret_cast
(bytes_.data()); + count_ = header->count; - if (dataSize != dataSize_) { - LOG(ERROR) << "Error: Data size does not match, expected " << dataSize - << " found: " << dataSize_; + if (header->bufferSize != bytes_.size()) { + LOG(ERROR) << "Error: Data size does not match, expected " + << header->bufferSize << " found: " << bytes_.size(); abort(); } } +int32_t MapBuffer::getKeyBucket(Key key) const { + int32_t lo = 0; + int32_t hi = count_ - 1; + while (lo <= hi) { + int32_t mid = (lo + hi) >> 1; + + Key midVal = + *reinterpret_cast(bytes_.data() + bucketOffset(mid)); + + if (midVal < key) { + lo = mid + 1; + } else if (midVal > key) { + hi = mid - 1; + } else { + return mid; + } + } + + return -1; +} + int32_t MapBuffer::getInt(Key key) const { - int32_t value = 0; - memcpy( - reinterpret_cast(&value), - reinterpret_cast(data_ + getValueOffset(key)), - INT_SIZE); - return value; + auto bucketIndex = getKeyBucket(key); + react_native_assert(bucketIndex != -1 && "Key not found in MapBuffer"); + + return *reinterpret_cast( + bytes_.data() + valueOffset(bucketIndex)); } bool MapBuffer::getBool(Key key) const { @@ -56,42 +67,30 @@ bool MapBuffer::getBool(Key key) const { } double MapBuffer::getDouble(Key key) const { - // TODO T83483191: extract this code into a "template method" and reuse it for - // other types - double value = 0; - memcpy( - reinterpret_cast(&value), - reinterpret_cast(data_ + getValueOffset(key)), - DOUBLE_SIZE); - return value; + auto bucketIndex = getKeyBucket(key); + react_native_assert(bucketIndex != -1 && "Key not found in MapBuffer"); + + return *reinterpret_cast( + bytes_.data() + valueOffset(bucketIndex)); } int32_t MapBuffer::getDynamicDataOffset() const { - // The begininig of dynamic data can be calculated as the offset of the next + // The start of dynamic data can be calculated as the offset of the next // key in the map - return getKeyOffset(count_); + return bucketOffset(count_); } std::string MapBuffer::getString(Key key) const { // TODO T83483191:Add checks to verify that offsets are under the boundaries // of the map buffer int32_t dynamicDataOffset = getDynamicDataOffset(); - int32_t stringLength = 0; int32_t offset = getInt(key); - memcpy( - reinterpret_cast(&stringLength), - reinterpret_cast(data_ + dynamicDataOffset + offset), - INT_SIZE); - - char *value = new char[stringLength]; + int32_t stringLength = *reinterpret_cast( + bytes_.data() + dynamicDataOffset + offset); + uint8_t const *stringPtr = + bytes_.data() + dynamicDataOffset + offset + sizeof(int); - memcpy( - reinterpret_cast(value), - reinterpret_cast( - data_ + dynamicDataOffset + offset + INT_SIZE), - stringLength); - - return std::string(value, 0, stringLength); + return std::string(stringPtr, stringPtr + stringLength); } MapBuffer MapBuffer::getMapBuffer(Key key) const { @@ -99,50 +98,30 @@ MapBuffer MapBuffer::getMapBuffer(Key key) const { // of the map buffer int32_t dynamicDataOffset = getDynamicDataOffset(); - int32_t mapBufferLength = 0; int32_t offset = getInt(key); - memcpy( - reinterpret_cast(&mapBufferLength), - reinterpret_cast(data_ + dynamicDataOffset + offset), - INT_SIZE); + int32_t mapBufferLength = *reinterpret_cast( + bytes_.data() + dynamicDataOffset + offset); - uint8_t *value = new Byte[mapBufferLength]; + std::vector value(mapBufferLength); memcpy( - reinterpret_cast(value), - reinterpret_cast( - data_ + dynamicDataOffset + offset + INT_SIZE), + value.data(), + bytes_.data() + dynamicDataOffset + offset + sizeof(int32_t), mapBufferLength); - return MapBuffer(value, mapBufferLength); + return MapBuffer(std::move(value)); } -bool MapBuffer::isNull(Key key) const { - return getInt(key) == NULL_VALUE; +size_t MapBuffer::size() const { + return bytes_.size(); } -int32_t MapBuffer::getBufferSize() const { - return dataSize_; -} - -void MapBuffer::copy(uint8_t *output) const { - memcpy(output, data_, dataSize_); -} - -uint16_t MapBuffer::getCount() const { - uint16_t size = 0; - - memcpy( - reinterpret_cast(&size), - reinterpret_cast(data_ + HEADER_COUNT_OFFSET), - - UINT16_SIZE); - - return size; +uint8_t const *MapBuffer::data() const { + return bytes_.data(); } -MapBuffer::~MapBuffer() { - delete[] data_; +uint16_t MapBuffer::count() const { + return count_; } } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.h b/ReactCommon/react/renderer/mapbuffer/MapBuffer.h index b3f0c3051f176f..dcfa25ec703a26 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.h +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,67 +8,143 @@ #pragma once #include -#include -#include +#include + +#include +#include #include +#include +#include namespace facebook { namespace react { +class JReadableMapBuffer; + +// clang-format off + /** - * MapBuffer is an optimized map format for transferring data like props between - * C++ and other platforms The implementation of this map is optimized to: + * MapBuffer is an optimized sparse array format for transferring props-like + * objects between C++ and other VMs. The implementation of this map is optimized to: * - be compact to optimize space when sparse (sparse is the common case). * - be accessible through JNI with zero/minimal copying via ByteBuffer. - * - be Have excellent C++ single-write and many-read performance by maximizing + * - have excellent C++ single-write and many-read performance by maximizing * CPU cache performance through compactness, data locality, and fixed offsets * where possible. * - be optimized for iteration and intersection against other maps, but with * reasonably good random access as well. - * - Work recursively for nested maps/arrays. - * - Supports dynamic types that map to JSON. - * - Don't require mutability - single-write on creation. + * - work recursively for nested maps/arrays. + * - support dynamic types that map to JSON. + * - don't require mutability/copy - single-write on creation and move semantics. * - have minimal APK size and build time impact. + * + * MapBuffer data is stored in a continuous chunk of memory (bytes_ field below) with the following layout: + * + * ┌─────────────────────Header──────────────────────┐ + * │ 10 bytes │ + * ├─Alignment─┬─Item count─┬──────Buffer size───────┤ + * │ 2 bytes │ 2 bytes │ 4 bytes │ + * └───────────┴────────────┴────────────────────────┘ + * ┌────────────────────────────────────────────────────────────────────────────────────────┐ + * │ Buckets (one per item in the map) │ + * │ │ + * ├───────────────────────────Bucket───────────────────────────┬───Bucket────┬─────────────┤ + * │ 12 bytes │ 12 bytes │ │ + * ├───Key───┬──Type───┬──────Value (primitive or offset)───────┤ ... │ ... │ + * │ 2 bytes │ 2 bytes │ 8 bytes │ │ │ + * └─────────┴─────────┴────────────────────────────────────────┴─────────────┴─────────────┘ + * ┌────────────────────────────────────────────────────────────────────────────────────────┐ + * │ Dynamic data │ + * │ │ + * │ Free-form data for complex objects (e.g. strings or nested MapBuffers). │ + * │ When dynamic data is serialized with some object, bucket value contains an offset of │ + * │ associated byte in the array. The format of the data is not restricted, but common │ + * │ practice is to use [length | bytes]. │ + * └────────────────────────────────────────────────────────────────────────────────────────┘ */ + +// clang-format on + class MapBuffer { - private: - // Buffer and its size - const uint8_t *data_ = nullptr; + public: + using Key = uint16_t; - // amount of bytes in the MapBuffer - int32_t dataSize_ = 0; + // The first value in the buffer, used to check correct encoding/endianness on + // JVM side. + constexpr static uint16_t HEADER_ALIGNMENT = 0xFE; - // amount of items in the MapBuffer - uint16_t count_ = 0; + struct Header { + uint16_t alignment = HEADER_ALIGNMENT; // alignment of serialization + uint16_t count; // amount of items in the map + uint32_t bufferSize; // Amount of bytes used to store the map in memory + }; - // returns the relative offset of the first byte of dynamic data - int32_t getDynamicDataOffset() const; +#pragma pack(push, 1) + struct Bucket { + Key key; + uint16_t type; + uint64_t data; - public: - MapBuffer(uint8_t *const data, int32_t dataSize); + Bucket(Key key, uint16_t type, uint64_t data) + : key(key), type(type), data(data) {} + }; +#pragma pack(pop) - ~MapBuffer(); + static_assert(sizeof(Header) == 8, "MapBuffer header size is incorrect."); + static_assert(sizeof(Bucket) == 12, "MapBuffer bucket size is incorrect."); - int32_t getInt(Key key) const; + /** + * Data types available for serialization in MapBuffer + * Keep in sync with `DataType` enum in `JReadableMapBuffer.java`, which + * expects the same values after reading them through JNI. + */ + enum DataType : uint16_t { + Boolean = 0, + Int = 1, + Double = 2, + String = 3, + Map = 4, + }; - bool getBool(Key key) const; + explicit MapBuffer(std::vector data); - double getDouble(Key key) const; + MapBuffer(MapBuffer const &buffer) = delete; - std::string getString(Key key) const; + MapBuffer &operator=(MapBuffer other) = delete; + + MapBuffer(MapBuffer &&buffer) = default; + + int32_t getInt(MapBuffer::Key key) const; + + bool getBool(MapBuffer::Key key) const; + + double getDouble(MapBuffer::Key key) const; + + std::string getString(MapBuffer::Key key) const; // TODO T83483191: review this declaration - MapBuffer getMapBuffer(Key key) const; + MapBuffer getMapBuffer(MapBuffer::Key key) const; + + size_t size() const; - int32_t getBufferSize() const; + uint8_t const *data() const; - // TODO T83483191: review parameters of copy method - void copy(uint8_t *output) const; + uint16_t count() const; + + private: + // Buffer and its size + std::vector const bytes_; + + // amount of items in the MapBuffer + uint16_t count_ = 0; + + // returns the relative offset of the first byte of dynamic data + int32_t getDynamicDataOffset() const; - bool isNull(Key key) const; + int32_t getKeyBucket(MapBuffer::Key key) const; - uint16_t getCount() const; + friend JReadableMapBuffer; }; } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp b/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp index 4ff2f7b5c58807..93883437012bc3 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp +++ b/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp @@ -1,225 +1,148 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #include "MapBufferBuilder.h" +#include using namespace facebook::react; namespace facebook { namespace react { -// TODO T83483191: Add asserts to check overflowing on additions -MapBufferBuilder::MapBufferBuilder() - : MapBufferBuilder::MapBufferBuilder(INITIAL_KEY_VALUE_SIZE) {} +constexpr uint32_t INT_SIZE = sizeof(uint32_t); +constexpr uint32_t DOUBLE_SIZE = sizeof(double); +constexpr uint32_t MAX_BUCKET_VALUE_SIZE = sizeof(uint64_t); MapBuffer MapBufferBuilder::EMPTY() { - static auto emptyMap = MapBufferBuilder().build(); - return emptyMap; + return MapBufferBuilder(0).build(); } -MapBufferBuilder::MapBufferBuilder(uint16_t initialSize) { - keyValuesSize_ = initialSize; - keyValues_ = new Byte[keyValuesSize_]; - // First Key should be written right after the header. - keyValuesOffset_ = HEADER_SIZE; - - dynamicDataSize_ = 0; - dynamicDataValues_ = nullptr; - dynamicDataOffset_ = 0; -} - -void MapBufferBuilder::ensureKeyValueSpace() { - int32_t oldKeyValuesSize = keyValuesSize_; - react_native_assert( - (keyValuesSize_ < std::numeric_limits::max() / 2) && - "Error trying to assign a value beyond the capacity of uint16_t: "); - keyValuesSize_ *= 2; - uint8_t *newKeyValues = new Byte[keyValuesSize_]; - uint8_t *oldKeyValues = keyValues_; - memcpy(newKeyValues, keyValues_, oldKeyValuesSize); - keyValues_ = newKeyValues; - delete[] oldKeyValues; +MapBufferBuilder::MapBufferBuilder(uint32_t initialSize) { + buckets_.reserve(initialSize); + header_.count = 0; + header_.bufferSize = 0; } void MapBufferBuilder::storeKeyValue( - Key key, - uint8_t *value, - int32_t valueSize) { - if (key < minKeyToStore_) { - LOG(ERROR) << "Error: key out of order - key: " << key; - abort(); - } - if (valueSize > MAX_VALUE_SIZE) { + MapBuffer::Key key, + MapBuffer::DataType type, + uint8_t const *value, + uint32_t valueSize) { + if (valueSize > MAX_BUCKET_VALUE_SIZE) { LOG(ERROR) << "Error: size of value must be <= MAX_VALUE_SIZE. ValueSize: " << valueSize; abort(); } - // TODO T83483191: header.count points to the next index - // TODO T83483191: add test to verify storage of sparse keys - int32_t keyOffset = getKeyOffset(_header.count); - int32_t valueOffset = keyOffset + KEY_SIZE; + uint64_t data = 0; + auto *dataPtr = reinterpret_cast(&data); + memcpy(dataPtr, value, valueSize); - int32_t nextKeyValueOffset = keyOffset + BUCKET_SIZE; - if (nextKeyValueOffset >= keyValuesSize_) { - ensureKeyValueSpace(); - } - - memcpy(keyValues_ + keyOffset, &key, KEY_SIZE); - memcpy(keyValues_ + valueOffset, value, valueSize); + buckets_.emplace_back(key, static_cast(type), data); - _header.count++; - - minKeyToStore_ = key + 1; - // Move keyValuesOffset_ to the next available [key, value] position - keyValuesOffset_ = std::max(nextKeyValueOffset, keyValuesOffset_); -} + header_.count++; -void MapBufferBuilder::putBool(Key key, bool value) { - putInt(key, (int)value); -} - -void MapBufferBuilder::putDouble(Key key, double value) { - uint8_t *bytePointer = reinterpret_cast(&value); - storeKeyValue(key, bytePointer, DOUBLE_SIZE); + if (lastKey_ > key) { + needsSort_ = true; + } + lastKey_ = key; } -void MapBufferBuilder::putNull(Key key) { - putInt(key, NULL_VALUE); +void MapBufferBuilder::putBool(MapBuffer::Key key, bool value) { + int intValue = (int)value; + storeKeyValue( + key, + MapBuffer::DataType::Boolean, + reinterpret_cast(&intValue), + INT_SIZE); } -void MapBufferBuilder::putInt(Key key, int32_t value) { - uint8_t *bytePointer = reinterpret_cast(&(value)); - storeKeyValue(key, bytePointer, INT_SIZE); +void MapBufferBuilder::putDouble(MapBuffer::Key key, double value) { + storeKeyValue( + key, + MapBuffer::DataType::Double, + reinterpret_cast(&value), + DOUBLE_SIZE); } -void MapBufferBuilder::ensureDynamicDataSpace(int32_t size) { - if (dynamicDataValues_ == nullptr) { - dynamicDataSize_ = size; - dynamicDataValues_ = new Byte[dynamicDataSize_]; - dynamicDataOffset_ = 0; - return; - } - - if (dynamicDataOffset_ + size >= dynamicDataSize_) { - int32_t oldDynamicDataSize = dynamicDataSize_; - react_native_assert( - (dynamicDataSize_ < std::numeric_limits::max() / 2) && - "Error: trying to assign a value beyond the capacity of int"); - dynamicDataSize_ *= dynamicDataSize_; - - react_native_assert( - (dynamicDataSize_ < std::numeric_limits::max() - size) && - "Error: trying to assign a value beyond the capacity of int"); - - // sum size to ensure that the size always fit into newDynamicDataValues - dynamicDataSize_ += size; - uint8_t *newDynamicDataValues = new Byte[dynamicDataSize_]; - uint8_t *oldDynamicDataValues = dynamicDataValues_; - memcpy(newDynamicDataValues, dynamicDataValues_, oldDynamicDataSize); - dynamicDataValues_ = newDynamicDataValues; - delete[] oldDynamicDataValues; - } +void MapBufferBuilder::putInt(MapBuffer::Key key, int32_t value) { + storeKeyValue( + key, + MapBuffer::DataType::Int, + reinterpret_cast(&value), + INT_SIZE); } -void MapBufferBuilder::putString(Key key, std::string value) { - int32_t strLength = static_cast(value.length()); - const char *cstring = getCstring(&value); +void MapBufferBuilder::putString(MapBuffer::Key key, std::string const &value) { + auto strSize = value.size(); + const char *strData = value.data(); - // format [lenght of string (int)] + [Array of Characters in the string] - int32_t sizeOfLength = INT_SIZE; - // TODO T83483191: review if map.getBufferSize() should be an int32_t or long - // instead of an int16 (because strings can be longer than int16); - - int32_t sizeOfDynamicData = sizeOfLength + strLength; - ensureDynamicDataSpace(sizeOfDynamicData); - memcpy(dynamicDataValues_ + dynamicDataOffset_, &strLength, sizeOfLength); - memcpy( - dynamicDataValues_ + dynamicDataOffset_ + sizeOfLength, - cstring, - strLength); + // format [length of string (int)] + [Array of Characters in the string] + auto offset = dynamicData_.size(); + dynamicData_.resize(offset + INT_SIZE + strSize, 0); + memcpy(dynamicData_.data() + offset, &strSize, INT_SIZE); + memcpy(dynamicData_.data() + offset + INT_SIZE, strData, strSize); // Store Key and pointer to the string - putInt(key, dynamicDataOffset_); - - dynamicDataOffset_ += sizeOfDynamicData; + storeKeyValue( + key, + MapBuffer::DataType::String, + reinterpret_cast(&offset), + INT_SIZE); } -void MapBufferBuilder::putMapBuffer(Key key, MapBuffer &map) { - int32_t mapBufferSize = map.getBufferSize(); - - // format [lenght of buffer (int)] + [bytes of MapBuffer] - int32_t sizeOfDynamicData = mapBufferSize + INT_SIZE; +void MapBufferBuilder::putMapBuffer(MapBuffer::Key key, MapBuffer const &map) { + auto mapBufferSize = map.size(); - // format [Array of bytes of the mapBuffer] - ensureDynamicDataSpace(sizeOfDynamicData); + auto offset = dynamicData_.size(); - memcpy(dynamicDataValues_ + dynamicDataOffset_, &mapBufferSize, INT_SIZE); - // Copy the content of the map into dynamicDataValues_ - map.copy(dynamicDataValues_ + dynamicDataOffset_ + INT_SIZE); + // format [length of buffer (int)] + [bytes of MapBuffer] + dynamicData_.resize(offset + INT_SIZE + mapBufferSize, 0); + memcpy(dynamicData_.data() + offset, &mapBufferSize, INT_SIZE); + // Copy the content of the map into dynamicData_ + memcpy(dynamicData_.data() + offset + INT_SIZE, map.data(), mapBufferSize); // Store Key and pointer to the string - putInt(key, dynamicDataOffset_); + storeKeyValue( + key, + MapBuffer::DataType::Map, + reinterpret_cast(&offset), + INT_SIZE); +} - dynamicDataOffset_ += sizeOfDynamicData; +static inline bool compareBuckets( + MapBuffer::Bucket const &a, + MapBuffer::Bucket const &b) { + return a.key < b.key; } MapBuffer MapBufferBuilder::build() { - react_native_assert( - (keyValues_ != nullptr) && - "Error when building mapbuffer with invalid datastructures."); - // Create buffer: [header] + [key, values] + [dynamic data] - int32_t bufferSize = keyValuesOffset_ + dynamicDataOffset_; - - _header.bufferSize = bufferSize; - - // Copy header at the beginning of "keyValues_" - memcpy(keyValues_, &_header, HEADER_SIZE); - - uint8_t *buffer = new Byte[bufferSize]; - - memcpy(buffer, keyValues_, keyValuesOffset_); + auto bucketSize = buckets_.size() * sizeof(MapBuffer::Bucket); + auto headerSize = sizeof(MapBuffer::Header); + auto bufferSize = headerSize + bucketSize + dynamicData_.size(); - if (dynamicDataValues_ != nullptr) { - memcpy(buffer + keyValuesOffset_, dynamicDataValues_, dynamicDataOffset_); - } - - // TODO T83483191: should we use std::move here? - auto map = MapBuffer(buffer, bufferSize); + header_.bufferSize = static_cast(bufferSize); - // TODO T83483191: we should invalidate the class once the build() method is - // called. - - if (keyValues_ != nullptr) { - delete[] keyValues_; + if (needsSort_) { + std::sort(buckets_.begin(), buckets_.end(), compareBuckets); } - keyValues_ = nullptr; - keyValuesSize_ = 0; - keyValuesOffset_ = 0; - if (dynamicDataValues_ != nullptr) { - delete[] dynamicDataValues_; - dynamicDataValues_ = nullptr; - } - dynamicDataSize_ = 0; - dynamicDataOffset_ = 0; - _header = {ALIGNMENT, 0, 0}; + // TODO(T83483191): add pass to check for duplicates - return map; -} + std::vector buffer(bufferSize); + memcpy(buffer.data(), &header_, headerSize); + memcpy(buffer.data() + headerSize, buckets_.data(), bucketSize); + memcpy( + buffer.data() + headerSize + bucketSize, + dynamicData_.data(), + dynamicData_.size()); -MapBufferBuilder::~MapBufferBuilder() { - if (keyValues_ != nullptr) { - delete[] keyValues_; - } - if (dynamicDataValues_ != nullptr) { - delete[] dynamicDataValues_; - } + return MapBuffer(std::move(buffer)); } } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h b/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h index d46dd8fbea0a5f..aa8ae879407487 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h +++ b/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,85 +9,50 @@ #include #include -#include -#include namespace facebook { namespace react { -// Default initial size for _keyValues array -// 108 = 10 entries = 10*10 + 8 sizeof(header) -constexpr uint16_t INITIAL_KEY_VALUE_SIZE = 108; - -// Default initial size for _dynamicDataValues array -constexpr int32_t INITIAL_DYNAMIC_DATA_SIZE = 200; +// Default reserved size for buckets_ vector +constexpr uint32_t INITIAL_BUCKETS_SIZE = 10; /** * MapBufferBuilder is a builder class for MapBuffer */ class MapBufferBuilder { - private: - Header _header = {ALIGNMENT, 0, 0}; - - void ensureKeyValueSpace(); - - void ensureDynamicDataSpace(int32_t size); - - void storeKeyValue(Key key, uint8_t *value, int32_t valueSize); - - // Array of [key,value] map entries: - // - Key is represented in 2 bytes - // - Value is stored into 8 bytes. The 8 bytes of the value will contain the - // actual value for the key or a pointer to the actual value (based on the - // type) - uint8_t *keyValues_ = nullptr; - - // Amount of bytes allocated on _keyValues - uint16_t keyValuesSize_ = 0; - - // Relative offset on the _keyValues array. - // This represents the first byte that can be written in _keyValues array - int32_t keyValuesOffset_ = 0; - - // This array contains data for dynamic values in the MapBuffer. - // A dynamic value is a String or another MapBuffer. - uint8_t *dynamicDataValues_ = nullptr; - - // Amount of bytes allocated on _dynamicDataValues - int32_t dynamicDataSize_ = 0; + public: + MapBufferBuilder(uint32_t initialSize = INITIAL_BUCKETS_SIZE); - // Relative offset on the _dynamicDataValues array. - // This represents the first byte that can be written in _dynamicDataValues - // array - int32_t dynamicDataOffset_ = 0; + static MapBuffer EMPTY(); - // Minimmum key to store in the MapBuffer (this is used to guarantee - // consistency) - uint16_t minKeyToStore_ = 0; + void putInt(MapBuffer::Key key, int32_t value); - public: - MapBufferBuilder(); + void putBool(MapBuffer::Key key, bool value); - MapBufferBuilder(uint16_t initialSize); + void putDouble(MapBuffer::Key key, double value); - ~MapBufferBuilder(); + void putString(MapBuffer::Key key, std::string const &value); - static MapBuffer EMPTY(); + void putMapBuffer(MapBuffer::Key key, MapBuffer const &map); - void putInt(Key key, int32_t value); + MapBuffer build(); - void putBool(Key key, bool value); + private: + MapBuffer::Header header_; - void putDouble(Key key, double value); + std::vector buckets_{}; - void putNull(Key key); + std::vector dynamicData_{}; - void putString(Key key, std::string value); + uint16_t lastKey_{0}; - void putMapBuffer(Key key, MapBuffer &map); + bool needsSort_{false}; - // TODO T83483191: This should return MapBuffer! - MapBuffer build(); + void storeKeyValue( + MapBuffer::Key key, + MapBuffer::DataType type, + uint8_t const *value, + uint32_t valueSize); }; } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/primitives.h b/ReactCommon/react/renderer/mapbuffer/primitives.h deleted file mode 100644 index 456e0b9e12d1d1..00000000000000 --- a/ReactCommon/react/renderer/mapbuffer/primitives.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -// TODO T83483191: Enable CHECK_CONSISTENCY only in debug mode or test -// environments (or just in demand) #define CHECK_CONSISTENCY 1 - -constexpr static int32_t NULL_VALUE = 0; - -// Value used to verify if the data is serialized with LittleEndian order -constexpr static uint16_t ALIGNMENT = 0xFE; - -using Key = uint16_t; - -using Byte = uint8_t; - -namespace facebook { -namespace react { - -struct Header { - uint16_t alignment; // alignment of serialization - uint16_t count; // amount of items in the map - int32_t bufferSize; // Amount of bytes used to store the map in memory -}; - -constexpr static int32_t KEY_SIZE = sizeof(Key); -constexpr static int32_t HEADER_SIZE = sizeof(Header); -constexpr static int32_t INT_SIZE = sizeof(int32_t); -constexpr static int32_t DOUBLE_SIZE = sizeof(double); -constexpr static int32_t UINT8_SIZE = sizeof(uint8_t); -constexpr static int32_t UINT16_SIZE = sizeof(uint16_t); -constexpr static int32_t UINT64_SIZE = sizeof(uint64_t); -constexpr static int32_t HEADER_ALIGNMENT_OFFSET = 0; -constexpr static int32_t HEADER_COUNT_OFFSET = UINT16_SIZE; -constexpr static int32_t HEADER_BUFFER_SIZE_OFFSET = UINT16_SIZE * 2; - -constexpr static int32_t MAX_VALUE_SIZE = UINT64_SIZE; - -// 10 bytes : 2 key + 8 value -constexpr static int32_t BUCKET_SIZE = KEY_SIZE + UINT64_SIZE; - -/** - * Returns the offset of the key received by parameter. - */ -inline int32_t getKeyOffset(Key key) { - return HEADER_SIZE + BUCKET_SIZE * key; -} - -/** - * Returns the offset of the value associated to the key received by parameter. - */ -inline int32_t getValueOffset(Key key) { - return getKeyOffset(key) + KEY_SIZE; -} - -static inline const char *getCstring(const std::string *str) { - return str ? str->c_str() : ""; -} - -inline void -checkKeyConsistency(const Header &header, const uint8_t *data, Key key) { -#ifdef CHECK_CONSISTENCY - if (key >= header.count) { - LOG(ERROR) << "Error: Key is higher than size of Map - key '" << key - << "' - size: '" << header.count << "'"; - assert(false && "Error while reading key"); - } - - Key storedKey = 0; - memcpy( - reinterpret_cast(&storedKey), - reinterpret_cast(data + getKeyOffset(key)), - KEY_SIZE); - - if (storedKey != key) { - LOG(ERROR) << "Error while reading key, expecting '" << key << "' found: '" - << storedKey << "'"; - assert(false && "Error while reading key"); - } -#endif -} - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp index 9dd36eeb6df997..f0d5c737541a76 100644 --- a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +++ b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,7 +21,7 @@ TEST(MapBufferTest, testSimpleIntMap) { auto map = builder.build(); - EXPECT_EQ(map.getCount(), 2); + EXPECT_EQ(map.count(), 2); EXPECT_EQ(map.getInt(0), 1234); EXPECT_EQ(map.getInt(1), 4321); } @@ -38,7 +38,7 @@ TEST(MapBufferTest, testMapBufferExtension) { auto map = buffer.build(); - EXPECT_EQ(map.getCount(), 4); + EXPECT_EQ(map.count(), 4); EXPECT_EQ(map.getInt(0), 1234); EXPECT_EQ(map.getInt(1), 4321); @@ -54,28 +54,11 @@ TEST(MapBufferTest, testBoolEntries) { auto map = buffer.build(); - EXPECT_EQ(map.getCount(), 2); + EXPECT_EQ(map.count(), 2); EXPECT_EQ(map.getBool(0), true); EXPECT_EQ(map.getBool(1), false); } -TEST(MapBufferTest, testNullEntries) { - auto buffer = MapBufferBuilder(); - - buffer.putNull(0); - buffer.putInt(1, 1234); - - auto map = buffer.build(); - - EXPECT_EQ(map.getCount(), 2); - EXPECT_EQ(map.isNull(0), true); - EXPECT_EQ(map.isNull(1), false); - // TODO T83483191: serialize null values to be distinguishable from '0' - // values - // EXPECT_EQ(map.isNull(1), false); - // EXPECT_EQ(map.getBool(1), false); -} - TEST(MapBufferTest, testDoubleEntries) { auto buffer = MapBufferBuilder(); @@ -84,7 +67,7 @@ TEST(MapBufferTest, testDoubleEntries) { auto map = buffer.build(); - EXPECT_EQ(map.getCount(), 2); + EXPECT_EQ(map.count(), 2); EXPECT_EQ(map.getDouble(0), 123.4); EXPECT_EQ(map.getDouble(1), 432.1); @@ -108,6 +91,18 @@ TEST(MapBufferTest, testUTFStringEntry) { EXPECT_EQ(map.getString(0), "Let's count: 的, 一, 是"); } +TEST(MapBufferTest, testEmojiStringEntry) { + auto builder = MapBufferBuilder(); + + builder.putString( + 0, "Let's count: 1️⃣, 2️⃣, 3️⃣, 🤦🏿‍♀️"); + auto map = builder.build(); + + EXPECT_EQ( + map.getString(0), + "Let's count: 1️⃣, 2️⃣, 3️⃣, 🤦🏿‍♀️"); +} + TEST(MapBufferTest, testUTFStringEntries) { auto builder = MapBufferBuilder(); @@ -122,12 +117,12 @@ TEST(MapBufferTest, testUTFStringEntries) { TEST(MapBufferTest, testEmptyMap) { auto builder = MapBufferBuilder(); auto map = builder.build(); - EXPECT_EQ(map.getCount(), 0); + EXPECT_EQ(map.count(), 0); } TEST(MapBufferTest, testEmptyMapConstant) { auto map = MapBufferBuilder::EMPTY(); - EXPECT_EQ(map.getCount(), 0); + EXPECT_EQ(map.count(), 0); } TEST(MapBufferTest, testMapEntries) { @@ -136,7 +131,7 @@ TEST(MapBufferTest, testMapEntries) { builder.putInt(1, 1234); auto map = builder.build(); - EXPECT_EQ(map.getCount(), 2); + EXPECT_EQ(map.count(), 2); EXPECT_EQ(map.getString(0), "This is a test"); EXPECT_EQ(map.getInt(1), 1234); @@ -145,12 +140,27 @@ TEST(MapBufferTest, testMapEntries) { builder2.putMapBuffer(1, map); auto map2 = builder2.build(); - EXPECT_EQ(map2.getCount(), 2); + EXPECT_EQ(map2.count(), 2); EXPECT_EQ(map2.getInt(0), 4321); MapBuffer readMap2 = map2.getMapBuffer(1); - EXPECT_EQ(readMap2.getCount(), 2); + EXPECT_EQ(readMap2.count(), 2); EXPECT_EQ(readMap2.getString(0), "This is a test"); EXPECT_EQ(readMap2.getInt(1), 1234); } + +TEST(MapBufferTest, testMapRandomAccess) { + auto builder = MapBufferBuilder(); + builder.putInt(1234, 4321); + builder.putString(0, "This is a test"); + builder.putDouble(8, 908.1); + builder.putString(65535, "Let's count: 的, 一, 是"); + auto map = builder.build(); + + EXPECT_EQ(map.count(), 4); + EXPECT_EQ(map.getString(0), "This is a test"); + EXPECT_EQ(map.getDouble(8), 908.1); + EXPECT_EQ(map.getInt(1234), 4321); + EXPECT_EQ(map.getString(65535), "Let's count: 的, 一, 是"); +} diff --git a/ReactCommon/react/renderer/mounting/Android.mk b/ReactCommon/react/renderer/mounting/Android.mk deleted file mode 100644 index efd902e42cad9e..00000000000000 --- a/ReactCommon/react/renderer/mounting/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_mounting - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libjsi libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug libreact_render_graphics libreact_render_telemetry - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,better) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/telemetry) diff --git a/ReactCommon/react/renderer/mounting/BUCK b/ReactCommon/react/renderer/mounting/BUCK index 20a434f8687e75..67e926a93d2ebb 100644 --- a/ReactCommon/react/renderer/mounting/BUCK +++ b/ReactCommon/react/renderer/mounting/BUCK @@ -35,7 +35,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -47,10 +50,10 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/renderer/components/root:root"), react_native_xplat_target("react/renderer/components/view:view"), diff --git a/ReactCommon/react/renderer/mounting/CMakeLists.txt b/ReactCommon/react/renderer/mounting/CMakeLists.txt new file mode 100644 index 00000000000000..58b3124362400f --- /dev/null +++ b/ReactCommon/react/renderer/mounting/CMakeLists.txt @@ -0,0 +1,31 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_mounting_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_mounting SHARED ${react_render_mounting_SRC}) + +target_include_directories(react_render_mounting PRIVATE .) +target_include_directories(react_render_mounting PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_mounting + butter + folly_runtime + glog + glog_init + jsi + react_debug + react_render_core + react_render_debug + react_render_graphics + react_render_telemetry + react_utils + rrc_root + rrc_view + yoga) diff --git a/ReactCommon/react/renderer/mounting/Differentiator.cpp b/ReactCommon/react/renderer/mounting/Differentiator.cpp index a37e90758fcb1a..41d4de1e8e5368 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.cpp +++ b/ReactCommon/react/renderer/mounting/Differentiator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ #include "Differentiator.h" -#include -#include +#include +#include #include #include #include @@ -168,7 +168,7 @@ class TinyMap final { erasedAtFront_ = 0; } - better::small_vector vector_; + butter::small_vector vector_; size_t numErased_{0}; size_t erasedAtFront_{0}; }; @@ -341,7 +341,8 @@ static void calculateShadowViewMutationsV2( ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, ShadowViewNodePair::NonOwningList &&oldChildPairs, - ShadowViewNodePair::NonOwningList &&newChildPairs); + ShadowViewNodePair::NonOwningList &&newChildPairs, + bool isRecursionRedundant = false); struct OrderedMutationInstructionContainer { ShadowViewMutation::List createMutations{}; @@ -895,8 +896,8 @@ static void calculateShadowViewMutationsFlattener( // Construct unvisited nodes map auto unvisitedRecursiveChildPairs = TinyMap{}; - for (size_t i = 0; i < flattenedNodes.size(); i++) { - auto &newChild = *flattenedNodes[i]; + for (auto &flattenedNode : flattenedNodes) { + auto &newChild = *flattenedNode; auto unvisitedOtherNodesIt = unvisitedOtherNodes.find(newChild.shadowView.tag); @@ -959,14 +960,12 @@ static void calculateShadowViewMutationsFlattener( // If old nodes were not visited, we know that we can delete them // now. They will be removed from the hierarchy by the outermost // loop of this function. - for (auto unvisitedOldChildPairIt = - unvisitedRecursiveChildPairs.begin(); - unvisitedOldChildPairIt != unvisitedRecursiveChildPairs.end(); - unvisitedOldChildPairIt++) { - if (unvisitedOldChildPairIt->first == 0) { + for (auto &unvisitedRecursiveChildPair : + unvisitedRecursiveChildPairs) { + if (unvisitedRecursiveChildPair.first == 0) { continue; } - auto &oldFlattenedNode = *unvisitedOldChildPairIt->second; + auto &oldFlattenedNode = *unvisitedRecursiveChildPair.second; // Node unvisited - mark the entire subtree for deletion if (oldFlattenedNode.isConcreteView && @@ -1026,13 +1025,11 @@ static void calculateShadowViewMutationsFlattener( // Final step: go through creation/deletion candidates and delete/create // subtrees if they were never visited during the execution of the above // loop and recursions. - for (auto it = deletionCreationCandidatePairs.begin(); - it != deletionCreationCandidatePairs.end(); - it++) { - if (it->first == 0) { + for (auto &deletionCreationCandidatePair : deletionCreationCandidatePairs) { + if (deletionCreationCandidatePair.first == 0) { continue; } - auto &treeChildPair = *it->second; + auto &treeChildPair = *deletionCreationCandidatePair.second; // If node was visited during a flattening/unflattening recursion, // and the node in the other tree is concrete, that means it was @@ -1087,7 +1084,9 @@ static void calculateShadowViewMutationsV2( ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, ShadowViewNodePair::NonOwningList &&oldChildPairs, - ShadowViewNodePair::NonOwningList &&newChildPairs) { + ShadowViewNodePair::NonOwningList &&newChildPairs, + bool isRecursionRedundant) { + SystraceSection s("Differentiator::calculateShadowViewMutationsV2"); if (oldChildPairs.empty() && newChildPairs.empty()) { return; } @@ -1205,13 +1204,39 @@ static void calculateShadowViewMutationsV2( continue; } + // If we take this path, technically the operations and recursion below + // are redundant. However, some parts of the Fabric ecosystem (namely, as + // of writing this, LayoutAnimations) rely heavily on getting /explicit/ + // Remove/Delete instructions for every single node in the tree. Thus, we + // generate the "RemoveDeleteTree" instruction as well as all of the + // individual Remove/Delete operations below, but we mark those as + // redundant. The platform layer can then discard the unnecessary + // instructions. RemoveDeleteTreeMutation is a significant performance + // improvement but could be improved significantly by eliminating the need + // for any of the redundant instructions in the future. + if (ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction && + !isRecursionRedundant) { + mutationContainer.removeMutations.push_back( + ShadowViewMutation::RemoveDeleteTreeMutation( + parentShadowView, + oldChildPair.shadowView, + static_cast(oldChildPair.mountIndex))); + } + mutationContainer.deleteMutations.push_back( - ShadowViewMutation::DeleteMutation(oldChildPair.shadowView)); + ShadowViewMutation::DeleteMutation( + oldChildPair.shadowView, + isRecursionRedundant || + ShadowViewMutation:: + PlatformSupportsRemoveDeleteTreeInstruction)); mutationContainer.removeMutations.push_back( ShadowViewMutation::RemoveMutation( parentShadowView, oldChildPair.shadowView, - static_cast(oldChildPair.mountIndex))); + static_cast(oldChildPair.mountIndex), + isRecursionRedundant || + ShadowViewMutation:: + PlatformSupportsRemoveDeleteTreeInstruction)); // We also have to call the algorithm recursively to clean up the entire // subtree starting from the removed view. @@ -1224,7 +1249,8 @@ static void calculateShadowViewMutationsV2( oldChildPair.shadowView, sliceChildShadowNodeViewPairsFromViewNodePair( oldChildPair, innerScope), - {}); + {}, + ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction); } } else if (index == oldChildPairs.size()) { // If we don't have any more existing children we can choose a fast path @@ -1477,14 +1503,12 @@ static void calculateShadowViewMutationsV2( // subtrees/nodes. We do this here because we need to traverse the entire // list to make sure that a node was not reparented into an unflattened // node that occurs *after* it in the hierarchy, due to zIndex ordering. - for (auto it = deletionCandidatePairs.begin(); - it != deletionCandidatePairs.end(); - it++) { - if (it->first == 0) { + for (auto &deletionCandidatePair : deletionCandidatePairs) { + if (deletionCandidatePair.first == 0) { continue; } - auto const &oldChildPair = *it->second; + auto const &oldChildPair = *deletionCandidatePair.second; DEBUG_LOGS({ LOG(ERROR) @@ -1520,17 +1544,16 @@ static void calculateShadowViewMutationsV2( // Final step: generate Create instructions for entirely new // subtrees/nodes that are not the result of flattening or unflattening. - for (auto it = newInsertedPairs.begin(); it != newInsertedPairs.end(); - it++) { + for (auto &newInsertedPair : newInsertedPairs) { // Erased elements of a TinyMap will have a Tag/key of 0 - skip those // These *should* be removed by the map; there are currently no KNOWN // cases where TinyMap will do the wrong thing, but there are not yet // any unit tests explicitly for TinyMap, so this is safer for now. - if (it->first == 0) { + if (newInsertedPair.first == 0) { continue; } - auto const &newChildPair = *it->second; + auto const &newChildPair = *newInsertedPair.second; DEBUG_LOGS({ LOG(ERROR) diff --git a/ReactCommon/react/renderer/mounting/Differentiator.h b/ReactCommon/react/renderer/mounting/Differentiator.h index 551173652c8260..6d7cbfa58d3590 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.h +++ b/ReactCommon/react/renderer/mounting/Differentiator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 98001cfa1c1f7a..8dc8f97ca6061a 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -75,11 +75,11 @@ void MountingCoordinator::resetLatestRevision() const { lastRevision_.reset(); } -better::optional MountingCoordinator::pullTransaction() +std::optional MountingCoordinator::pullTransaction() const { std::lock_guard lock(mutex_); - auto transaction = better::optional{}; + auto transaction = std::optional{}; // Base case if (lastRevision_.has_value()) { @@ -183,7 +183,7 @@ TelemetryController const &MountingCoordinator::getTelemetryController() const { void MountingCoordinator::setMountingOverrideDelegate( std::weak_ptr delegate) const { std::lock_guard lock(mutex_); - mountingOverrideDelegate_ = delegate; + mountingOverrideDelegate_ = std::move(delegate); } } // namespace react diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/ReactCommon/react/renderer/mounting/MountingCoordinator.h index 00c12ba06858e6..ba66f6a11dc2b1 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include @@ -56,7 +56,7 @@ class MountingCoordinator final { * However, a consumer should always call it on the same thread (e.g. on the * main thread) or ensure sequentiality of mount transactions separately. */ - better::optional pullTransaction() const; + std::optional pullTransaction() const; /* * Blocks the current thread until a new mounting transaction is available or @@ -104,7 +104,7 @@ class MountingCoordinator final { mutable std::mutex mutex_; mutable ShadowTreeRevision baseRevision_; - mutable better::optional lastRevision_{}; + mutable std::optional lastRevision_{}; mutable MountingTransaction::Number number_{0}; mutable std::condition_variable signal_; mutable std::weak_ptr diff --git a/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h b/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h index 5aa95d4d80f035..807cd9f013017e 100644 --- a/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h +++ b/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -36,7 +36,7 @@ class MountingOverrideDelegate { * @param mountingCoordinator * @return */ - virtual better::optional pullTransaction( + virtual std::optional pullTransaction( SurfaceId surfaceId, MountingTransaction::Number number, TransactionTelemetry const &telemetry, diff --git a/ReactCommon/react/renderer/mounting/MountingTransaction.cpp b/ReactCommon/react/renderer/mounting/MountingTransaction.cpp index 6fce3907303e77..8c3e2c37472955 100644 --- a/ReactCommon/react/renderer/mounting/MountingTransaction.cpp +++ b/ReactCommon/react/renderer/mounting/MountingTransaction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -30,7 +30,7 @@ ShadowViewMutationList MountingTransaction::getMutations() && { return std::move(mutations_); } -TransactionTelemetry const &MountingTransaction::getTelemetry() const { +TransactionTelemetry &MountingTransaction::getTelemetry() const { return telemetry_; } diff --git a/ReactCommon/react/renderer/mounting/MountingTransaction.h b/ReactCommon/react/renderer/mounting/MountingTransaction.h index 6f0bbee60fe30d..6a65d8dab9f379 100644 --- a/ReactCommon/react/renderer/mounting/MountingTransaction.h +++ b/ReactCommon/react/renderer/mounting/MountingTransaction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -65,7 +65,7 @@ class MountingTransaction final { /* * Returns telemetry associated with this transaction. */ - TransactionTelemetry const &getTelemetry() const; + TransactionTelemetry &getTelemetry() const; /* * Returns the id of the surface that the transaction belongs to. @@ -81,7 +81,7 @@ class MountingTransaction final { SurfaceId surfaceId_; Number number_; ShadowViewMutationList mutations_; - TransactionTelemetry telemetry_; + mutable TransactionTelemetry telemetry_; }; } // namespace react diff --git a/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp b/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp deleted file mode 100644 index ff8a2ce5bc363f..00000000000000 --- a/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "MountingTransactionMetadata.h" - -namespace facebook { -namespace react {} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h b/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h deleted file mode 100644 index 176a34c9cda3ad..00000000000000 --- a/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -/* - * Contains all (meta)information related to a MountingTransaction except a list - * of mutation instructions. - * The class is meant to be used when a consumer should not have access to all - * information about the transaction (incapsulation) but still needs to observe - * it to produce some side-effects. - */ -class MountingTransactionMetadata final { - public: - SurfaceId surfaceId; - MountingTransaction::Number number; - TransactionTelemetry telemetry; - SurfaceTelemetry surfaceTelemetry; -}; - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index 1d3c6fe8dce323..e68b88f8529bf7 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -110,8 +110,8 @@ static ShadowNode::Unshared progressState( // Stage 1: Aligned part. for (index = 0; index < childrenSize && index < baseChildrenSize; index++) { - const auto &childNode = *children.at(index); - const auto &baseChildNode = *baseChildren.at(index); + auto const &childNode = *children[index]; + auto const &baseChildNode = *baseChildren[index]; if (&childNode == &baseChildNode) { // Nodes are identical, skipping. @@ -136,7 +136,7 @@ static ShadowNode::Unshared progressState( // Stage 2: Misaligned part. for (; index < childrenSize; index++) { - auto newChildNode = progressState(*children.at(index)); + auto newChildNode = progressState(*children[index]); if (newChildNode) { if (!areChildrenChanged) { // Making a copy before the first mutation. @@ -161,8 +161,8 @@ static ShadowNode::Unshared progressState( } static void updateMountedFlag( - const SharedShadowNodeList &oldChildren, - const SharedShadowNodeList &newChildren) { + const ShadowNode::ListOfShared &oldChildren, + const ShadowNode::ListOfShared &newChildren) { // This is a simplified version of Diffing algorithm that only updates // `mounted` flag on `ShadowNode`s. The algorithm sets "mounted" flag before // "unmounted" to allow `ShadowNode` detect a situation where the node was @@ -270,7 +270,7 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const { auto revision = ShadowTreeRevision{}; { - std::unique_lock lock(commitMutex_); + std::unique_lock lock(commitMutex_); if (commitMode_ == commitMode) { return; } @@ -287,7 +287,7 @@ void ShadowTree::setCommitMode(CommitMode commitMode) const { } CommitMode ShadowTree::getCommitMode() const { - std::shared_lock lock(commitMutex_); + std::shared_lock lock(commitMutex_); return commitMode_; } @@ -330,12 +330,12 @@ CommitStatus ShadowTree::tryCommit( { // Reading `currentRevision_` in shared manner. - std::shared_lock lock(commitMutex_); + std::shared_lock lock(commitMutex_); commitMode = commitMode_; oldRevision = currentRevision_; } - auto oldRootShadowNode = oldRevision.rootShadowNode; + auto const &oldRootShadowNode = oldRevision.rootShadowNode; auto newRootShadowNode = transaction(*oldRevision.rootShadowNode); if (!newRootShadowNode || @@ -345,7 +345,7 @@ CommitStatus ShadowTree::tryCommit( if (commitOptions.enableStateReconciliation) { auto updatedNewRootShadowNode = - progressState(*newRootShadowNode, *oldRevision.rootShadowNode); + progressState(*newRootShadowNode, *oldRootShadowNode); if (updatedNewRootShadowNode) { newRootShadowNode = std::static_pointer_cast(updatedNewRootShadowNode); @@ -367,7 +367,7 @@ CommitStatus ShadowTree::tryCommit( { // Updating `currentRevision_` in unique manner if it hasn't changed. - std::unique_lock lock(commitMutex_); + std::unique_lock lock(commitMutex_); if (currentRevision_.number != oldRevision.number) { return CommitStatus::Failed; @@ -410,7 +410,7 @@ CommitStatus ShadowTree::tryCommit( } ShadowTreeRevision ShadowTree::getCurrentRevision() const { - std::shared_lock lock(commitMutex_); + std::shared_lock lock(commitMutex_); return currentRevision_; } @@ -433,7 +433,10 @@ void ShadowTree::commitEmptyTree() const { void ShadowTree::emitLayoutEvents( std::vector &affectedLayoutableNodes) const { - SystraceSection s("ShadowTree::emitLayoutEvents"); + SystraceSection s( + "ShadowTree::emitLayoutEvents", + "affectedLayoutableNodes", + affectedLayoutableNodes.size()); for (auto const *layoutableNode : affectedLayoutableNodes) { // Only instances of `ViewShadowNode` (and subclasses) are supported. diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.h b/ReactCommon/react/renderer/mounting/ShadowTree.h index 2553fdc3d310cd..248ce4daa10f19 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -135,7 +135,7 @@ class ShadowTree final { SurfaceId const surfaceId_; ShadowTreeDelegate const &delegate_; - mutable better::shared_mutex commitMutex_; + mutable butter::shared_mutex commitMutex_; mutable CommitMode commitMode_{ CommitMode::Normal}; // Protected by `commitMutex_`. mutable ShadowTreeRevision currentRevision_; // Protected by `commitMutex_`. diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h b/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h index 45e762c5314013..4816733068002d 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp index 8c801d82270f8c..2b0c6927edf454 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,14 +18,14 @@ ShadowTreeRegistry::~ShadowTreeRegistry() { } void ShadowTreeRegistry::add(std::unique_ptr &&shadowTree) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); registry_.emplace(shadowTree->getSurfaceId(), std::move(shadowTree)); } std::unique_ptr ShadowTreeRegistry::remove( SurfaceId surfaceId) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); auto iterator = registry_.find(surfaceId); if (iterator == registry_.end()) { @@ -39,8 +39,8 @@ std::unique_ptr ShadowTreeRegistry::remove( bool ShadowTreeRegistry::visit( SurfaceId surfaceId, - std::function callback) const { - std::shared_lock lock(mutex_); + std::function const &callback) const { + std::shared_lock lock(mutex_); auto iterator = registry_.find(surfaceId); @@ -53,15 +53,10 @@ bool ShadowTreeRegistry::visit( } void ShadowTreeRegistry::enumerate( - std::function callback) - const { - std::shared_lock lock(mutex_); - bool stop = false; + std::function const &callback) const { + std::shared_lock lock(mutex_); for (auto const &pair : registry_) { - callback(*pair.second, stop); - if (stop) { - break; - } + callback(*pair.second); } } diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h index e2cee3d8c65b79..5e520f963985ec 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,8 @@ #pragma once -#include -#include +#include +#include #include #include @@ -50,19 +50,18 @@ class ShadowTreeRegistry final { */ bool visit( SurfaceId surfaceId, - std::function callback) const; + std::function const &callback) const; /* * Enumerates all stored shadow trees. - * Set `stop` to `true` to interrupt the enumeration. * Can be called from any thread. */ - void enumerate(std::function - callback) const; + void enumerate( + std::function const &callback) const; private: - mutable better::shared_mutex mutex_; - mutable better::map> + mutable butter::shared_mutex mutex_; + mutable butter::map> registry_; // Protected by `mutex_`. }; diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.cpp b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.cpp index f56d03ec2023e0..510683987eeb76 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h index 50e05ad7741a5b..4c7075ec7a5bcd 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h +++ b/ReactCommon/react/renderer/mounting/ShadowTreeRevision.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,8 +7,6 @@ #pragma once -#include - #include #include #include diff --git a/ReactCommon/react/renderer/mounting/ShadowView.cpp b/ReactCommon/react/renderer/mounting/ShadowView.cpp index 3b4b54f1439b68..a521baf785c81d 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/ShadowView.h b/ReactCommon/react/renderer/mounting/ShadowView.h index 614399b2fb0250..350f05bd77d4fc 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.h +++ b/ReactCommon/react/renderer/mounting/ShadowView.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -65,9 +65,9 @@ std::vector getDebugProps( * */ struct ShadowViewNodePair final { - using NonOwningList = better:: + using NonOwningList = butter:: small_vector; - using OwningList = better:: + using OwningList = butter:: small_vector; ShadowView shadowView; @@ -103,7 +103,7 @@ struct ShadowViewNodePair final { * */ struct ShadowViewNodePairLegacy final { - using OwningList = better::small_vector< + using OwningList = butter::small_vector< ShadowViewNodePairLegacy, kShadowNodeChildrenSmallVectorSize>; diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp index 4a77190dff1295..2873f06e4da2f2 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,26 +7,37 @@ #include "ShadowViewMutation.h" +#include + namespace facebook { namespace react { +/** + * Initialize static feature flags for this module. + * These flags should be treated as temporary. + */ +bool ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction = false; + ShadowViewMutation ShadowViewMutation::CreateMutation(ShadowView shadowView) { return { /* .type = */ Create, /* .parentShadowView = */ {}, /* .oldChildShadowView = */ {}, - /* .newChildShadowView = */ shadowView, + /* .newChildShadowView = */ std::move(shadowView), /* .index = */ -1, }; } -ShadowViewMutation ShadowViewMutation::DeleteMutation(ShadowView shadowView) { +ShadowViewMutation ShadowViewMutation::DeleteMutation( + ShadowView shadowView, + bool isRedundantOperation) { return { /* .type = */ Delete, /* .parentShadowView = */ {}, - /* .oldChildShadowView = */ shadowView, + /* .oldChildShadowView = */ std::move(shadowView), /* .newChildShadowView = */ {}, /* .index = */ -1, + /* .isRedundantOperation */ isRedundantOperation, }; } @@ -36,9 +47,9 @@ ShadowViewMutation ShadowViewMutation::InsertMutation( int index) { return { /* .type = */ Insert, - /* .parentShadowView = */ parentShadowView, + /* .parentShadowView = */ std::move(parentShadowView), /* .oldChildShadowView = */ {}, - /* .newChildShadowView = */ childShadowView, + /* .newChildShadowView = */ std::move(childShadowView), /* .index = */ index, }; } @@ -46,11 +57,26 @@ ShadowViewMutation ShadowViewMutation::InsertMutation( ShadowViewMutation ShadowViewMutation::RemoveMutation( ShadowView parentShadowView, ShadowView childShadowView, - int index) { + int index, + bool isRedundantOperation) { return { /* .type = */ Remove, - /* .parentShadowView = */ parentShadowView, - /* .oldChildShadowView = */ childShadowView, + /* .parentShadowView = */ std::move(parentShadowView), + /* .oldChildShadowView = */ std::move(childShadowView), + /* .newChildShadowView = */ {}, + /* .index = */ index, + /* .isRedundantOperation */ isRedundantOperation, + }; +} + +ShadowViewMutation ShadowViewMutation::RemoveDeleteTreeMutation( + ShadowView parentShadowView, + ShadowView childShadowView, + int index) { + return { + /* .type = */ RemoveDeleteTree, + /* .parentShadowView = */ std::move(parentShadowView), + /* .oldChildShadowView = */ std::move(childShadowView), /* .newChildShadowView = */ {}, /* .index = */ index, }; @@ -62,8 +88,8 @@ ShadowViewMutation ShadowViewMutation::UpdateMutation( return { /* .type = */ Update, /* .parentShadowView = */ {}, - /* .oldChildShadowView = */ oldChildShadowView, - /* .newChildShadowView = */ newChildShadowView, + /* .oldChildShadowView = */ std::move(oldChildShadowView), + /* .newChildShadowView = */ std::move(newChildShadowView), /* .index = */ -1, }; } @@ -89,12 +115,14 @@ ShadowViewMutation::ShadowViewMutation( ShadowView parentShadowView, ShadowView oldChildShadowView, ShadowView newChildShadowView, - int index) + int index, + bool isRedundantOperation) : type(type), - parentShadowView(parentShadowView), - oldChildShadowView(oldChildShadowView), - newChildShadowView(newChildShadowView), - index(index) {} + parentShadowView(std::move(parentShadowView)), + oldChildShadowView(std::move(oldChildShadowView)), + newChildShadowView(std::move(newChildShadowView)), + index(index), + isRedundantOperation(isRedundantOperation) {} #if RN_DEBUG_STRING_CONVERTIBLE @@ -110,6 +138,8 @@ std::string getDebugName(ShadowViewMutation const &mutation) { return "Remove"; case ShadowViewMutation::Update: return "Update"; + case ShadowViewMutation::RemoveDeleteTree: + return "RemoveDeleteTree"; } } diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h index 3ed3414804a547..7beba76b25eb2a 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,6 +25,10 @@ struct ShadowViewMutation final { ShadowViewMutation() = delete; +#pragma mark - Platform feature flags + + static bool PlatformSupportsRemoveDeleteTreeInstruction; + #pragma mark - Designated Initializers /* @@ -35,7 +39,9 @@ struct ShadowViewMutation final { /* * Creates and returns an `Delete` mutation. */ - static ShadowViewMutation DeleteMutation(ShadowView shadowView); + static ShadowViewMutation DeleteMutation( + ShadowView shadowView, + bool isRedundantOperation = false); /* * Creates and returns an `Insert` mutation. @@ -49,6 +55,18 @@ struct ShadowViewMutation final { * Creates and returns a `Remove` mutation. */ static ShadowViewMutation RemoveMutation( + ShadowView parentShadowView, + ShadowView childShadowView, + int index, + bool isRedundantOperation = false); + + /* + * Creates and returns a `RemoveDelete` mutation. + * This is a signal to (for supported platforms) + * remove and delete an entire subtree with a single + * instruction. + */ + static ShadowViewMutation RemoveDeleteTreeMutation( ShadowView parentShadowView, ShadowView childShadowView, int index); @@ -62,7 +80,14 @@ struct ShadowViewMutation final { #pragma mark - Type - enum Type { Create = 1, Delete = 2, Insert = 4, Remove = 8, Update = 16 }; + enum Type { + Create = 1, + Delete = 2, + Insert = 4, + Remove = 8, + Update = 16, + RemoveDeleteTree = 32 + }; #pragma mark - Fields @@ -72,6 +97,12 @@ struct ShadowViewMutation final { ShadowView newChildShadowView = {}; int index = -1; + // RemoveDeleteTree causes many Remove/Delete operations to be redundant. + // However, we must internally produce all of them for any consumers that + // rely on explicit instructions to remove/delete every node in the tree. + // Notably (as of the time of writing this) LayoutAnimations. + bool isRedundantOperation = false; + // Some platforms can have the notion of virtual views - views that are in the // ShadowTree hierarchy but never are on the platform. Generally this is used // so notify the platform that a view exists so that we can keep EventEmitters @@ -85,7 +116,8 @@ struct ShadowViewMutation final { ShadowView parentShadowView, ShadowView oldChildShadowView, ShadowView newChildShadowView, - int index); + int index, + bool isRedundantOperation = false); }; using ShadowViewMutationList = std::vector; diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index cad4ae8a398685..0d490dc657258d 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/StubView.h b/ReactCommon/react/renderer/mounting/StubView.h index a721c57c74d210..b629a16abd04d4 100644 --- a/ReactCommon/react/renderer/mounting/StubView.h +++ b/ReactCommon/react/renderer/mounting/StubView.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,7 +35,7 @@ class StubView final { ComponentHandle componentHandle; SurfaceId surfaceId; Tag tag; - SharedProps props; + Props::Shared props; SharedEventEmitter eventEmitter; LayoutMetrics layoutMetrics; State::Shared state; diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.cpp b/ReactCommon/react/renderer/mounting/StubViewTree.cpp index 6e82ad5028fb1a..fb1fc8e1ac9e68 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.cpp +++ b/ReactCommon/react/renderer/mounting/StubViewTree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -200,6 +200,11 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { break; } + case ShadowViewMutation::RemoveDeleteTree: { + // TODO: do something here + break; + } + case ShadowViewMutation::Update: { STUB_VIEW_LOG({ LOG(ERROR) << "StubView: Update [" << mutation.newChildShadowView.tag @@ -250,7 +255,7 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) { // For iOS especially: flush logs because some might be lost on iOS if an // assert is hit right after this. - google::FlushLogFiles(google::INFO); + google::FlushLogFiles(google::GLOG_INFO); } bool operator==(StubViewTree const &lhs, StubViewTree const &rhs) { diff --git a/ReactCommon/react/renderer/mounting/StubViewTree.h b/ReactCommon/react/renderer/mounting/StubViewTree.h index c3ce25c8fdf10e..5d09bed0a0f6cd 100644 --- a/ReactCommon/react/renderer/mounting/StubViewTree.h +++ b/ReactCommon/react/renderer/mounting/StubViewTree.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/TelemetryController.cpp b/ReactCommon/react/renderer/mounting/TelemetryController.cpp index a9e36d9a399637..25ef9bee6509d0 100644 --- a/ReactCommon/react/renderer/mounting/TelemetryController.cpp +++ b/ReactCommon/react/renderer/mounting/TelemetryController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,9 +17,9 @@ TelemetryController::TelemetryController( : mountingCoordinator_(mountingCoordinator) {} bool TelemetryController::pullTransaction( - std::function willMount, - std::function doMount, - std::function didMount) const { + MountingTransactionCallback const &willMount, + MountingTransactionCallback const &doMount, + MountingTransactionCallback const &didMount) const { auto optional = mountingCoordinator_.pullTransaction(); if (!optional.has_value()) { return false; @@ -27,24 +27,22 @@ bool TelemetryController::pullTransaction( auto transaction = std::move(*optional); - auto surfaceId = transaction.getSurfaceId(); - auto number = transaction.getNumber(); - auto telemetry = transaction.getTelemetry(); + auto &telemetry = transaction.getTelemetry(); auto numberOfMutations = static_cast(transaction.getMutations().size()); mutex_.lock(); auto compoundTelemetry = compoundTelemetry_; mutex_.unlock(); - willMount({surfaceId, number, telemetry, compoundTelemetry}); + willMount(transaction, compoundTelemetry); telemetry.willMount(); - doMount(std::move(transaction.getMutations())); + doMount(transaction, compoundTelemetry); telemetry.didMount(); compoundTelemetry.incorporate(telemetry, numberOfMutations); - didMount({surfaceId, number, telemetry, compoundTelemetry}); + didMount(transaction, compoundTelemetry); mutex_.lock(); compoundTelemetry_ = compoundTelemetry; diff --git a/ReactCommon/react/renderer/mounting/TelemetryController.h b/ReactCommon/react/renderer/mounting/TelemetryController.h index 3911ea30e42258..23ecd25c806a54 100644 --- a/ReactCommon/react/renderer/mounting/TelemetryController.h +++ b/ReactCommon/react/renderer/mounting/TelemetryController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,7 +11,6 @@ #include #include -#include #include namespace facebook { @@ -19,6 +18,10 @@ namespace react { class MountingCoordinator; +using MountingTransactionCallback = std::function; + /* * Provides convenient tools for aggregating and accessing telemetry data * associated with running Surface. @@ -43,9 +46,9 @@ class TelemetryController final { * Calls `MountingCoordinator::pullTransaction()` and aggregates telemetry. */ bool pullTransaction( - std::function willMount, - std::function doMount, - std::function didMount) const; + MountingTransactionCallback const &willMount, + MountingTransactionCallback const &doMount, + MountingTransactionCallback const &didMount) const; private: MountingCoordinator const &mountingCoordinator_; diff --git a/ReactCommon/react/renderer/mounting/stubs.cpp b/ReactCommon/react/renderer/mounting/stubs.cpp index c5f76beb203e04..71ff672ecc7f62 100644 --- a/ReactCommon/react/renderer/mounting/stubs.cpp +++ b/ReactCommon/react/renderer/mounting/stubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/stubs.h b/ReactCommon/react/renderer/mounting/stubs.h index 73ac7b1d8ecccf..a55145be1e6da7 100644 --- a/ReactCommon/react/renderer/mounting/stubs.h +++ b/ReactCommon/react/renderer/mounting/stubs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp index 8ad2395bef7687..5c98724a79b2f2 100644 --- a/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/MountingTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -43,14 +43,14 @@ static SharedViewProps nonFlattenedDefaultProps( static ShadowNode::Shared makeNode( ComponentDescriptor const &componentDescriptor, int tag, - ShadowNode::ListOfShared children, + const ShadowNode::ListOfShared &children, bool flattened = false) { auto props = flattened ? generateDefaultProps(componentDescriptor) : nonFlattenedDefaultProps(componentDescriptor); return componentDescriptor.createShadowNode( ShadowNodeFragment{ - props, std::make_shared(children)}, + props, std::make_shared(children)}, componentDescriptor.createFamily({tag, SurfaceId(1), nullptr}, nullptr)); } @@ -111,32 +111,32 @@ TEST(MountingTest, testReorderingInstructionGeneration) { auto shadowNodeV1 = viewComponentDescriptor.createShadowNode( ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childB, childC, childD})}, + std::make_shared( + ShadowNode::ListOfShared{childB, childC, childD})}, family); auto shadowNodeV2 = shadowNodeV1->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childA, childB, childC, childD})}); + std::make_shared( + ShadowNode::ListOfShared{childA, childB, childC, childD})}); auto shadowNodeV3 = shadowNodeV2->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childB, childC, childD})}); + std::make_shared( + ShadowNode::ListOfShared{childB, childC, childD})}); auto shadowNodeV4 = shadowNodeV3->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childB, childD, childE})}); + std::make_shared( + ShadowNode::ListOfShared{childB, childD, childE})}); auto shadowNodeV5 = shadowNodeV4->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childB, childA, childE, childC})}); + std::make_shared( + ShadowNode::ListOfShared{childB, childA, childE, childC})}); auto shadowNodeV6 = shadowNodeV5->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared(SharedShadowNodeList{ + std::make_shared(ShadowNode::ListOfShared{ childB, childA, childD, childF, childE, childC})}); auto shadowNodeV7 = shadowNodeV6->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared(SharedShadowNodeList{ + std::make_shared(ShadowNode::ListOfShared{ childF, childE, childC, @@ -151,38 +151,38 @@ TEST(MountingTest, testReorderingInstructionGeneration) { auto rootNodeV1 = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV1})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV1})})); auto rootNodeV2 = std::static_pointer_cast( rootNodeV1->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV2})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV2})})); auto rootNodeV3 = std::static_pointer_cast( rootNodeV2->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV3})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV3})})); auto rootNodeV4 = std::static_pointer_cast( rootNodeV3->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV4})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV4})})); auto rootNodeV5 = std::static_pointer_cast( rootNodeV4->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV5})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV5})})); auto rootNodeV6 = std::static_pointer_cast( rootNodeV5->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV6})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV6})})); auto rootNodeV7 = std::static_pointer_cast( rootNodeV6->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV7})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV7})})); // Layout std::vector affectedLayoutableNodesV1{}; @@ -358,9 +358,9 @@ TEST(MountingTest, testReorderingInstructionGeneration) { // The actual nodes that should be created in this transaction have a tag > // 105. EXPECT_TRUE(mutations6.size() == 25); - for (int i = 0; i < mutations6.size(); i++) { - if (mutations6[i].type == ShadowViewMutation::Create) { - EXPECT_TRUE(mutations6[i].newChildShadowView.tag > 105); + for (auto &i : mutations6) { + if (i.type == ShadowViewMutation::Create) { + EXPECT_TRUE(i.newChildShadowView.tag > 105); } } } @@ -419,159 +419,169 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) { auto reparentedViewA = makeNode( viewComponentDescriptor, 1000, - SharedShadowNodeList{ + ShadowNode::ListOfShared{ childC->clone({}), childA->clone({}), childB->clone({})}); auto reparentedViewB = makeNode( viewComponentDescriptor, 2000, - SharedShadowNodeList{ + ShadowNode::ListOfShared{ childF->clone({}), childE->clone({}), childD->clone({})}); // Root -> G* -> H -> I -> J -> A* [nodes with * are _not_ flattened] auto shadowNodeV1 = viewComponentDescriptor.createShadowNode( ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childG->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childG->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childH->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childH->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>(SharedShadowNodeList{ - childI->clone(ShadowNodeFragment{ - generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{ - childJ->clone(ShadowNodeFragment{ - generateDefaultProps( - viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>( - SharedShadowNodeList{ - reparentedViewA->clone( - {})})})})})})})})})})}, + std::make_shared( + ShadowNode::ListOfShared{ + childI->clone(ShadowNodeFragment{ + generateDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + childJ->clone(ShadowNodeFragment{ + generateDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + reparentedViewA->clone( + {})})})})})})})})})})}, family); // Root -> G* -> H* -> I -> J -> A* [nodes with * are _not_ flattened] auto shadowNodeV2 = shadowNodeV1->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childG->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childG->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childH->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childH->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childI->clone(ShadowNodeFragment{ + std::make_shared< + ShadowNode::ListOfShared>(ShadowNode::ListOfShared{ + childI->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>(SharedShadowNodeList{ - childJ->clone(ShadowNodeFragment{ - generateDefaultProps( - viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{ - reparentedViewA->clone( - {})})})})})})})})})})}); + std::make_shared( + ShadowNode::ListOfShared{ + childJ->clone(ShadowNodeFragment{ + generateDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + reparentedViewA->clone( + {})})})})})})})})})})}); // Root -> G* -> H -> I -> J -> A* [nodes with * are _not_ flattened] auto shadowNodeV3 = shadowNodeV2->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childG->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childG->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childH->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childH->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childI->clone(ShadowNodeFragment{ + std::make_shared< + ShadowNode::ListOfShared>(ShadowNode::ListOfShared{ + childI->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>(SharedShadowNodeList{ - childJ->clone(ShadowNodeFragment{ - generateDefaultProps( - viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{ - reparentedViewA->clone( - {})})})})})})})})})})}); + std::make_shared( + ShadowNode::ListOfShared{ + childJ->clone(ShadowNodeFragment{ + generateDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + reparentedViewA->clone( + {})})})})})})})})})})}); // The view is reparented 1 level down with a different sibling // Root -> G* -> H* -> I* -> J -> [B*, A*] [nodes with * are _not_ flattened] auto shadowNodeV4 = shadowNodeV3->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childG->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childG->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childH->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childH->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childI->clone(ShadowNodeFragment{ + std::make_shared< + ShadowNode::ListOfShared>(ShadowNode::ListOfShared{ + childI->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>(SharedShadowNodeList{ - childJ->clone(ShadowNodeFragment{ - generateDefaultProps( - viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{ - reparentedViewB->clone({}), - reparentedViewA->clone( - {})})})})})})})})})})}); + std::make_shared( + ShadowNode::ListOfShared{ + childJ->clone(ShadowNodeFragment{ + generateDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + reparentedViewB->clone({}), + reparentedViewA->clone( + {})})})})})})})})})})}); // The view is reparented 1 level further down with its order with the sibling // swapped // Root -> G* -> H* -> I* -> J* -> [A*, B*] [nodes with * are _not_ flattened] auto shadowNodeV5 = shadowNodeV4->clone(ShadowNodeFragment{ generateDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childG->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childG->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childH->clone(ShadowNodeFragment{ + std::make_shared( + ShadowNode::ListOfShared{childH->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{childI->clone(ShadowNodeFragment{ + std::make_shared< + ShadowNode::ListOfShared>(ShadowNode::ListOfShared{ + childI->clone(ShadowNodeFragment{ nonFlattenedDefaultProps(viewComponentDescriptor), - std::make_shared< - SharedShadowNodeList>(SharedShadowNodeList{ - childJ->clone(ShadowNodeFragment{ - nonFlattenedDefaultProps( - viewComponentDescriptor), - std::make_shared( - SharedShadowNodeList{ - reparentedViewA->clone({}), - reparentedViewB->clone( - {})})})})})})})})})})}); + std::make_shared( + ShadowNode::ListOfShared{ + childJ->clone(ShadowNodeFragment{ + nonFlattenedDefaultProps( + viewComponentDescriptor), + std::make_shared< + ShadowNode::ListOfShared>( + ShadowNode::ListOfShared{ + reparentedViewA->clone({}), + reparentedViewB->clone( + {})})})})})})})})})})}); // Injecting a tree into the root node. auto rootNodeV1 = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV1})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV1})})); auto rootNodeV2 = std::static_pointer_cast( rootNodeV1->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV2})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV2})})); auto rootNodeV3 = std::static_pointer_cast( rootNodeV2->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV3})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV3})})); auto rootNodeV4 = std::static_pointer_cast( rootNodeV3->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV4})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV4})})); auto rootNodeV5 = std::static_pointer_cast( rootNodeV4->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{shadowNodeV5})})); + std::make_shared( + ShadowNode::ListOfShared{shadowNodeV5})})); // Layout std::vector affectedLayoutableNodesV1{}; diff --git a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index da9806e58dc5c0..1afd71e2b79a7d 100644 --- a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -77,8 +77,8 @@ static void testShadowNodeTreeLifeCycle( auto currentRootNode = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{singleRootChildNode})})); + std::make_shared( + ShadowNode::ListOfShared{singleRootChildNode})})); // Building an initial view hierarchy. auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); @@ -227,8 +227,8 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( auto currentRootNode = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ ShadowNodeFragment::propsPlaceholder(), - std::make_shared( - SharedShadowNodeList{singleRootChildNode})})); + std::make_shared( + ShadowNode::ListOfShared{singleRootChildNode})})); // Building an initial view hierarchy. auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); diff --git a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 521d3135d1311f..6d2cc0a19005e6 100644 --- a/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -153,19 +153,19 @@ class StackingContextTest : public ::testing::Test { } void mutateViewShadowNodeProps_( - std::shared_ptr node, + std::shared_ptr const &node, std::function callback) { rootShadowNode_ = std::static_pointer_cast(rootShadowNode_->cloneTree( node->getFamily(), [&](ShadowNode const &oldShadowNode) { - auto viewProps = std::make_shared(); + auto viewProps = std::make_shared(); callback(*viewProps); return oldShadowNode.clone(ShadowNodeFragment{viewProps}); })); } void testViewTree_( - std::function callback) { + std::function const &callback) { rootShadowNode_->layoutIfNeeded(); callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_)); diff --git a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp index b88ec2c33f781c..ffa54f0dd97d67 100644 --- a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,14 +24,14 @@ using namespace facebook::react; class DummyShadowTreeDelegate : public ShadowTreeDelegate { public: - virtual RootShadowNode::Unshared shadowTreeWillCommit( + RootShadowNode::Unshared shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const override { return newRootShadowNode; }; - virtual void shadowTreeDidFinishTransaction( + void shadowTreeDidFinishTransaction( ShadowTree const &shadowTree, MountingCoordinator::Shared const &mountingCoordinator) const override{}; }; diff --git a/ReactCommon/react/renderer/runtimescheduler/Android.mk b/ReactCommon/react/renderer/runtimescheduler/Android.mk deleted file mode 100644 index b67a8e632908e3..00000000000000 --- a/ReactCommon/react/renderer/runtimescheduler/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_runtimescheduler - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libruntimeexecutor libreact_render_core libreact_debug libjsi callinvoker - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,runtimeexecutor) -$(call import-module,callinvoker) diff --git a/ReactCommon/react/renderer/runtimescheduler/BUCK b/ReactCommon/react/renderer/runtimescheduler/BUCK index 81f2b99954f916..7db6aa11bbf87c 100644 --- a/ReactCommon/react/renderer/runtimescheduler/BUCK +++ b/ReactCommon/react/renderer/runtimescheduler/BUCK @@ -34,7 +34,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -46,7 +49,7 @@ rn_xplat_cxx_library( deps = [ react_native_xplat_target("runtimeexecutor:runtimeexecutor"), react_native_xplat_target("react/renderer/debug:debug"), - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("callinvoker:callinvoker"), ], ) diff --git a/ReactCommon/react/renderer/runtimescheduler/CMakeLists.txt b/ReactCommon/react/renderer/runtimescheduler/CMakeLists.txt new file mode 100644 index 00000000000000..5a18fb85c09ad8 --- /dev/null +++ b/ReactCommon/react/renderer/runtimescheduler/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_runtimescheduler_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_runtimescheduler SHARED ${react_render_runtimescheduler_SRC}) + +target_include_directories(react_render_runtimescheduler PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_runtimescheduler + callinvoker + jsi + react_debug + react_render_core + runtimeexecutor) diff --git a/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h b/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h index a6da8b49b852a8..75e7f0a6ba7de2 100644 --- a/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h +++ b/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp index ecf2589dddcad6..fd041aca8a4c02 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp @@ -1,11 +1,13 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #include "RuntimeScheduler.h" + +#include #include "ErrorUtils.h" namespace facebook { @@ -14,25 +16,19 @@ namespace react { #pragma mark - Public RuntimeScheduler::RuntimeScheduler( - RuntimeExecutor const &runtimeExecutor, + RuntimeExecutor runtimeExecutor, std::function now) - : runtimeExecutor_(runtimeExecutor), now_(now) {} + : runtimeExecutor_(std::move(runtimeExecutor)), now_(std::move(now)) {} void RuntimeScheduler::scheduleWork( std::function callback) const { - if (enableYielding_) { - shouldYield_ = true; - runtimeExecutor_( - [this, callback = std::move(callback)](jsi::Runtime &runtime) { - shouldYield_ = false; - callback(runtime); - startWorkLoop(runtime); - }); - } else { - runtimeExecutor_([callback = std::move(callback)](jsi::Runtime &runtime) { - callback(runtime); - }); - } + runtimeAccessRequests_ += 1; + runtimeExecutor_( + [this, callback = std::move(callback)](jsi::Runtime &runtime) { + runtimeAccessRequests_ -= 1; + callback(runtime); + startWorkLoop(runtime); + }); } std::shared_ptr RuntimeScheduler::scheduleTask( @@ -43,23 +39,21 @@ std::shared_ptr RuntimeScheduler::scheduleTask( std::make_shared(priority, std::move(callback), expirationTime); taskQueue_.push(task); - if (!isCallbackScheduled_ && !isPerformingWork_) { - isCallbackScheduled_ = true; - runtimeExecutor_([this](jsi::Runtime &runtime) { - isCallbackScheduled_ = false; - startWorkLoop(runtime); - }); - } + scheduleWorkLoopIfNecessary(); return task; } bool RuntimeScheduler::getShouldYield() const noexcept { - return shouldYield_; + return runtimeAccessRequests_ > 0; +} + +bool RuntimeScheduler::getIsSynchronous() const noexcept { + return isSynchronous_; } -void RuntimeScheduler::cancelTask(const std::shared_ptr &task) noexcept { - task->callback.reset(); +void RuntimeScheduler::cancelTask(Task &task) noexcept { + task.callback.reset(); } SchedulerPriority RuntimeScheduler::getCurrentPriorityLevel() const noexcept { @@ -70,23 +64,67 @@ RuntimeSchedulerTimePoint RuntimeScheduler::now() const noexcept { return now_(); } -void RuntimeScheduler::setEnableYielding(bool enableYielding) { - enableYielding_ = enableYielding; -} - void RuntimeScheduler::executeNowOnTheSameThread( - std::function callback) const { - shouldYield_ = true; + std::function callback) { + runtimeAccessRequests_ += 1; executeSynchronouslyOnSameThread_CAN_DEADLOCK( runtimeExecutor_, - [callback = std::move(callback)](jsi::Runtime &runtime) { + [this, callback = std::move(callback)](jsi::Runtime &runtime) { + runtimeAccessRequests_ -= 1; + isSynchronous_ = true; callback(runtime); + isSynchronous_ = false; }); - shouldYield_ = false; + + // Resume work loop if needed. In synchronous mode + // only expired tasks are executed. Tasks with lower priority + // might be still in the queue. + scheduleWorkLoopIfNecessary(); +} + +void RuntimeScheduler::callExpiredTasks(jsi::Runtime &runtime) { + auto previousPriority = currentPriority_; + try { + while (!taskQueue_.empty()) { + auto topPriorityTask = taskQueue_.top(); + auto now = now_(); + auto didUserCallbackTimeout = topPriorityTask->expirationTime <= now; + + if (!didUserCallbackTimeout) { + break; + } + + currentPriority_ = topPriorityTask->priority; + auto result = topPriorityTask->execute(runtime); + + if (result.isObject() && result.getObject(runtime).isFunction(runtime)) { + topPriorityTask->callback = + result.getObject(runtime).getFunction(runtime); + } else { + if (taskQueue_.top() == topPriorityTask) { + taskQueue_.pop(); + } + } + } + } catch (jsi::JSError &error) { + handleFatalError(runtime, error); + } + + currentPriority_ = previousPriority; } #pragma mark - Private +void RuntimeScheduler::scheduleWorkLoopIfNecessary() const { + if (!isWorkLoopScheduled_ && !isPerformingWork_) { + isWorkLoopScheduled_ = true; + runtimeExecutor_([this](jsi::Runtime &runtime) { + isWorkLoopScheduled_ = false; + startWorkLoop(runtime); + }); + } +} + void RuntimeScheduler::startWorkLoop(jsi::Runtime &runtime) const { auto previousPriority = currentPriority_; isPerformingWork_ = true; @@ -96,10 +134,11 @@ void RuntimeScheduler::startWorkLoop(jsi::Runtime &runtime) const { auto now = now_(); auto didUserCallbackTimeout = topPriorityTask->expirationTime <= now; - if (!didUserCallbackTimeout && shouldYield_) { - // This task hasn't expired and we need to yield. + if (!didUserCallbackTimeout && getShouldYield()) { + // This currentTask hasn't expired, and we need to yield. break; } + currentPriority_ = topPriorityTask->priority; auto result = topPriorityTask->execute(runtime); diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h index 5d18a7d9ea8a85..96dce49a47f311 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,7 +20,7 @@ namespace react { class RuntimeScheduler final { public: RuntimeScheduler( - RuntimeExecutor const &runtimeExecutor, + RuntimeExecutor runtimeExecutor, std::function now = RuntimeSchedulerClock::now); /* @@ -45,21 +45,66 @@ class RuntimeScheduler final { * component. */ void executeNowOnTheSameThread( - std::function callback) const; + std::function callback); + /* + * Adds a JavaScript callback to priority queue with given priority. + * Triggers workloop if needed. + * + * Thread synchronization must be enforced externally. + */ std::shared_ptr scheduleTask( SchedulerPriority priority, jsi::Function callback); - void cancelTask(std::shared_ptr const &task) noexcept; + /* + * Cancelled task will never be executed. + * + * Operates on JSI object. + * Thread synchronization must be enforced externally. + */ + void cancelTask(Task &task) noexcept; + /* + * Return value indicates if host platform has a pending access to the + * runtime. + * + * Can be called from any thread. + */ bool getShouldYield() const noexcept; + /* + * Return value informs if the current task is executed inside synchronous + * block. + * + * Can be called from any thread. + */ + bool getIsSynchronous() const noexcept; + + /* + * Returns value of currently executed task. Designed to be called from React. + * + * Thread synchronization must be enforced externally. + */ SchedulerPriority getCurrentPriorityLevel() const noexcept; + /* + * Returns current monotonic time. This time is not related to wall clock + * time. + * + * Thread synchronization must be enforced externally. + */ RuntimeSchedulerTimePoint now() const noexcept; - void setEnableYielding(bool enableYielding); + /* + * Expired task is a task that should have been already executed. Designed to + * be called in the event pipeline after an event is dispatched to React. + * React may schedule events with immediate priority which need to be handled + * before the next event is sent to React. + * + * Thread synchronization must be enforced externally. + */ + void callExpiredTasks(jsi::Runtime &runtime); private: mutable std::priority_queue< @@ -70,10 +115,22 @@ class RuntimeScheduler final { RuntimeExecutor const runtimeExecutor_; mutable SchedulerPriority currentPriority_{SchedulerPriority::NormalPriority}; - mutable std::atomic_bool shouldYield_{false}; + + /* + * Counter indicating how many access to the runtime have been requested. + */ + mutable std::atomic runtimeAccessRequests_{0}; + + mutable std::atomic_bool isSynchronous_{false}; void startWorkLoop(jsi::Runtime &runtime) const; + /* + * Schedules a work loop unless it has been already scheduled + * This is to avoid unnecessary calls to `runtimeExecutor`. + */ + void scheduleWorkLoopIfNecessary() const; + /* * Returns a time point representing the current point in time. May be called * from multiple threads. @@ -84,21 +141,12 @@ class RuntimeScheduler final { * Flag indicating if callback on JavaScript queue has been * scheduled. */ - std::atomic_bool isCallbackScheduled_{false}; - - /* - * Flag indicating if yielding is enabled. - * - * If set to true and Concurrent Mode is enabled on the surface, - * React Native will ask React to yield in case any work has been scheduled. - * Default value is false - */ - bool enableYielding_{false}; + mutable std::atomic_bool isWorkLoopScheduled_{false}; /* * This flag is set while performing work, to prevent re-entrancy. */ - mutable bool isPerformingWork_{false}; + mutable std::atomic_bool isPerformingWork_{false}; }; } // namespace react diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index 92525118e282d8..c04d842f8e6129 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,6 +12,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -42,9 +43,27 @@ RuntimeSchedulerBinding::createAndInstallIfNeeded( return runtimeSchedulerObject.getHostObject(runtime); } +std::shared_ptr RuntimeSchedulerBinding::getBinding( + jsi::Runtime &runtime) { + auto runtimeSchedulerModuleName = "nativeRuntimeScheduler"; + + auto runtimeSchedulerValue = + runtime.global().getProperty(runtime, runtimeSchedulerModuleName); + if (runtimeSchedulerValue.isUndefined()) { + return nullptr; + } + + auto runtimeSchedulerObject = runtimeSchedulerValue.asObject(runtime); + return runtimeSchedulerObject.getHostObject(runtime); +} + RuntimeSchedulerBinding::RuntimeSchedulerBinding( - std::shared_ptr const &runtimeScheduler) - : runtimeScheduler_(runtimeScheduler) {} + std::shared_ptr runtimeScheduler) + : runtimeScheduler_(std::move(runtimeScheduler)) {} + +bool RuntimeSchedulerBinding::getIsSynchronous() const { + return runtimeScheduler_->getIsSynchronous(); +} jsi::Value RuntimeSchedulerBinding::get( jsi::Runtime &runtime, @@ -81,7 +100,7 @@ jsi::Value RuntimeSchedulerBinding::get( jsi::Value const &, jsi::Value const *arguments, size_t) noexcept -> jsi::Value { - runtimeScheduler_->cancelTask(taskFromValue(runtime, arguments[0])); + runtimeScheduler_->cancelTask(*taskFromValue(runtime, arguments[0])); return jsi::Value::undefined(); }); } @@ -133,9 +152,21 @@ jsi::Value RuntimeSchedulerBinding::get( }); } + // TODO: remmove this, as it's deprecated in the JS scheduler if (propertyName == "unstable_getCurrentPriorityLevel") { - auto currentPriorityLevel = runtimeScheduler_->getCurrentPriorityLevel(); - return jsi::Value(runtime, serialize(currentPriorityLevel)); + return jsi::Function::createFromHostFunction( + runtime, + name, + 0, + [this]( + jsi::Runtime &runtime, + jsi::Value const &, + jsi::Value const *, + size_t) noexcept -> jsi::Value { + auto currentPriorityLevel = + runtimeScheduler_->getCurrentPriorityLevel(); + return jsi::Value(runtime, serialize(currentPriorityLevel)); + }); } if (propertyName == "unstable_ImmediatePriority") { @@ -163,8 +194,11 @@ jsi::Value RuntimeSchedulerBinding::get( return jsi::Value::undefined(); } - react_native_assert(false && "undefined property"); +#ifdef REACT_NATIVE_DEBUG + throw std::runtime_error("undefined property"); +#else return jsi::Value::undefined(); +#endif } } // namespace react diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h index 27c1ad9f31dff5..92c345abbfcd67 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,8 +18,7 @@ namespace react { */ class RuntimeSchedulerBinding : public jsi::HostObject { public: - RuntimeSchedulerBinding( - std::shared_ptr const &runtimeScheduler); + RuntimeSchedulerBinding(std::shared_ptr runtimeScheduler); /* * Installs RuntimeSchedulerBinding into JavaScript runtime if needed. @@ -31,11 +30,20 @@ class RuntimeSchedulerBinding : public jsi::HostObject { jsi::Runtime &runtime, std::shared_ptr const &runtimeScheduler); + /* + * Returns a shared pointer to RuntimeSchedulerBinding previously installed + * into a runtime. Thread synchronization must be enforced externally. + */ + static std::shared_ptr getBinding( + jsi::Runtime &runtime); + /* * `jsi::HostObject` specific overloads. */ jsi::Value get(jsi::Runtime &runtime, jsi::PropNameID const &name) override; + bool getIsSynchronous() const; + private: std::shared_ptr runtimeScheduler_; }; diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp index 70f02ca132e03f..3f8b3be7ae4f4c 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,12 +7,14 @@ #include "RuntimeSchedulerCallInvoker.h" +#include + namespace facebook { namespace react { RuntimeSchedulerCallInvoker::RuntimeSchedulerCallInvoker( std::weak_ptr runtimeScheduler) - : runtimeScheduler_(runtimeScheduler) {} + : runtimeScheduler_(std::move(runtimeScheduler)) {} void RuntimeSchedulerCallInvoker::invokeAsync(std::function &&func) { if (auto runtimeScheduler = runtimeScheduler_.lock()) { diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h index b40e0cad727846..0fd18530c3da8a 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h index 51652ee0a070d3..c6edc7f28c9108 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h index 329fe252aa3860..76309e24768aab 100644 --- a/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h +++ b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -61,5 +61,21 @@ static inline std::chrono::milliseconds timeoutForSchedulerPriority( } } +static inline std::string debugValueForSchedulerPriority( + SchedulerPriority schedulerPriority) { + switch (schedulerPriority) { + case SchedulerPriority::ImmediatePriority: + return "SchedulerPriority::ImmediatePriority"; + case SchedulerPriority::UserBlockingPriority: + return "SchedulerPriority::UserBlockingPriority"; + case SchedulerPriority::NormalPriority: + return "SchedulerPriority::NormalPriority"; + case SchedulerPriority::LowPriority: + return "SchedulerPriority::LowPriority"; + case SchedulerPriority::IdlePriority: + return "SchedulerPriority::IdlePriority"; + } +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/Task.cpp b/ReactCommon/react/renderer/runtimescheduler/Task.cpp index bd87944afa37ab..bed71bb4b0326a 100644 --- a/ReactCommon/react/renderer/runtimescheduler/Task.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/Task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/Task.h b/ReactCommon/react/renderer/runtimescheduler/Task.h index 87676d5db737b9..76c52a9ff5e973 100644 --- a/ReactCommon/react/renderer/runtimescheduler/Task.h +++ b/ReactCommon/react/renderer/runtimescheduler/Task.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,11 +7,12 @@ #pragma once -#include #include #include #include +#include + namespace facebook { namespace react { @@ -29,7 +30,7 @@ struct Task final { friend TaskPriorityComparer; SchedulerPriority priority; - better::optional callback; + std::optional callback; RuntimeSchedulerClock::time_point expirationTime; jsi::Value execute(jsi::Runtime &runtime); diff --git a/ReactCommon/react/renderer/runtimescheduler/primitives.h b/ReactCommon/react/renderer/runtimescheduler/primitives.h index 2283b4cad27104..caa2b2614014ca 100644 --- a/ReactCommon/react/renderer/runtimescheduler/primitives.h +++ b/ReactCommon/react/renderer/runtimescheduler/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index 3fade3594ee6b1..7c274bcf39358a 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -159,7 +159,7 @@ TEST_F(RuntimeSchedulerTest, taskExpiration) { } TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { - uint firstTaskCallOrder; + uint firstTaskCallOrder = 0; auto callbackOne = createHostFunctionFromLambda([this, &firstTaskCallOrder](bool) { firstTaskCallOrder = hostFunctionCallCount_; @@ -192,7 +192,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { } TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { - uint lowPriorityTaskCallOrder; + uint lowPriorityTaskCallOrder = 0; auto callbackOne = createHostFunctionFromLambda([this, &lowPriorityTaskCallOrder](bool) { lowPriorityTaskCallOrder = hostFunctionCallCount_; @@ -237,7 +237,7 @@ TEST_F(RuntimeSchedulerTest, cancelTask) { EXPECT_FALSE(didRunTask); EXPECT_EQ(stubQueue_->size(), 1); - runtimeScheduler_->cancelTask(task); + runtimeScheduler_->cancelTask(*task); stubQueue_->tick(); @@ -316,25 +316,7 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { SchedulerPriority::NormalPriority); } -TEST_F(RuntimeSchedulerTest, scheduleWork) { - bool wasCalled = false; - runtimeScheduler_->scheduleWork( - [&](jsi::Runtime const &) { wasCalled = true; }); - - EXPECT_FALSE(wasCalled); - - EXPECT_FALSE(runtimeScheduler_->getShouldYield()); - - EXPECT_EQ(stubQueue_->size(), 1); - - stubQueue_->tick(); - - EXPECT_TRUE(wasCalled); - EXPECT_EQ(stubQueue_->size(), 0); -} - TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) { - runtimeScheduler_->setEnableYielding(true); bool wasCalled = false; runtimeScheduler_->scheduleWork( [&](jsi::Runtime const &) { wasCalled = true; }); @@ -353,8 +335,6 @@ TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) { } TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { - runtimeScheduler_->setEnableYielding(true); - bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; @@ -382,8 +362,6 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { } TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { - runtimeScheduler_->setEnableYielding(true); - bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; @@ -412,8 +390,6 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { } TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) { - runtimeScheduler_->setEnableYielding(true); - bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; @@ -477,7 +453,7 @@ TEST_F(RuntimeSchedulerTest, handlingError) { bool didRunTask = false; auto firstCallback = createHostFunctionFromLambda([this, &didRunTask](bool) { didRunTask = true; - jsi::detail::throwJSError(*runtime_, "Test error"); + throw jsi::JSError(*runtime_, "Test error"); return jsi::Value::undefined(); }); @@ -494,4 +470,151 @@ TEST_F(RuntimeSchedulerTest, handlingError) { EXPECT_EQ(stubErrorUtils_->getReportFatalCallCount(), 1); } +TEST_F(RuntimeSchedulerTest, basicSameThreadExecution) { + bool didRunSynchronousTask = false; + std::thread t1([this, &didRunSynchronousTask]() { + runtimeScheduler_->executeNowOnTheSameThread( + [this, &didRunSynchronousTask](jsi::Runtime &rt) { + EXPECT_TRUE(runtimeScheduler_->getIsSynchronous()); + didRunSynchronousTask = true; + }); + EXPECT_FALSE(runtimeScheduler_->getIsSynchronous()); + }); + + auto hasTask = stubQueue_->waitForTask(1ms); + + EXPECT_TRUE(hasTask); + EXPECT_FALSE(didRunSynchronousTask); + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + t1.join(); + + EXPECT_TRUE(didRunSynchronousTask); +} + +TEST_F(RuntimeSchedulerTest, sameThreadTaskCreatesImmediatePriorityTask) { + bool didRunSynchronousTask = false; + bool didRunSubsequentTask = false; + std::thread t1([this, &didRunSynchronousTask, &didRunSubsequentTask]() { + runtimeScheduler_->executeNowOnTheSameThread( + [this, &didRunSynchronousTask, &didRunSubsequentTask]( + jsi::Runtime &runtime) { + didRunSynchronousTask = true; + + auto callback = createHostFunctionFromLambda( + [&didRunSubsequentTask](bool didUserCallbackTimeout) { + didRunSubsequentTask = true; + EXPECT_FALSE(didUserCallbackTimeout); + return jsi::Value::undefined(); + }); + + runtimeScheduler_->scheduleTask( + SchedulerPriority::ImmediatePriority, std::move(callback)); + + runtimeScheduler_->callExpiredTasks(runtime); + }); + }); + + auto hasTask = stubQueue_->waitForTask(1ms); + + EXPECT_TRUE(hasTask); + EXPECT_FALSE(didRunSynchronousTask); + EXPECT_FALSE(didRunSubsequentTask); + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + t1.join(); + + EXPECT_TRUE(didRunSynchronousTask); + EXPECT_TRUE(didRunSubsequentTask); +} + +TEST_F(RuntimeSchedulerTest, sameThreadTaskCreatesLowPriorityTask) { + bool didRunSynchronousTask = false; + bool didRunSubsequentTask = false; + std::thread t1([this, &didRunSynchronousTask, &didRunSubsequentTask]() { + runtimeScheduler_->executeNowOnTheSameThread( + [this, &didRunSynchronousTask, &didRunSubsequentTask]( + jsi::Runtime &runtime) { + didRunSynchronousTask = true; + + auto callback = createHostFunctionFromLambda( + [&didRunSubsequentTask](bool didUserCallbackTimeout) { + didRunSubsequentTask = true; + EXPECT_FALSE(didUserCallbackTimeout); + return jsi::Value::undefined(); + }); + + runtimeScheduler_->scheduleTask( + SchedulerPriority::LowPriority, std::move(callback)); + runtimeScheduler_->callExpiredTasks(runtime); + + EXPECT_FALSE(didRunSubsequentTask); + }); + }); + + auto hasTask = stubQueue_->waitForTask(1ms); + + EXPECT_TRUE(hasTask); + EXPECT_FALSE(didRunSynchronousTask); + EXPECT_FALSE(didRunSubsequentTask); + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + t1.join(); + + EXPECT_TRUE(didRunSynchronousTask); + EXPECT_FALSE(didRunSubsequentTask); + + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + EXPECT_TRUE(didRunSubsequentTask); + + EXPECT_EQ(stubQueue_->size(), 0); +} + +TEST_F(RuntimeSchedulerTest, twoThreadsRequestAccessToTheRuntime) { + bool didRunSynchronousTask = false; + bool didRunWork = false; + + runtimeScheduler_->scheduleWork( + [&didRunWork](jsi::Runtime &) { didRunWork = true; }); + + std::thread t1([this, &didRunSynchronousTask]() { + runtimeScheduler_->executeNowOnTheSameThread( + [&didRunSynchronousTask](jsi::Runtime &runtime) { + didRunSynchronousTask = true; + }); + }); + + auto hasTask = stubQueue_->waitForTasks(2, 1ms); + + EXPECT_TRUE(hasTask); + EXPECT_FALSE(didRunWork); + EXPECT_FALSE(didRunSynchronousTask); + EXPECT_TRUE(runtimeScheduler_->getShouldYield()); + EXPECT_EQ(stubQueue_->size(), 2); + + stubQueue_->tick(); + + EXPECT_TRUE(didRunWork); + EXPECT_FALSE(didRunSynchronousTask); + EXPECT_TRUE(runtimeScheduler_->getShouldYield()); + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + t1.join(); + + EXPECT_TRUE(didRunWork); + EXPECT_TRUE(didRunSynchronousTask); + EXPECT_FALSE(runtimeScheduler_->getShouldYield()); +} + } // namespace facebook::react diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp index 4139e2f0c16cbb..cb32caf215e3f8 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/StubClock.h b/ReactCommon/react/renderer/runtimescheduler/tests/StubClock.h index 6ac977fd7d536a..26c93459edb382 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/StubClock.h +++ b/ReactCommon/react/renderer/runtimescheduler/tests/StubClock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h b/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h index ca2de84a0fe612..f5ddf9bbd308a9 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h +++ b/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h b/ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h index 272be4833b0069..c7a7c634ce3145 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h +++ b/ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,32 +7,63 @@ #pragma once +#include #include class StubQueue { public: void runOnQueue(std::function &&func) { - callbackQueue_.push(func); + { + std::lock_guard lock(mutex_); + callbackQueue_.push(func); + } + + signal_.notify_one(); } void flush() { - while (!callbackQueue_.empty()) { + while (size() > 0) { tick(); } } void tick() { - if (!callbackQueue_.empty()) { - auto callback = callbackQueue_.front(); + std::function callback; + { + std::lock_guard lock(mutex_); + if (!callbackQueue_.empty()) { + callback = callbackQueue_.front(); + callbackQueue_.pop(); + } + } + + if (callback) { callback(); - callbackQueue_.pop(); } } - int size() { + size_t size() const { + std::lock_guard lock(mutex_); return callbackQueue_.size(); } + bool waitForTask(std::chrono::duration timeout) const { + std::unique_lock lock(mutex_); + return signal_.wait_for( + lock, timeout, [this]() { return !callbackQueue_.empty(); }); + } + + bool waitForTasks( + std::size_t numberOfTasks, + std::chrono::duration timeout) const { + std::unique_lock lock(mutex_); + return signal_.wait_for(lock, timeout, [this, numberOfTasks]() { + return numberOfTasks == callbackQueue_.size(); + }); + } + private: + mutable std::condition_variable signal_; + mutable std::mutex mutex_; std::queue> callbackQueue_; }; diff --git a/ReactCommon/react/renderer/scheduler/Android.mk b/ReactCommon/react/renderer/scheduler/Android.mk deleted file mode 100644 index 32b8f71dd04780..00000000000000 --- a/ReactCommon/react/renderer/scheduler/Android.mk +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_scheduler - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libyoga librrc_view libreact_utils libreact_render_templateprocessor libreact_render_graphics libreact_render_uimanager libfolly_futures libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_root libreact_render_mounting libreact_debug libreact_render_runtimescheduler - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/runtimescheduler) -$(call import-module,react/renderer/templateprocessor) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp index e625afe059bbf8..543be6cf5c70db 100644 --- a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h index c6751a087912be..c6350a431832be 100644 --- a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h +++ b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/scheduler/BUCK b/ReactCommon/react/renderer/scheduler/BUCK index ee76e263bb1dfe..2d10b223f875b5 100644 --- a/ReactCommon/react/renderer/scheduler/BUCK +++ b/ReactCommon/react/renderer/scheduler/BUCK @@ -33,7 +33,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -44,7 +47,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/scheduler/CMakeLists.txt b/ReactCommon/react/renderer/scheduler/CMakeLists.txt new file mode 100644 index 00000000000000..3823b9d3c1e102 --- /dev/null +++ b/ReactCommon/react/renderer/scheduler/CMakeLists.txt @@ -0,0 +1,34 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_scheduler_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_scheduler SHARED ${react_render_scheduler_SRC}) + +target_include_directories(react_render_scheduler PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_scheduler + folly_runtime + glog + jsi + react_config + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_mounting + react_render_runtimescheduler + react_render_templateprocessor + react_render_uimanager + react_utils + rrc_root + rrc_view + yoga +) diff --git a/ReactCommon/react/renderer/scheduler/InspectorData.h b/ReactCommon/react/renderer/scheduler/InspectorData.h index ac77165b0dd0e2..76eda88ac7e61f 100644 --- a/ReactCommon/react/renderer/scheduler/InspectorData.h +++ b/ReactCommon/react/renderer/scheduler/InspectorData.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 15cff205ffee64..53a7fe6bf34035 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ namespace facebook { namespace react { Scheduler::Scheduler( - SchedulerToolbox schedulerToolbox, + SchedulerToolbox const &schedulerToolbox, UIManagerAnimationDelegate *animationDelegate, SchedulerDelegate *delegate) { runtimeExecutor_ = schedulerToolbox.runtimeExecutor; @@ -42,15 +42,30 @@ Scheduler::Scheduler( "ReactNativeConfig"); // Creating a container for future `EventDispatcher` instance. - eventDispatcher_ = - std::make_shared>(); + eventDispatcher_ = std::make_shared>(); auto uiManager = std::make_shared( runtimeExecutor_, schedulerToolbox.backgroundExecutor, contextContainer_); auto eventOwnerBox = std::make_shared(); eventOwnerBox->owner = eventDispatcher_; - auto eventPipe = [uiManager]( +#ifdef ANDROID + auto enableCallImmediates = reactNativeConfig_->getBool( + "react_native_new_architecture:enable_call_immediates_android"); +#else + auto enableCallImmediates = reactNativeConfig_->getBool( + "react_native_new_architecture:enable_call_immediates_ios"); +#endif + + auto weakRuntimeScheduler = + contextContainer_->find>( + "RuntimeScheduler"); + auto runtimeScheduler = + (enableCallImmediates && weakRuntimeScheduler.has_value()) + ? weakRuntimeScheduler.value().lock() + : nullptr; + + auto eventPipe = [uiManager, runtimeScheduler = runtimeScheduler.get()]( jsi::Runtime &runtime, const EventTarget *eventTarget, const std::string &type, @@ -62,6 +77,9 @@ Scheduler::Scheduler( runtime, eventTarget, type, priority, payloadFactory); }, runtime); + if (runtimeScheduler) { + runtimeScheduler->callExpiredTasks(runtime); + } }; auto statePipe = [uiManager](StateUpdate const &stateUpdate) { @@ -86,12 +104,11 @@ Scheduler::Scheduler( uiManager->setDelegate(this); uiManager->setComponentDescriptorRegistry(componentDescriptorRegistry_); - runtimeExecutor_([uiManager, - runtimeExecutor = runtimeExecutor_](jsi::Runtime &runtime) { - auto uiManagerBinding = - UIManagerBinding::createAndInstallIfNeeded(runtime, runtimeExecutor); - uiManagerBinding->attach(uiManager); - }); + runtimeExecutor_( + [uiManager, runtimeExecutor = runtimeExecutor_](jsi::Runtime &runtime) { + UIManagerBinding::createAndInstallIfNeeded( + runtime, runtimeExecutor, uiManager); + }); auto componentDescriptorRegistryKey = "ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE"; @@ -105,7 +122,7 @@ Scheduler::Scheduler( commitHooks_ = schedulerToolbox.commitHooks; uiManager_ = uiManager; - for (auto commitHook : commitHooks_) { + for (auto const &commitHook : commitHooks_) { uiManager->registerCommitHook(*commitHook); } @@ -116,8 +133,7 @@ Scheduler::Scheduler( uiManager_->setAnimationDelegate(animationDelegate); #ifdef ANDROID - removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( - "react_fabric:remove_outstanding_surfaces_on_destruction_android"); + removeOutstandingSurfacesOnDestruction_ = true; #else removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool( "react_fabric:remove_outstanding_surfaces_on_destruction_ios"); @@ -128,7 +144,7 @@ Scheduler::~Scheduler() { LOG(WARNING) << "Scheduler::~Scheduler() was called (address: " << this << ")."; - for (auto commitHook : commitHooks_) { + for (auto const &commitHook : commitHooks_) { uiManager_->unregisterCommitHook(*commitHook); } @@ -143,7 +159,7 @@ Scheduler::~Scheduler() { // Then, let's verify that the requirement was satisfied. auto surfaceIds = std::vector{}; uiManager_->getShadowTreeRegistry().enumerate( - [&](ShadowTree const &shadowTree, bool &stop) { + [&surfaceIds](ShadowTree const &shadowTree) { surfaceIds.push_back(shadowTree.getSurfaceId()); }); @@ -207,10 +223,10 @@ InspectorData Scheduler::getInspectorDataForInstance( // TODO T97216348: remove folly::dynamic from InspectorData struct result.props = dynamic["props"]; auto hierarchy = dynamic["hierarchy"]; - for (size_t i = 0; i < hierarchy.size(); i++) { - auto viewHierarchyValue = hierarchy[i]["name"]; + for (auto &i : hierarchy) { + auto viewHierarchyValue = i["name"]; if (!viewHierarchyValue.isNull()) { - result.hierarchy.push_back(viewHierarchyValue.c_str()); + result.hierarchy.emplace_back(viewHierarchyValue.c_str()); } } return result; @@ -248,8 +264,8 @@ void Scheduler::renderTemplateToSurface( ShadowNodeFragment{ /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .children = */ - std::make_shared( - SharedShadowNodeList{tree}), + std::make_shared( + ShadowNode::ListOfShared{tree}), }); }); }); @@ -315,7 +331,7 @@ void Scheduler::uiManagerDidCloneShadowNode( void Scheduler::uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) { + folly::dynamic const &args) { SystraceSection s("Scheduler::uiManagerDispatchCommand"); if (delegate_) { @@ -352,5 +368,23 @@ ContextContainer::Shared Scheduler::getContextContainer() const { return contextContainer_; } +std::shared_ptr Scheduler::getUIManager() const { + return uiManager_; +} + +void Scheduler::addEventListener( + const std::shared_ptr &listener) { + if (eventDispatcher_->has_value()) { + eventDispatcher_->value().addListener(listener); + } +} + +void Scheduler::removeEventListener( + const std::shared_ptr &listener) { + if (eventDispatcher_->has_value()) { + eventDispatcher_->value().removeListener(listener); + } +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 32beafc7e9ffda..626572a073f23f 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ namespace react { class Scheduler final : public UIManagerDelegate { public: Scheduler( - SchedulerToolbox schedulerToolbox, + SchedulerToolbox const &schedulerToolbox, UIManagerAnimationDelegate *animationDelegate, SchedulerDelegate *delegate); ~Scheduler(); @@ -95,7 +96,7 @@ class Scheduler final : public UIManagerDelegate { void uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) override; + folly::dynamic const &args) override; void uiManagerDidSendAccessibilityEvent( const ShadowNode::Shared &shadowNode, std::string const &eventType) override; @@ -107,6 +108,14 @@ class Scheduler final : public UIManagerDelegate { #pragma mark - ContextContainer ContextContainer::Shared getContextContainer() const; +#pragma mark - UIManager + std::shared_ptr getUIManager() const; + +#pragma mark - Event listeners + void addEventListener(const std::shared_ptr &listener); + void removeEventListener( + const std::shared_ptr &listener); + private: friend class SurfaceHandler; @@ -125,7 +134,7 @@ class Scheduler final : public UIManagerDelegate { * parts that need to have ownership (and only ownership) of that, and then * fill the optional. */ - std::shared_ptr> eventDispatcher_; + std::shared_ptr> eventDispatcher_; /** * Hold onto ContextContainer. See SchedulerToolbox. diff --git a/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h b/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h index cfd41c5d30d189..e1bf4fda5bb475 100644 --- a/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h +++ b/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,7 +47,7 @@ class SchedulerDelegate { virtual void schedulerDidDispatchCommand( const ShadowView &shadowView, std::string const &commandName, - folly::dynamic const args) = 0; + folly::dynamic const &args) = 0; virtual void schedulerDidSendAccessibilityEvent( const ShadowView &shadowView, diff --git a/ReactCommon/react/renderer/scheduler/SchedulerToolbox.cpp b/ReactCommon/react/renderer/scheduler/SchedulerToolbox.cpp index 95e21a15064480..8b50f893b4390e 100644 --- a/ReactCommon/react/renderer/scheduler/SchedulerToolbox.cpp +++ b/ReactCommon/react/renderer/scheduler/SchedulerToolbox.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/scheduler/SchedulerToolbox.h b/ReactCommon/react/renderer/scheduler/SchedulerToolbox.h index c6c2c179e0e7f5..6903b86e4531f0 100644 --- a/ReactCommon/react/renderer/scheduler/SchedulerToolbox.h +++ b/ReactCommon/react/renderer/scheduler/SchedulerToolbox.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp index 9e36696803347c..b68e2f617a153a 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,12 +29,12 @@ SurfaceHandler::SurfaceHandler(SurfaceHandler &&other) noexcept { } SurfaceHandler &SurfaceHandler::operator=(SurfaceHandler &&other) noexcept { - std::unique_lock lock1(linkMutex_, std::defer_lock); - std::unique_lock lock2( + std::unique_lock lock1(linkMutex_, std::defer_lock); + std::unique_lock lock2( parametersMutex_, std::defer_lock); - std::unique_lock lock3( + std::unique_lock lock3( other.linkMutex_, std::defer_lock); - std::unique_lock lock4( + std::unique_lock lock4( other.parametersMutex_, std::defer_lock); std::lock(lock1, lock2, lock3, lock4); @@ -51,17 +51,17 @@ SurfaceHandler &SurfaceHandler::operator=(SurfaceHandler &&other) noexcept { void SurfaceHandler::setContextContainer( ContextContainer::Shared contextContainer) const noexcept { - parameters_.contextContainer = contextContainer; + parameters_.contextContainer = std::move(contextContainer); } Status SurfaceHandler::getStatus() const noexcept { - std::shared_lock lock(linkMutex_); + std::shared_lock lock(linkMutex_); return link_.status; } void SurfaceHandler::start() const noexcept { SystraceSection s("SurfaceHandler::start"); - std::unique_lock lock(linkMutex_); + std::unique_lock lock(linkMutex_); react_native_assert( link_.status == Status::Registered && "Surface must be registered."); react_native_assert( @@ -73,7 +73,7 @@ void SurfaceHandler::start() const noexcept { auto parameters = Parameters{}; { SystraceSection s2("SurfaceHandler::start::paramsLock"); - std::shared_lock parametersLock(parametersMutex_); + std::shared_lock parametersLock(parametersMutex_); parameters = parameters_; } @@ -100,7 +100,7 @@ void SurfaceHandler::start() const noexcept { void SurfaceHandler::stop() const noexcept { auto shadowTree = ShadowTree::Unique{}; { - std::unique_lock lock(linkMutex_); + std::unique_lock lock(linkMutex_); react_native_assert( link_.status == Status::Running && "Surface must be running."); @@ -118,7 +118,7 @@ void SurfaceHandler::stop() const noexcept { void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept { { - std::unique_lock lock(parametersMutex_); + std::unique_lock lock(parametersMutex_); if (parameters_.displayMode == displayMode) { return; } @@ -127,7 +127,7 @@ void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept { } { - std::shared_lock lock(linkMutex_); + std::shared_lock lock(linkMutex_); if (link_.status != Status::Running) { return; @@ -144,41 +144,41 @@ void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept { } DisplayMode SurfaceHandler::getDisplayMode() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.displayMode; } #pragma mark - Accessors SurfaceId SurfaceHandler::getSurfaceId() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.surfaceId; } void SurfaceHandler::setSurfaceId(SurfaceId surfaceId) const noexcept { - std::unique_lock lock(parametersMutex_); + std::unique_lock lock(parametersMutex_); parameters_.surfaceId = surfaceId; } std::string SurfaceHandler::getModuleName() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.moduleName; } void SurfaceHandler::setProps(folly::dynamic const &props) const noexcept { SystraceSection s("SurfaceHandler::setProps"); - std::unique_lock lock(parametersMutex_); + std::unique_lock lock(parametersMutex_); parameters_.props = props; } folly::dynamic SurfaceHandler::getProps() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.props; } std::shared_ptr SurfaceHandler::getMountingCoordinator() const noexcept { - std::shared_lock lock(linkMutex_); + std::shared_lock lock(linkMutex_); react_native_assert( link_.status != Status::Unregistered && "Surface must be registered."); react_native_assert( @@ -191,7 +191,7 @@ SurfaceHandler::getMountingCoordinator() const noexcept { Size SurfaceHandler::measure( LayoutConstraints const &layoutConstraints, LayoutContext const &layoutContext) const noexcept { - std::shared_lock lock(linkMutex_); + std::shared_lock lock(linkMutex_); if (link_.status != Status::Running) { return layoutConstraints.clamp({0, 0}); @@ -217,7 +217,7 @@ void SurfaceHandler::constraintLayout( LayoutContext const &layoutContext) const noexcept { SystraceSection s("SurfaceHandler::constraintLayout"); { - std::unique_lock lock(parametersMutex_); + std::unique_lock lock(parametersMutex_); if (parameters_.layoutConstraints == layoutConstraints && parameters_.layoutContext == layoutContext) { @@ -229,7 +229,7 @@ void SurfaceHandler::constraintLayout( } { - std::shared_lock lock(linkMutex_); + std::shared_lock lock(linkMutex_); if (link_.status != Status::Running) { return; @@ -248,12 +248,12 @@ void SurfaceHandler::constraintLayout( } LayoutConstraints SurfaceHandler::getLayoutConstraints() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.layoutConstraints; } LayoutContext SurfaceHandler::getLayoutContext() const noexcept { - std::shared_lock lock(parametersMutex_); + std::shared_lock lock(parametersMutex_); return parameters_.layoutContext; } @@ -292,7 +292,7 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept { } void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept { - std::unique_lock lock(linkMutex_); + std::unique_lock lock(linkMutex_); react_native_assert( link_.status != Status::Running && "Surface must not be running."); diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h index c0ae0e60bdc797..babf534da3a32c 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -195,13 +195,13 @@ class SurfaceHandler { /* * `link_` and `linkMutex_` pair. */ - mutable better::shared_mutex linkMutex_; + mutable butter::shared_mutex linkMutex_; mutable Link link_; /* * `parameters_` and `parametersMutex_` pair. */ - mutable better::shared_mutex parametersMutex_; + mutable butter::shared_mutex parametersMutex_; mutable Parameters parameters_; }; diff --git a/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp b/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp index a6f8a537f92c53..faa9c2c12822af 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,7 +22,7 @@ void SurfaceManager::startSurface( LayoutConstraints const &layoutConstraints, LayoutContext const &layoutContext) const noexcept { { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); auto surfaceHandler = SurfaceHandler{moduleName, surfaceId}; surfaceHandler.setContextContainer(scheduler_.getContextContainer()); registry_.emplace(surfaceId, std::move(surfaceHandler)); @@ -45,7 +45,7 @@ void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept { }); { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); auto iterator = registry_.find(surfaceId); registry_.erase(iterator); @@ -87,9 +87,9 @@ void SurfaceManager::constraintSurfaceLayout( void SurfaceManager::visit( SurfaceId surfaceId, - std::function callback) + std::function const &callback) const noexcept { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto iterator = registry_.find(surfaceId); diff --git a/ReactCommon/react/renderer/scheduler/SurfaceManager.h b/ReactCommon/react/renderer/scheduler/SurfaceManager.h index 83052f1855d776..76dd2bf8f93a41 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceManager.h +++ b/ReactCommon/react/renderer/scheduler/SurfaceManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -26,7 +26,7 @@ namespace react { */ class SurfaceManager final { public: - SurfaceManager(Scheduler const &scheduler) noexcept; + explicit SurfaceManager(Scheduler const &scheduler) noexcept; #pragma mark - Surface Management @@ -55,12 +55,12 @@ class SurfaceManager final { private: void visit( SurfaceId surfaceId, - std::function callback) + std::function const &callback) const noexcept; Scheduler const &scheduler_; - mutable better::shared_mutex mutex_; // Protects `registry_`. - mutable better::map registry_{}; + mutable butter::shared_mutex mutex_; // Protects `registry_`. + mutable butter::map registry_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp index 66d6c8c8a0f5f0..fc9a406629c073 100644 --- a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,17 +9,19 @@ #include +#include + namespace facebook { namespace react { SynchronousEventBeat::SynchronousEventBeat( RunLoopObserver::Unique uiRunLoopObserver, RuntimeExecutor runtimeExecutor, - std::shared_ptr const &runtimeScheduler) + std::shared_ptr runtimeScheduler) : EventBeat({}), uiRunLoopObserver_(std::move(uiRunLoopObserver)), runtimeExecutor_(std::move(runtimeExecutor)), - runtimeScheduler_(runtimeScheduler) { + runtimeScheduler_(std::move(runtimeScheduler)) { uiRunLoopObserver_->setDelegate(this); uiRunLoopObserver_->enable(); } diff --git a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.h b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.h index a3e2d6489d18db..ff2827897b5889 100644 --- a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.h +++ b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,7 +25,7 @@ class SynchronousEventBeat final : public EventBeat, SynchronousEventBeat( RunLoopObserver::Unique uiRunLoopObserver, RuntimeExecutor runtimeExecutor, - std::shared_ptr const &runtimeScheduler); + std::shared_ptr runtimeScheduler); void induce() const override; diff --git a/ReactCommon/react/renderer/telemetry/Android.mk b/ReactCommon/react/renderer/telemetry/Android.mk deleted file mode 100644 index 990ec538ff5fc7..00000000000000 --- a/ReactCommon/react/renderer/telemetry/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_telemetry - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,better) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,react/utils) diff --git a/ReactCommon/react/renderer/telemetry/BUCK b/ReactCommon/react/renderer/telemetry/BUCK index d6b46e35dec661..d1a1da1f31397f 100644 --- a/ReactCommon/react/renderer/telemetry/BUCK +++ b/ReactCommon/react/renderer/telemetry/BUCK @@ -35,7 +35,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -47,10 +50,10 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("react/debug:debug"), react_native_xplat_target("react/utils:utils"), ], diff --git a/ReactCommon/react/renderer/telemetry/CMakeLists.txt b/ReactCommon/react/renderer/telemetry/CMakeLists.txt new file mode 100644 index 00000000000000..cad8f9e81cd3c2 --- /dev/null +++ b/ReactCommon/react/renderer/telemetry/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_telemetry_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_telemetry SHARED ${react_render_telemetry_SRC}) + +target_include_directories(react_render_telemetry PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_telemetry + butter + folly_runtime + glog + glog_init + react_debug + react_render_core + react_render_debug + react_utils + rrc_root + rrc_view + yoga) diff --git a/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.cpp b/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.cpp index 5d836b7006ea30..d982e26d6ee713 100644 --- a/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.cpp +++ b/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.h b/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.h index 6a72636120002b..32aa356be9fc93 100644 --- a/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.h +++ b/ReactCommon/react/renderer/telemetry/SurfaceTelemetry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -60,7 +60,7 @@ class SurfaceTelemetry final { int numberOfTextMeasurements_{}; int lastRevisionNumber_{}; - better:: + butter:: small_vector recentTransactionTelemetries_{}; }; diff --git a/ReactCommon/react/renderer/telemetry/TransactionTelemetry.cpp b/ReactCommon/react/renderer/telemetry/TransactionTelemetry.cpp index b7b5fe37c033d7..79c2f71b55af6a 100644 --- a/ReactCommon/react/renderer/telemetry/TransactionTelemetry.cpp +++ b/ReactCommon/react/renderer/telemetry/TransactionTelemetry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,8 @@ #include +#include + namespace facebook { namespace react { @@ -19,7 +21,7 @@ TransactionTelemetry::TransactionTelemetry() TransactionTelemetry::TransactionTelemetry( std::function now) - : now_{now} {} + : now_{std::move(now)} {} TransactionTelemetry *TransactionTelemetry::threadLocalTelemetry() { return threadLocalTransactionTelemetry; diff --git a/ReactCommon/react/renderer/telemetry/TransactionTelemetry.h b/ReactCommon/react/renderer/telemetry/TransactionTelemetry.h index ab3a398d78537d..919e1f26b716b4 100644 --- a/ReactCommon/react/renderer/telemetry/TransactionTelemetry.h +++ b/ReactCommon/react/renderer/telemetry/TransactionTelemetry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp b/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp index 95c6dfcf1b0785..656ea81067f716 100644 --- a/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp +++ b/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/templateprocessor/Android.mk b/ReactCommon/react/renderer/templateprocessor/Android.mk deleted file mode 100644 index 23ebd6b9a606b1..00000000000000 --- a/ReactCommon/react/renderer/templateprocessor/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_templateprocessor - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libfolly_futures libreact_utils libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug react_render_uimanager - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/utils) -$(call import-module,react/renderer/componentregistry) diff --git a/ReactCommon/react/renderer/templateprocessor/BUCK b/ReactCommon/react/renderer/templateprocessor/BUCK index 430b0bdb1d3b00..eefba5b9e7494c 100644 --- a/ReactCommon/react/renderer/templateprocessor/BUCK +++ b/ReactCommon/react/renderer/templateprocessor/BUCK @@ -34,7 +34,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -46,7 +49,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", diff --git a/ReactCommon/react/renderer/templateprocessor/CMakeLists.txt b/ReactCommon/react/renderer/templateprocessor/CMakeLists.txt new file mode 100644 index 00000000000000..2aeaa6d101f478 --- /dev/null +++ b/ReactCommon/react/renderer/templateprocessor/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_templateprocessor_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_templateprocessor SHARED ${react_render_templateprocessor_SRC}) + +target_include_directories(react_render_templateprocessor PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_templateprocessor + folly_runtime + glog + jsi + react_config + react_render_componentregistry + react_render_core + react_render_debug + react_render_uimanager + react_utils +) diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp index d9f4e44d1dc8b4..a198134b350e00 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,21 +25,21 @@ bool constexpr DEBUG_FLY = false; struct RBCContext { const Tag rootTag; - const std::vector &nodes; + const std::vector &nodes; const std::vector ®isters; const ComponentDescriptorRegistry &componentDescriptorRegistry; const NativeModuleRegistry &nativeModuleRegistry; }; // TODO: use RBCContext instead of all the separate arguments. -SharedShadowNode UITemplateProcessor::runCommand( +ShadowNode::Shared UITemplateProcessor::runCommand( const folly::dynamic &command, SurfaceId surfaceId, - std::vector &nodes, + std::vector &nodes, std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig) { + std::shared_ptr const &reactNativeConfig) { const std::string &opcode = command[0].asString(); const int tagOffset = 420000; // TODO: change to integer codes and a switch statement @@ -100,13 +100,13 @@ SharedShadowNode UITemplateProcessor::runCommand( return nullptr; } -SharedShadowNode UITemplateProcessor::buildShadowTree( +ShadowNode::Shared UITemplateProcessor::buildShadowTree( const std::string &jsonStr, SurfaceId surfaceId, const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig) { + std::shared_ptr const &reactNativeConfig) { if (DEBUG_FLY) { LOG(INFO) << "(strt) UITemplateProcessor inject hardcoded 'server rendered' view tree"; @@ -122,7 +122,7 @@ SharedShadowNode UITemplateProcessor::buildShadowTree( } auto parsed = folly::parseJson(content); auto commands = parsed["commands"]; - std::vector nodes(commands.size() * 2); + std::vector nodes(commands.size() * 2); std::vector registers(32); for (const auto &command : commands) { try { @@ -148,7 +148,7 @@ SharedShadowNode UITemplateProcessor::buildShadowTree( LOG(ERROR) << "react ui template missing returnRoot command :("; throw std::runtime_error( "Missing returnRoot command in template content:\n" + content); - return SharedShadowNode{}; + return ShadowNode::Shared{}; } } // namespace react diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h index 384c572a6997e8..a95339e58b9114 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -50,17 +50,17 @@ class UITemplateProcessor { const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig); + std::shared_ptr const &reactNativeConfig); private: static ShadowNode::Shared runCommand( const folly::dynamic &command, Tag rootTag, - std::vector &nodes, + std::vector &nodes, std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, - const std::shared_ptr reactNativeConfig); + std::shared_ptr const &reactNativeConfig); }; } // namespace react } // namespace facebook diff --git a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp index add08294321f05..fc672ef606bfb2 100644 --- a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp +++ b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -48,8 +48,7 @@ NativeModuleRegistry buildNativeModuleRegistry(); NativeModuleRegistry buildNativeModuleRegistry() { NativeModuleRegistry nMR; nMR.registerModule( - "MobileConfig", - [&](const std::string &methodName, const folly::dynamic &args) { + "MobileConfig", [&](const std::string &, const folly::dynamic &) { return mockSimpleTestValue_; }); return nMR; @@ -57,20 +56,20 @@ NativeModuleRegistry buildNativeModuleRegistry() { class MockReactNativeConfig : public ReactNativeConfig { public: - MockReactNativeConfig() {} + MockReactNativeConfig() = default; bool getBool(const std::string ¶m) const override { return mockSimpleTestValue_; } - std::string getString(const std::string ¶m) const override { + std::string getString(const std::string &) const override { return ""; } - int64_t getInt64(const std::string ¶m) const override { + int64_t getInt64(const std::string &) const override { return 0; } - double getDouble(const std::string ¶m) const override { + double getDouble(const std::string &) const override { return 0.0; } }; diff --git a/ReactCommon/react/renderer/textlayoutmanager/Android.mk b/ReactCommon/react/renderer/textlayoutmanager/Android.mk deleted file mode 100644 index 0d216e572762ba..00000000000000 --- a/ReactCommon/react/renderer/textlayoutmanager/Android.mk +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_textlayoutmanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/android/react/renderer/textlayoutmanager/*.cpp) - -LOCAL_SHARED_LIBRARIES := libfolly_futures libreactnativeutilsjni libreact_utils libfb libfbjni libreact_render_uimanager libreact_render_componentregistry libreact_render_attributedstring libreact_render_mounting glog libfolly_json libglog_init libyoga libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug libreact_render_mapbuffer libmapbufferjni libreact_render_telemetry - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbjni) -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/utils) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) -$(call import-module,react/renderer/telemetry) diff --git a/ReactCommon/react/renderer/textlayoutmanager/BUCK b/ReactCommon/react/renderer/textlayoutmanager/BUCK index 1e7e142f4cb24b..ae63b1e7a1c127 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/BUCK +++ b/ReactCommon/react/renderer/textlayoutmanager/BUCK @@ -103,7 +103,10 @@ rn_xplat_cxx_library( "platform/ios/**/*.mm", ], ), - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -114,7 +117,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, diff --git a/ReactCommon/react/renderer/textlayoutmanager/CMakeLists.txt b/ReactCommon/react/renderer/textlayoutmanager/CMakeLists.txt new file mode 100644 index 00000000000000..cb12805f3c546d --- /dev/null +++ b/ReactCommon/react/renderer/textlayoutmanager/CMakeLists.txt @@ -0,0 +1,45 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_textlayourmanager_SRC CONFIGURE_DEPENDS + *.cpp + platform/android/react/renderer/textlayoutmanager/*.cpp) + +add_library(react_render_textlayoutmanager + SHARED + ${react_render_textlayourmanager_SRC}) + +target_include_directories(react_render_textlayoutmanager + PUBLIC + ${REACT_COMMON_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/platform/android/ +) + +target_link_libraries(react_render_textlayoutmanager + glog + fb + fbjni + folly_runtime + glog_init + mapbufferjni + react_debug + react_render_attributedstring + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_mapbuffer + react_render_mounting + react_render_telemetry + react_render_uimanager + react_utils + reactnativeutilsjni + yoga +) diff --git a/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.cpp b/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.cpp index 76bbc45c963404..6275bd8c442c9a 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,8 @@ #include "TextMeasureCache.h" +#include + namespace facebook { namespace react { @@ -30,7 +32,7 @@ LineMeasurement::LineMeasurement( Float capHeight, Float ascender, Float xHeight) - : text(text), + : text(std::move(text)), frame(frame), descender(descender), capHeight(capHeight), diff --git a/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h b/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h index d0e71872810d75..013796ba53de4b 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h +++ b/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 439fdb369af70b..c4c5bfce9b1e1d 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,25 +9,157 @@ #include +#include #include #include #include +#include +#include #include -#include using namespace facebook::jni; namespace facebook { namespace react { -TextLayoutManager::~TextLayoutManager() {} +Size measureAndroidComponent( + ContextContainer::Shared const &contextContainer, + Tag rootTag, + std::string const &componentName, + folly::dynamic localData, + folly::dynamic props, + folly::dynamic state, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + jfloatArray attachmentPositions) { + const jni::global_ref &fabricUIManager = + contextContainer->at>("FabricUIManager"); + + static auto measure = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("measure"); + + auto componentNameRef = make_jstring(componentName); + local_ref localDataRNM = + ReadableNativeMap::newObjectCxxArgs(std::move(localData)); + local_ref propsRNM = + ReadableNativeMap::newObjectCxxArgs(std::move(props)); + local_ref stateRNM = + ReadableNativeMap::newObjectCxxArgs(std::move(state)); + + local_ref localDataRM = + make_local(reinterpret_cast(localDataRNM.get())); + local_ref propsRM = + make_local(reinterpret_cast(propsRNM.get())); + local_ref stateRM = + make_local(reinterpret_cast(stateRNM.get())); + + auto size = yogaMeassureToSize(measure( + fabricUIManager, + rootTag, + componentNameRef.get(), + localDataRM.get(), + propsRM.get(), + stateRM.get(), + minWidth, + maxWidth, + minHeight, + maxHeight, + attachmentPositions)); + + // Explicitly release smart pointers to free up space faster in JNI tables + componentNameRef.reset(); + localDataRM.reset(); + localDataRNM.reset(); + propsRM.reset(); + propsRNM.reset(); + stateRM.reset(); + stateRNM.reset(); + + return size; +} + +Size measureAndroidComponentMapBuffer( + const ContextContainer::Shared &contextContainer, + Tag rootTag, + std::string const &componentName, + MapBuffer localData, + MapBuffer props, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + jfloatArray attachmentPositions) { + const jni::global_ref &fabricUIManager = + contextContainer->at>("FabricUIManager"); + auto componentNameRef = make_jstring(componentName); + + static auto measure = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("measureMapBuffer"); + + auto localDataMap = + JReadableMapBuffer::createWithContents(std::move(localData)); + auto propsMap = JReadableMapBuffer::createWithContents(std::move(props)); + + auto size = yogaMeassureToSize(measure( + fabricUIManager, + rootTag, + componentNameRef.get(), + localDataMap.get(), + propsMap.get(), + nullptr, + minWidth, + maxWidth, + minHeight, + maxHeight, + attachmentPositions)); + + // Explicitly release smart pointers to free up space faster in JNI tables + componentNameRef.reset(); + localDataMap.reset(); + propsMap.reset(); + return size; +} + +TextLayoutManager::TextLayoutManager( + const ContextContainer::Shared &contextContainer) + : contextContainer_(contextContainer), + mapBufferSerializationEnabled_( + contextContainer->at("MapBufferSerializationEnabled")), + measureCache_( + contextContainer->at("EnableLargeTextMeasureCache") + ? 1024 + : kSimpleThreadSafeCacheSizeCap) {} void *TextLayoutManager::getNativeTextLayoutManager() const { return self_; } TextMeasurement TextLayoutManager::measure( - AttributedStringBox attributedStringBox, + AttributedStringBox const &attributedStringBox, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { auto &attributedString = attributedStringBox.getValue(); @@ -59,7 +191,7 @@ TextMeasurement TextLayoutManager::measure( TextMeasurement TextLayoutManager::measureCachedSpannableById( int64_t cacheId, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const { auto env = Environment::current(); auto attachmentPositions = env->NewFloatArray(0); @@ -73,7 +205,7 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById( contextContainer_, -1, // TODO: we should pass rootTag in "RCTText", - cacheIdMap, + std::move(cacheIdMap), toDynamic(paragraphAttributes), nullptr, minimumSize.width, @@ -93,8 +225,8 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById( } LinesMeasurements TextLayoutManager::measureLines( - AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + AttributedString const &attributedString, + ParagraphAttributes const ¶graphAttributes, Size size) const { if (mapBufferSerializationEnabled_) { return measureLinesMapBuffer(attributedString, paragraphAttributes, size); @@ -147,23 +279,23 @@ LinesMeasurements TextLayoutManager::measureLines( } LinesMeasurements TextLayoutManager::measureLinesMapBuffer( - AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + AttributedString const &attributedString, + ParagraphAttributes const ¶graphAttributes, Size size) const { const jni::global_ref &fabricUIManager = contextContainer_->at>("FabricUIManager"); static auto measureLines = jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") ->getMethod("measureLinesMapBuffer"); auto attributedStringMB = - ReadableMapBuffer::createWithContents(toMapBuffer(attributedString)); + JReadableMapBuffer::createWithContents(toMapBuffer(attributedString)); auto paragraphAttributesMB = - ReadableMapBuffer::createWithContents(toMapBuffer(paragraphAttributes)); + JReadableMapBuffer::createWithContents(toMapBuffer(paragraphAttributes)); auto array = measureLines( fabricUIManager, @@ -189,12 +321,12 @@ LinesMeasurements TextLayoutManager::measureLinesMapBuffer( TextMeasurement TextLayoutManager::doMeasure( AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const { layoutConstraints.maximumSize.height = std::numeric_limits::infinity(); int attachmentsCount = 0; - for (auto fragment : attributedString.getFragments()) { + for (auto const &fragment : attributedString.getFragments()) { if (fragment.isAttachment()) { attachmentsCount++; } @@ -219,19 +351,21 @@ TextMeasurement TextLayoutManager::doMeasure( maximumSize.height, attachmentPositions); - jfloat *attachmentData = env->GetFloatArrayElements(attachmentPositions, 0); + jfloat *attachmentData = + env->GetFloatArrayElements(attachmentPositions, nullptr); auto attachments = TextMeasurement::Attachments{}; if (attachmentsCount > 0) { - folly::dynamic fragments = serializedAttributedString["fragments"]; + folly::dynamic const &fragments = serializedAttributedString["fragments"]; int attachmentIndex = 0; - for (int i = 0; i < fragments.size(); i++) { - folly::dynamic fragment = fragments[i]; - if (fragment["isAttachment"] == true) { + for (auto const &fragment : fragments) { + auto isAttachment = fragment.find("isAttachment"); + if (isAttachment != fragment.items().end() && + isAttachment->second.getBool()) { float top = attachmentData[attachmentIndex * 2]; float left = attachmentData[attachmentIndex * 2 + 1]; - float width = (float)fragment["width"].getDouble(); - float height = (float)fragment["height"].getDouble(); + auto width = (float)fragment["width"].getDouble(); + auto height = (float)fragment["height"].getDouble(); auto rect = facebook::react::Rect{ {left, top}, facebook::react::Size{width, height}}; @@ -251,12 +385,12 @@ TextMeasurement TextLayoutManager::doMeasure( TextMeasurement TextLayoutManager::doMeasureMapBuffer( AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const { layoutConstraints.maximumSize.height = std::numeric_limits::infinity(); int attachmentsCount = 0; - for (auto fragment : attributedString.getFragments()) { + for (auto const &fragment : attributedString.getFragments()) { if (fragment.isAttachment()) { attachmentsCount++; } @@ -274,20 +408,21 @@ TextMeasurement TextLayoutManager::doMeasureMapBuffer( contextContainer_, -1, // TODO: we should pass rootTag in "RCTText", - attributedStringMap, - paragraphAttributesMap, + std::move(attributedStringMap), + std::move(paragraphAttributesMap), minimumSize.width, maximumSize.width, minimumSize.height, maximumSize.height, attachmentPositions); - jfloat *attachmentData = env->GetFloatArrayElements(attachmentPositions, 0); + jfloat *attachmentData = + env->GetFloatArrayElements(attachmentPositions, nullptr); auto attachments = TextMeasurement::Attachments{}; if (attachmentsCount > 0) { int attachmentIndex = 0; - for (auto fragment : attributedString.getFragments()) { + for (const auto &fragment : attributedString.getFragments()) { if (fragment.isAttachment()) { float top = attachmentData[attachmentIndex * 2]; float left = attachmentData[attachmentIndex * 2 + 1]; diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index 19ae11b2a7d62c..ad3483b3eb8dd1 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,19 +26,25 @@ using SharedTextLayoutManager = std::shared_ptr; */ class TextLayoutManager { public: - TextLayoutManager(const ContextContainer::Shared &contextContainer) - : contextContainer_(contextContainer) { - static auto value = - contextContainer->at("MapBufferSerializationEnabled"); - mapBufferSerializationEnabled_ = value; - } - ~TextLayoutManager(); + TextLayoutManager(const ContextContainer::Shared &contextContainer); + + /* + * Not copyable. + */ + TextLayoutManager(TextLayoutManager const &) = delete; + TextLayoutManager &operator=(TextLayoutManager const &) = delete; + + /* + * Not movable. + */ + TextLayoutManager(TextLayoutManager &&) = delete; + TextLayoutManager &operator=(TextLayoutManager &&) = delete; /* * Measures `attributedString` using native text rendering infrastructure. */ TextMeasurement measure( - AttributedStringBox attributedStringBox, + AttributedStringBox const &attributedStringBox, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const; @@ -48,7 +54,7 @@ class TextLayoutManager { */ TextMeasurement measureCachedSpannableById( int64_t cacheId, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const; /* @@ -56,8 +62,8 @@ class TextLayoutManager { * infrastructure. */ LinesMeasurements measureLines( - AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + AttributedString const &attributedString, + ParagraphAttributes const ¶graphAttributes, Size size) const; /* @@ -69,23 +75,23 @@ class TextLayoutManager { private: TextMeasurement doMeasure( AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const; TextMeasurement doMeasureMapBuffer( AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const; LinesMeasurements measureLinesMapBuffer( - AttributedString attributedString, - ParagraphAttributes paragraphAttributes, + AttributedString const &attributedString, + ParagraphAttributes const ¶graphAttributes, Size size) const; void *self_; ContextContainer::Shared contextContainer_; bool mapBufferSerializationEnabled_; - TextMeasureCache measureCache_{}; + TextMeasureCache measureCache_; }; } // namespace react diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp index 6d7f07ea6d1edb..e0214a6dab088f 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,8 +10,6 @@ namespace facebook { namespace react { -TextLayoutManager::~TextLayoutManager() {} - void *TextLayoutManager::getNativeTextLayoutManager() const { return (void *)this; } diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h index 87c6fdf4bfeca7..25233cabea2278 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/TextLayoutManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,7 +29,6 @@ using SharedTextLayoutManager = std::shared_ptr; class TextLayoutManager { public: TextLayoutManager(const ContextContainer::Shared &contextContainer) {} - ~TextLayoutManager(); /* * Measures `attributedStringBox` using native text rendering infrastructure. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.h index 61b1634f435cad..a87d67d192305c 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.m b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.m index 3a39ca20f62a09..4c4cb670f48f68 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.m +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h index 3a8ff540741bbb..b09fd7115ebe65 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm index c92dee1a17d519..0a5828ab7f5dbd 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -62,13 +62,13 @@ inline static UIFontWeight RCTUIFontWeightFromInteger(NSInteger fontWeight) RCTFontProperties fontProperties; fontProperties.family = fontFamily; fontProperties.size = textAttributes.fontSize; - fontProperties.style = textAttributes.fontStyle.hasValue() + fontProperties.style = textAttributes.fontStyle.has_value() ? RCTFontStyleFromFontStyle(textAttributes.fontStyle.value()) : RCTFontStyleUndefined; - fontProperties.variant = textAttributes.fontVariant.hasValue() + fontProperties.variant = textAttributes.fontVariant.has_value() ? RCTFontVariantFromFontVariant(textAttributes.fontVariant.value()) : RCTFontVariantUndefined; - fontProperties.weight = textAttributes.fontWeight.hasValue() + fontProperties.weight = textAttributes.fontWeight.has_value() ? RCTUIFontWeightFromInteger((NSInteger)textAttributes.fontWeight.value()) : NAN; fontProperties.sizeMultiplier = textAttributes.fontSizeMultiplier; @@ -136,7 +136,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex // Paragraph Style NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; BOOL isParagraphStyleUsed = NO; - if (textAttributes.alignment.hasValue()) { + if (textAttributes.alignment.has_value()) { TextAlignment textAlignment = textAttributes.alignment.value_or(TextAlignment::Natural); if (textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight) == LayoutDirection::RightToLeft) { if (textAlignment == TextAlignment::Right) { @@ -150,7 +150,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex isParagraphStyleUsed = YES; } - if (textAttributes.baseWritingDirection.hasValue()) { + if (textAttributes.baseWritingDirection.has_value()) { paragraphStyle.baseWritingDirection = RCTNSWritingDirectionFromWritingDirection(textAttributes.baseWritingDirection.value()); isParagraphStyleUsed = YES; @@ -198,7 +198,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex } // Shadow - if (textAttributes.textShadowOffset.hasValue()) { + if (textAttributes.textShadowOffset.has_value()) { auto textShadowOffset = textAttributes.textShadowOffset.value(); NSShadow *shadow = [NSShadow new]; shadow.shadowOffset = CGSize{textShadowOffset.width, textShadowOffset.height}; @@ -212,7 +212,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES; } - if (textAttributes.accessibilityRole.hasValue()) { + if (textAttributes.accessibilityRole.has_value()) { auto accessibilityRole = textAttributes.accessibilityRole.value(); switch (accessibilityRole) { case AccessibilityRole::None: @@ -334,7 +334,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex } else { NSString *string = [NSString stringWithCString:fragment.string.c_str() encoding:NSUTF8StringEncoding]; - if (fragment.textAttributes.textTransform.hasValue()) { + if (fragment.textAttributes.textTransform.has_value()) { auto textTransform = fragment.textAttributes.textTransform.value(); string = RCTNSStringFromStringApplyingTextTransform(string, textTransform); } @@ -378,6 +378,23 @@ AttributedStringBox RCTAttributedStringBoxFromNSAttributedString(NSAttributedStr return nsAttributedString.length ? AttributedStringBox{wrapManagedObject(nsAttributedString)} : AttributedStringBox{}; } +static NSString *capitalizeText(NSString *text) +{ + 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 *RCTNSStringFromStringApplyingTextTransform(NSString *string, TextTransform textTransform) { switch (textTransform) { @@ -386,7 +403,7 @@ AttributedStringBox RCTAttributedStringBoxFromNSAttributedString(NSAttributedStr case TextTransform::Lowercase: return [string lowercaseString]; case TextTransform::Capitalize: - return [string capitalizedString]; + return capitalizeText(string); default: return string; } diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontProperties.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontProperties.h index 3136b6dd5373d2..eca30e5046838a 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontProperties.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontProperties.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.h index eafaa4e6f086db..ad4d7af3dd926e 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.mm index a869b66505e53d..4f8d5aa0703293 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.h index e37bef5ca59bc2..15e4c755abc732 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm index 3cd00abda54dac..844fcb228510a2 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h index 9788d8ebb00c23..235137bde0c13a 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.h index d23a8f9545a322..ec101a3cb20a2e 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,15 +20,11 @@ namespace react { class TextLayoutManager; -using SharedTextLayoutManager = std::shared_ptr; - /* * Cross platform facade for iOS-specific RCTTTextLayoutManager. */ class TextLayoutManager { public: - using Shared = std::shared_ptr; - TextLayoutManager(ContextContainer::Shared const &contextContainer); /* diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.mm index 887f3726bac397..74e905bbecd03f 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/TextLayoutManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp b/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp index ab4974c763144d..40258861855b6a 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/BUCK b/ReactCommon/react/renderer/timeline/BUCK index a8888cb22f7c3a..a5d5e7f7983993 100644 --- a/ReactCommon/react/renderer/timeline/BUCK +++ b/ReactCommon/react/renderer/timeline/BUCK @@ -46,7 +46,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", react_native_xplat_target("react/utils:utils"), diff --git a/ReactCommon/react/renderer/timeline/Timeline.cpp b/ReactCommon/react/renderer/timeline/Timeline.cpp index 11dd457d8888a1..ea569370e8d2aa 100644 --- a/ReactCommon/react/renderer/timeline/Timeline.cpp +++ b/ReactCommon/react/renderer/timeline/Timeline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/Timeline.h b/ReactCommon/react/renderer/timeline/Timeline.h index 8eaaf226776731..cc7e1b4bac920c 100644 --- a/ReactCommon/react/renderer/timeline/Timeline.h +++ b/ReactCommon/react/renderer/timeline/Timeline.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/ReactCommon/react/renderer/timeline/TimelineController.cpp b/ReactCommon/react/renderer/timeline/TimelineController.cpp index 153650ae092f3d..01e716741f76a9 100644 --- a/ReactCommon/react/renderer/timeline/TimelineController.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,7 +25,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const { assert(shadowTreePtr); { - std::unique_lock lock(timelinesMutex_); + std::unique_lock lock(timelinesMutex_); auto timeline = std::make_unique(*shadowTreePtr); auto handler = TimelineHandler{*timeline}; @@ -35,7 +35,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const { } void TimelineController::disable(TimelineHandler &&handler) const { - std::unique_lock lock(timelinesMutex_); + std::unique_lock lock(timelinesMutex_); auto iterator = timelines_.find(handler.getSurfaceId()); assert(iterator != timelines_.end()); @@ -57,7 +57,7 @@ RootShadowNode::Unshared TimelineController::shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const noexcept { - std::shared_lock lock(timelinesMutex_); + std::shared_lock lock(timelinesMutex_); assert(uiManager_ && "`uiManager_` must not be `nullptr`."); diff --git a/ReactCommon/react/renderer/timeline/TimelineController.h b/ReactCommon/react/renderer/timeline/TimelineController.h index 0cfed408e7c79b..997fb025a1a043 100644 --- a/ReactCommon/react/renderer/timeline/TimelineController.h +++ b/ReactCommon/react/renderer/timeline/TimelineController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,7 +9,7 @@ #include -#include +#include #include #include @@ -65,12 +65,12 @@ class TimelineController final : public UIManagerCommitHook { /* * Protects all the data members. */ - mutable better::shared_mutex timelinesMutex_; + mutable butter::shared_mutex timelinesMutex_; /* * Owning collection of all running `Timeline` instances. */ - mutable better::map> timelines_; + mutable butter::map> timelines_; mutable UIManager const *uiManager_; mutable SurfaceId lastUpdatedSurface_; diff --git a/ReactCommon/react/renderer/timeline/TimelineFrame.cpp b/ReactCommon/react/renderer/timeline/TimelineFrame.cpp index 6b6f7883021fff..b23e160cce1591 100644 --- a/ReactCommon/react/renderer/timeline/TimelineFrame.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/TimelineFrame.h b/ReactCommon/react/renderer/timeline/TimelineFrame.h index a6374cb509a61a..0dfb2ed9e71ddd 100644 --- a/ReactCommon/react/renderer/timeline/TimelineFrame.h +++ b/ReactCommon/react/renderer/timeline/TimelineFrame.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp index 953e305d80b84a..3deef099f739be 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.h b/ReactCommon/react/renderer/timeline/TimelineHandler.h index 3065eefa7fec01..61fa45f3ce8aa1 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.h +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/timeline/TimelineSnapshot.cpp b/ReactCommon/react/renderer/timeline/TimelineSnapshot.cpp index fd460b1ef22f2b..08d40bd1214c87 100644 --- a/ReactCommon/react/renderer/timeline/TimelineSnapshot.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineSnapshot.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,13 +9,15 @@ #include +#include + namespace facebook { namespace react { TimelineSnapshot::TimelineSnapshot( - RootShadowNode::Shared const &rootShadowNode, + RootShadowNode::Shared rootShadowNode, int index) noexcept - : rootShadowNode_(rootShadowNode), + : rootShadowNode_(std::move(rootShadowNode)), frame_(TimelineFrame{index, telemetryTimePointNow()}) {} RootShadowNode::Shared TimelineSnapshot::getRootShadowNode() const noexcept { diff --git a/ReactCommon/react/renderer/timeline/TimelineSnapshot.h b/ReactCommon/react/renderer/timeline/TimelineSnapshot.h index 59d022b3f18d6f..0b293f32136548 100644 --- a/ReactCommon/react/renderer/timeline/TimelineSnapshot.h +++ b/ReactCommon/react/renderer/timeline/TimelineSnapshot.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,9 +20,7 @@ class TimelineSnapshot final { public: using List = std::vector; - TimelineSnapshot( - RootShadowNode::Shared const &rootShadowNode, - int index) noexcept; + TimelineSnapshot(RootShadowNode::Shared rootShadowNode, int index) noexcept; TimelineFrame getFrame() const noexcept; RootShadowNode::Shared getRootShadowNode() const noexcept; diff --git a/ReactCommon/react/renderer/uimanager/Android.mk b/ReactCommon/react/renderer/uimanager/Android.mk deleted file mode 100644 index 47975cd7dad251..00000000000000 --- a/ReactCommon/react/renderer/uimanager/Android.mk +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_uimanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := libreact_render_graphics libfolly_futures libruntimeexecutor libreact_render_componentregistry glog libreactconfig libfolly_json libjsi libreact_render_core libreact_render_debug librrc_view librrc_root libreact_render_mounting libreact_debug libreact_render_leakchecker - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/leakchecker) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/debug) -$(call import-module,runtimeexecutor) diff --git a/ReactCommon/react/renderer/uimanager/BUCK b/ReactCommon/react/renderer/uimanager/BUCK index d518a76c385a05..b701dbdb57e2f5 100644 --- a/ReactCommon/react/renderer/uimanager/BUCK +++ b/ReactCommon/react/renderer/uimanager/BUCK @@ -34,7 +34,10 @@ rn_xplat_cxx_library( fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -46,7 +49,7 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:JSIDynamic", @@ -60,6 +63,7 @@ rn_xplat_cxx_library( react_native_xplat_target("react/renderer/componentregistry:componentregistry"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("runtimeexecutor:runtimeexecutor"), + react_native_xplat_target("react/renderer/runtimescheduler:runtimescheduler"), ], ) diff --git a/ReactCommon/react/renderer/uimanager/CMakeLists.txt b/ReactCommon/react/renderer/uimanager/CMakeLists.txt new file mode 100644 index 00000000000000..0d9f7403b05b8c --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/CMakeLists.txt @@ -0,0 +1,32 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_uimanager_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_uimanager SHARED ${react_render_uimanager_SRC}) + +target_include_directories(react_render_uimanager PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_uimanager + glog + folly_runtime + jsi + react_debug + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_leakchecker + react_render_runtimescheduler + react_render_mounting + react_config + rrc_root + rrc_view + runtimeexecutor +) diff --git a/ReactCommon/react/renderer/uimanager/LayoutAnimationStatusDelegate.h b/ReactCommon/react/renderer/uimanager/LayoutAnimationStatusDelegate.h index cad196eb98230a..821cb2531a57e1 100644 --- a/ReactCommon/react/renderer/uimanager/LayoutAnimationStatusDelegate.h +++ b/ReactCommon/react/renderer/uimanager/LayoutAnimationStatusDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -23,6 +23,8 @@ class LayoutAnimationStatusDelegate { * Called when the LayoutAnimation engine completes all pending animations. */ virtual void onAllAnimationsComplete() = 0; + + virtual ~LayoutAnimationStatusDelegate() = default; }; } // namespace facebook::react diff --git a/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp b/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp new file mode 100644 index 00000000000000..e65992faacb648 --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp @@ -0,0 +1,147 @@ +/* + * 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. + */ + +#include "SurfaceRegistryBinding.h" +#include +#include +#include +#include "bindingUtils.h" + +namespace facebook::react { + +void SurfaceRegistryBinding::startSurface( + jsi::Runtime &runtime, + SurfaceId surfaceId, + std::string const &moduleName, + folly::dynamic const &initalProps, + DisplayMode displayMode) { + SystraceSection s("SurfaceRegistryBinding::startSurface"); + folly::dynamic parameters = folly::dynamic::object(); + parameters["rootTag"] = surfaceId; + parameters["initialProps"] = initalProps; + parameters["fabric"] = true; + + auto global = runtime.global(); + auto isBridgeless = global.hasProperty(runtime, "RN$Bridgeless") && + global.getProperty(runtime, "RN$Bridgeless").asBool(); + + if (isBridgeless) { + if (!global.hasProperty(runtime, "RN$SurfaceRegistry")) { + throw std::runtime_error( + "SurfaceRegistryBinding::startSurface: Failed to start Surface \"" + + moduleName + "\". global.RN$SurfaceRegistry was not installed."); + } + + auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry"); + auto method = registry.getPropertyAsFunction(runtime, "renderSurface"); + method.call( + runtime, + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } else { + if (moduleName != "LogBox" && + global.hasProperty(runtime, "RN$SurfaceRegistry")) { + auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry"); + auto method = registry.getPropertyAsFunction(runtime, "renderSurface"); + + method.call( + runtime, + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } else { + callMethodOfModule( + runtime, + "AppRegistry", + "runApplication", + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } + } +} + +void SurfaceRegistryBinding::setSurfaceProps( + jsi::Runtime &runtime, + SurfaceId surfaceId, + std::string const &moduleName, + folly::dynamic const &initalProps, + DisplayMode displayMode) { + SystraceSection s("UIManagerBinding::setSurfaceProps"); + folly::dynamic parameters = folly::dynamic::object(); + parameters["rootTag"] = surfaceId; + parameters["initialProps"] = initalProps; + parameters["fabric"] = true; + + auto global = runtime.global(); + auto isBridgeless = global.hasProperty(runtime, "RN$Bridgeless") && + global.getProperty(runtime, "RN$Bridgeless").asBool(); + + if (isBridgeless) { + if (!global.hasProperty(runtime, "RN$SurfaceRegistry")) { + throw std::runtime_error( + "SurfaceRegistryBinding::setSurfaceProps: Failed to set Surface props for \"" + + moduleName + "\". global.RN$SurfaceRegistry was not installed."); + } + + auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry"); + auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps"); + + method.call( + runtime, + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } else { + if (moduleName != "LogBox" && + global.hasProperty(runtime, "RN$SurfaceRegistry")) { + auto registry = global.getPropertyAsObject(runtime, "RN$SurfaceRegistry"); + auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps"); + + method.call( + runtime, + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } else { + callMethodOfModule( + runtime, + "AppRegistry", + "setSurfaceProps", + {jsi::String::createFromUtf8(runtime, moduleName), + jsi::valueFromDynamic(runtime, parameters), + jsi::Value(runtime, displayModeToInt(displayMode))}); + } + } +} + +void SurfaceRegistryBinding::stopSurface( + jsi::Runtime &runtime, + SurfaceId surfaceId) { + auto global = runtime.global(); + auto isBridgeless = global.hasProperty(runtime, "RN$Bridgeless") && + global.getProperty(runtime, "RN$Bridgeless").asBool(); + + if (isBridgeless) { + if (!global.hasProperty(runtime, "RN$stopSurface")) { + // ReactFabric module has not been loaded yet; there's no surface to stop. + return; + } + // Bridgeless mode uses a custom JSI binding instead of callable module. + global.getPropertyAsFunction(runtime, "RN$stopSurface") + .call(runtime, {jsi::Value{surfaceId}}); + } else { + callMethodOfModule( + runtime, + "ReactFabric", + "unmountComponentAtNode", + {jsi::Value{surfaceId}}); + } +} + +} // namespace facebook::react diff --git a/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h b/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h new file mode 100644 index 00000000000000..b688b0f61b04c6 --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook::react { + +class SurfaceRegistryBinding final { + public: + SurfaceRegistryBinding() = delete; + + /* + * Starts React Native Surface with given id, moduleName, and props. + * Thread synchronization must be enforced externally. + */ + static void startSurface( + jsi::Runtime &runtime, + SurfaceId surfaceId, + std::string const &moduleName, + folly::dynamic const &initalProps, + DisplayMode displayMode); + + /* + * Updates the React Native Surface identified with surfaceId and moduleName + * with the given props. + * Thread synchronization must be enforced externally. + */ + static void setSurfaceProps( + jsi::Runtime &runtime, + SurfaceId surfaceId, + std::string const &moduleName, + folly::dynamic const &initalProps, + DisplayMode displayMode); + + /* + * Stops React Native Surface with given id. + * Thread synchronization must be enforced externally. + */ + static void stopSurface(jsi::Runtime &runtime, SurfaceId surfaceId); +}; + +} // namespace facebook::react diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 56bb2bad80afaa..cd2d3267dafae3 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,13 +12,23 @@ #include #include #include +#include #include #include #include +#include + namespace facebook::react { +// Explicitly define destructors here, as they to exist in order to act as a +// "key function" for the ShadowNodeWrapper class -- this allow for RTTI to work +// properly across dynamic library boundaries (i.e. dynamic_cast that is used by +// isHostObject method) +ShadowNodeWrapper::~ShadowNodeWrapper() = default; +ShadowNodeListWrapper::~ShadowNodeListWrapper() = default; + static std::unique_ptr constructLeakCheckerIfNeeded( RuntimeExecutor const &runtimeExecutor) { #ifdef REACT_NATIVE_DEBUG @@ -30,11 +40,11 @@ static std::unique_ptr constructLeakCheckerIfNeeded( UIManager::UIManager( RuntimeExecutor const &runtimeExecutor, - BackgroundExecutor const &backgroundExecutor, + BackgroundExecutor backgroundExecutor, ContextContainer::Shared contextContainer) : runtimeExecutor_(runtimeExecutor), - backgroundExecutor_(backgroundExecutor), - contextContainer_(contextContainer), + backgroundExecutor_(std::move(backgroundExecutor)), + contextContainer_(std::move(contextContainer)), leakChecker_(constructLeakCheckerIfNeeded(runtimeExecutor)) {} UIManager::~UIManager() { @@ -42,7 +52,7 @@ UIManager::~UIManager() { << ")."; } -SharedShadowNode UIManager::createNode( +ShadowNode::Shared UIManager::createNode( Tag tag, std::string const &name, SurfaceId surfaceId, @@ -81,7 +91,7 @@ SharedShadowNode UIManager::createNode( family); if (delegate_) { - delegate_->uiManagerDidCreateShadowNode(*shadowNode.get()); + delegate_->uiManagerDidCreateShadowNode(*shadowNode); } if (leakChecker_) { leakChecker_->uiManagerDidCreateShadowNodeFamily(family); @@ -90,29 +100,28 @@ SharedShadowNode UIManager::createNode( return shadowNode; } -SharedShadowNode UIManager::cloneNode( - const ShadowNode::Shared &shadowNode, - const SharedShadowNodeSharedList &children, - const RawProps *rawProps) const { +ShadowNode::Shared UIManager::cloneNode( + ShadowNode const &shadowNode, + ShadowNode::SharedListOfShared const &children, + RawProps const *rawProps) const { SystraceSection s("UIManager::cloneNode"); PropsParserContext propsParserContext{ - shadowNode->getFamily().getSurfaceId(), *contextContainer_.get()}; + shadowNode.getFamily().getSurfaceId(), *contextContainer_.get()}; - auto &componentDescriptor = shadowNode->getComponentDescriptor(); + auto &componentDescriptor = shadowNode.getComponentDescriptor(); auto clonedShadowNode = componentDescriptor.cloneShadowNode( - *shadowNode, + shadowNode, { /* .props = */ rawProps ? componentDescriptor.cloneProps( - propsParserContext, shadowNode->getProps(), *rawProps) + propsParserContext, shadowNode.getProps(), *rawProps) : ShadowNodeFragment::propsPlaceholder(), /* .children = */ children, }); if (delegate_) { - delegate_->uiManagerDidCloneShadowNode( - *shadowNode.get(), *clonedShadowNode.get()); + delegate_->uiManagerDidCloneShadowNode(shadowNode, *clonedShadowNode); } return clonedShadowNode; @@ -129,7 +138,7 @@ void UIManager::appendChild( void UIManager::completeSurface( SurfaceId surfaceId, - SharedShadowNodeUnsharedList const &rootChildren, + ShadowNode::UnsharedListOfShared const &rootChildren, ShadowTree::CommitOptions commitOptions) const { SystraceSection s("UIManager::completeSurface"); @@ -169,12 +178,7 @@ void UIManager::startSurface( runtimeExecutor_([=](jsi::Runtime &runtime) { SystraceSection s("UIManager::startSurface::onRuntime"); - auto uiManagerBinding = UIManagerBinding::getBinding(runtime); - if (!uiManagerBinding) { - return; - } - - uiManagerBinding->startSurface( + SurfaceRegistryBinding::startSurface( runtime, surfaceId, moduleName, props, displayMode); }); } @@ -187,12 +191,7 @@ void UIManager::setSurfaceProps( SystraceSection s("UIManager::setSurfaceProps"); runtimeExecutor_([=](jsi::Runtime &runtime) { - auto uiManagerBinding = UIManagerBinding::getBinding(runtime); - if (!uiManagerBinding) { - return; - } - - uiManagerBinding->setSurfaceProps( + SurfaceRegistryBinding::setSurfaceProps( runtime, surfaceId, moduleName, props, displayMode); }); } @@ -212,12 +211,7 @@ ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const { // the JavaScript side will not be able to reference a `ShadowTree` and will // fail silently. runtimeExecutor_([=](jsi::Runtime &runtime) { - auto uiManagerBinding = UIManagerBinding::getBinding(runtime); - if (!uiManagerBinding) { - return; - } - - uiManagerBinding->stopSurface(runtime, surfaceId); + SurfaceRegistryBinding::stopSurface(runtime, surfaceId); }); if (leakChecker_) { @@ -333,7 +327,7 @@ void UIManager::updateState(StateUpdate const &stateUpdate) const { void UIManager::dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) const { + folly::dynamic const &args) const { if (delegate_) { delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args); } @@ -375,7 +369,8 @@ UIManagerDelegate *UIManager::getDelegate() { } void UIManager::visitBinding( - std::function callback, + std::function const + &callback, jsi::Runtime &runtime) const { auto uiManagerBinding = UIManagerBinding::getBinding(runtime); if (uiManagerBinding) { @@ -389,7 +384,7 @@ ShadowTreeRegistry const &UIManager::getShadowTreeRegistry() const { void UIManager::registerCommitHook( UIManagerCommitHook const &commitHook) const { - std::unique_lock lock(commitHookMutex_); + std::unique_lock lock(commitHookMutex_); react_native_assert( std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook) == commitHooks_.end()); @@ -399,7 +394,7 @@ void UIManager::registerCommitHook( void UIManager::unregisterCommitHook( UIManagerCommitHook const &commitHook) const { - std::unique_lock lock(commitHookMutex_); + std::unique_lock lock(commitHookMutex_); auto iterator = std::find(commitHooks_.begin(), commitHooks_.end(), &commitHook); react_native_assert(iterator != commitHooks_.end()); @@ -413,7 +408,7 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const { - std::shared_lock lock(commitHookMutex_); + std::shared_lock lock(commitHookMutex_); auto resultRootShadowNode = newRootShadowNode; for (auto const *commitHook : commitHooks_) { @@ -446,13 +441,12 @@ void UIManager::stopSurfaceForAnimationDelegate(SurfaceId surfaceId) const { } } -void UIManager::animationTick() { +void UIManager::animationTick() const { if (animationDelegate_ != nullptr && animationDelegate_->shouldAnimateFrame()) { - shadowTreeRegistry_.enumerate( - [&](ShadowTree const &shadowTree, bool &stop) { - shadowTree.notifyDelegatesOfUpdates(); - }); + shadowTreeRegistry_.enumerate([](ShadowTree const &shadowTree) { + shadowTree.notifyDelegatesOfUpdates(); + }); } } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index e24434cc9bcc7c..a30a594becfba9 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -34,7 +34,7 @@ class UIManager final : public ShadowTreeDelegate { public: UIManager( RuntimeExecutor const &runtimeExecutor, - BackgroundExecutor const &backgroundExecutor, + BackgroundExecutor backgroundExecutor, ContextContainer::Shared contextContainer); ~UIManager(); @@ -62,7 +62,7 @@ class UIManager final : public ShadowTreeDelegate { */ void stopSurfaceForAnimationDelegate(SurfaceId surfaceId) const; - void animationTick(); + void animationTick() const; /* * Provides access to a UIManagerBindging. @@ -71,7 +71,8 @@ class UIManager final : public ShadowTreeDelegate { * The callback is called synchronously on the same thread. */ void visitBinding( - std::function callback, + std::function const + &callback, jsi::Runtime &runtime) const; /* @@ -110,14 +111,6 @@ class UIManager final : public ShadowTreeDelegate { RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const override; - private: - friend class UIManagerBinding; - friend class Scheduler; - friend class SurfaceHandler; - - // `TimelineController` needs to call private `getShadowTreeRegistry()`. - friend class TimelineController; - ShadowNode::Shared createNode( Tag tag, std::string const &componentName, @@ -126,9 +119,9 @@ class UIManager final : public ShadowTreeDelegate { SharedEventTarget eventTarget) const; ShadowNode::Shared cloneNode( - const ShadowNode::Shared &shadowNode, - const SharedShadowNodeSharedList &children = nullptr, - const RawProps *rawProps = nullptr) const; + ShadowNode const &shadowNode, + ShadowNode::SharedListOfShared const &children = nullptr, + RawProps const *rawProps = nullptr) const; void appendChild( const ShadowNode::Shared &parentShadowNode, @@ -136,7 +129,7 @@ class UIManager final : public ShadowTreeDelegate { void completeSurface( SurfaceId surfaceId, - SharedShadowNodeUnsharedList const &rootChildren, + ShadowNode::UnsharedListOfShared const &rootChildren, ShadowTree::CommitOptions commitOptions) const; void setIsJSResponder( @@ -167,12 +160,19 @@ class UIManager final : public ShadowTreeDelegate { void dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) const; + folly::dynamic const &args) const; void sendAccessibilityEvent( const ShadowNode::Shared &shadowNode, std::string const &eventType); + ShadowTreeRegistry const &getShadowTreeRegistry() const; + + private: + friend class UIManagerBinding; + friend class Scheduler; + friend class SurfaceHandler; + /** * Configure a LayoutAnimation to happen on the next commit. * This API configures a global LayoutAnimation starting from the root node. @@ -183,8 +183,6 @@ class UIManager final : public ShadowTreeDelegate { jsi::Value const &successCallback, jsi::Value const &failureCallback) const; - ShadowTreeRegistry const &getShadowTreeRegistry() const; - SharedComponentDescriptorRegistry componentDescriptorRegistry_; UIManagerDelegate *delegate_; UIManagerAnimationDelegate *animationDelegate_{nullptr}; @@ -193,7 +191,7 @@ class UIManager final : public ShadowTreeDelegate { BackgroundExecutor const backgroundExecutor_{}; ContextContainer::Shared contextContainer_; - mutable better::shared_mutex commitHookMutex_; + mutable butter::shared_mutex commitHookMutex_; mutable std::vector commitHooks_; std::unique_ptr leakChecker_; diff --git a/ReactCommon/react/renderer/uimanager/UIManagerAnimationDelegate.h b/ReactCommon/react/renderer/uimanager/UIManagerAnimationDelegate.h index dc4417df99a137..d20f43c235065a 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerAnimationDelegate.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerAnimationDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index cbc68035ad826e..9393ba512f6781 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,54 +12,19 @@ #include #include #include +#include #include -namespace facebook::react { - -static jsi::Value getModule( - jsi::Runtime &runtime, - std::string const &moduleName) { - auto batchedBridge = - runtime.global().getPropertyAsObject(runtime, "__fbBatchedBridge"); - auto getCallableModule = - batchedBridge.getPropertyAsFunction(runtime, "getCallableModule"); - auto moduleAsValue = getCallableModule.callWithThis( - runtime, - batchedBridge, - {jsi::String::createFromUtf8(runtime, moduleName)}); - if (!moduleAsValue.isObject()) { - LOG(ERROR) << "getModule of " << moduleName << " is not an object"; - } - react_native_assert(moduleAsValue.isObject()); - return moduleAsValue; -} +#include -static bool checkBatchedBridgeIsActive(jsi::Runtime &runtime) { - if (!runtime.global().hasProperty(runtime, "__fbBatchedBridge")) { - LOG(ERROR) - << "getPropertyAsObject: property '__fbBatchedBridge' is undefined, expected an Object"; - return false; - } - return true; -} +#include "bindingUtils.h" -static bool checkGetCallableModuleIsActive(jsi::Runtime &runtime) { - if (!checkBatchedBridgeIsActive(runtime)) { - return false; - } - auto batchedBridge = - runtime.global().getPropertyAsObject(runtime, "__fbBatchedBridge"); - if (!batchedBridge.hasProperty(runtime, "getCallableModule")) { - LOG(ERROR) - << "getPropertyAsFunction: function 'getCallableModule' is undefined, expected a Function"; - return false; - } - return true; -} +namespace facebook::react { -std::shared_ptr UIManagerBinding::createAndInstallIfNeeded( +void UIManagerBinding::createAndInstallIfNeeded( jsi::Runtime &runtime, - RuntimeExecutor const &runtimeExecutor) { + RuntimeExecutor const &runtimeExecutor, + std::shared_ptr const &uiManager) { auto uiManagerModuleName = "nativeFabricUIManager"; auto uiManagerValue = @@ -67,17 +32,12 @@ std::shared_ptr UIManagerBinding::createAndInstallIfNeeded( if (uiManagerValue.isUndefined()) { // The global namespace does not have an instance of the binding; // we need to create, install and return it. - auto uiManagerBinding = std::make_shared(runtimeExecutor); + auto uiManagerBinding = + std::make_shared(uiManager, runtimeExecutor); auto object = jsi::Object::createFromHostObject(runtime, uiManagerBinding); runtime.global().setProperty( runtime, uiManagerModuleName, std::move(object)); - return uiManagerBinding; } - - // The global namespace already has an instance of the binding; - // we need to return that. - auto uiManagerObject = uiManagerValue.asObject(runtime); - return uiManagerObject.getHostObject(runtime); } std::shared_ptr UIManagerBinding::getBinding( @@ -94,41 +54,17 @@ std::shared_ptr UIManagerBinding::getBinding( return uiManagerObject.getHostObject(runtime); } -UIManagerBinding::UIManagerBinding(RuntimeExecutor const &runtimeExecutor) - : runtimeExecutor_(runtimeExecutor) {} +UIManagerBinding::UIManagerBinding( + std::shared_ptr uiManager, + RuntimeExecutor runtimeExecutor) + : uiManager_(std::move(uiManager)), + runtimeExecutor_(std::move(runtimeExecutor)) {} UIManagerBinding::~UIManagerBinding() { LOG(WARNING) << "UIManagerBinding::~UIManagerBinding() was called (address: " << this << ")."; } -void UIManagerBinding::attach(std::shared_ptr const &uiManager) { - uiManager_ = uiManager; -} - -static jsi::Value callMethodOfModule( - jsi::Runtime &runtime, - std::string const &moduleName, - std::string const &methodName, - std::initializer_list args) { - if (checkGetCallableModuleIsActive(runtime)) { - auto module = getModule(runtime, moduleName.c_str()); - if (module.isObject()) { - jsi::Object object = module.asObject(runtime); - react_native_assert(object.hasProperty(runtime, methodName.c_str())); - if (object.hasProperty(runtime, methodName.c_str())) { - auto method = object.getPropertyAsFunction(runtime, methodName.c_str()); - return method.callWithThis(runtime, object, args); - } else { - LOG(ERROR) << "getPropertyAsFunction: property '" << methodName - << "' is undefined, expected a Function"; - } - } - } - - return jsi::Value::undefined(); -} - jsi::Value UIManagerBinding::getInspectorDataForInstance( jsi::Runtime &runtime, EventEmitter const &eventEmitter) const { @@ -156,101 +92,13 @@ jsi::Value UIManagerBinding::getInspectorDataForInstance( {std::move(instanceHandle)}); } -void UIManagerBinding::startSurface( - jsi::Runtime &runtime, - SurfaceId surfaceId, - std::string const &moduleName, - folly::dynamic const &initalProps, - DisplayMode displayMode) const { - SystraceSection s("UIManagerBinding::startSurface"); - folly::dynamic parameters = folly::dynamic::object(); - parameters["rootTag"] = surfaceId; - parameters["initialProps"] = initalProps; - parameters["fabric"] = true; - - if (moduleName.compare("LogBox") != 0 && - runtime.global().hasProperty(runtime, "RN$SurfaceRegistry")) { - auto registry = - runtime.global().getPropertyAsObject(runtime, "RN$SurfaceRegistry"); - auto method = registry.getPropertyAsFunction(runtime, "renderSurface"); - - method.call( - runtime, - {jsi::String::createFromUtf8(runtime, moduleName), - jsi::valueFromDynamic(runtime, parameters), - jsi::Value(runtime, displayModeToInt(displayMode))}); - } else { - callMethodOfModule( - runtime, - "AppRegistry", - "runApplication", - {jsi::String::createFromUtf8(runtime, moduleName), - jsi::valueFromDynamic(runtime, parameters), - jsi::Value(runtime, displayModeToInt(displayMode))}); - } -} - -void UIManagerBinding::setSurfaceProps( - jsi::Runtime &runtime, - SurfaceId surfaceId, - std::string const &moduleName, - folly::dynamic const &initalProps, - DisplayMode displayMode) const { - SystraceSection s("UIManagerBinding::setSurfaceProps"); - folly::dynamic parameters = folly::dynamic::object(); - parameters["rootTag"] = surfaceId; - parameters["initialProps"] = initalProps; - parameters["fabric"] = true; - - if (moduleName.compare("LogBox") != 0 && - runtime.global().hasProperty(runtime, "RN$SurfaceRegistry")) { - auto registry = - runtime.global().getPropertyAsObject(runtime, "RN$SurfaceRegistry"); - auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps"); - - method.call( - runtime, - {jsi::String::createFromUtf8(runtime, moduleName), - jsi::valueFromDynamic(runtime, parameters), - jsi::Value(runtime, displayModeToInt(displayMode))}); - } else { - callMethodOfModule( - runtime, - "AppRegistry", - "setSurfaceProps", - {jsi::String::createFromUtf8(runtime, moduleName), - jsi::valueFromDynamic(runtime, parameters), - jsi::Value(runtime, displayModeToInt(displayMode))}); - } -} - -void UIManagerBinding::stopSurface(jsi::Runtime &runtime, SurfaceId surfaceId) - const { - auto global = runtime.global(); - if (global.hasProperty(runtime, "RN$Bridgeless")) { - if (!global.hasProperty(runtime, "RN$stopSurface")) { - // ReactFabric module has not been loaded yet; there's no surface to stop. - return; - } - // Bridgeless mode uses a custom JSI binding instead of callable module. - global.getPropertyAsFunction(runtime, "RN$stopSurface") - .call(runtime, {jsi::Value{surfaceId}}); - } else { - callMethodOfModule( - runtime, - "ReactFabric", - "unmountComponentAtNode", - {jsi::Value{surfaceId}}); - } -} - void UIManagerBinding::dispatchEvent( jsi::Runtime &runtime, EventTarget const *eventTarget, std::string const &type, ReactEventPriority priority, ValueFactory const &payloadFactory) const { - SystraceSection s("UIManagerBinding::dispatchEvent"); + SystraceSection s("UIManagerBinding::dispatchEvent", "type", type); auto payload = payloadFactory(runtime); @@ -276,6 +124,10 @@ void UIManagerBinding::dispatchEvent( }() : jsi::Value::null(); + if (instanceHandle.isNull()) { + LOG(WARNING) << "instanceHandle is null, event will be dropped"; + } + auto &eventHandlerWrapper = static_cast(*eventHandler_); @@ -368,7 +220,8 @@ jsi::Value UIManagerBinding::get( size_t count) noexcept -> jsi::Value { return valueFromShadowNode( runtime, - uiManager->cloneNode(shadowNodeFromValue(runtime, arguments[0]))); + uiManager->cloneNode( + *shadowNodeFromValue(runtime, arguments[0]))); }); } @@ -435,7 +288,7 @@ jsi::Value UIManagerBinding::get( return valueFromShadowNode( runtime, uiManager->cloneNode( - shadowNodeFromValue(runtime, arguments[0]), + *shadowNodeFromValue(runtime, arguments[0]), ShadowNode::emptySharedShadowNodeSharedList())); }); } @@ -455,7 +308,7 @@ jsi::Value UIManagerBinding::get( return valueFromShadowNode( runtime, uiManager->cloneNode( - shadowNodeFromValue(runtime, arguments[0]), + *shadowNodeFromValue(runtime, arguments[0]), nullptr, &rawProps)); }); @@ -476,7 +329,7 @@ jsi::Value UIManagerBinding::get( return valueFromShadowNode( runtime, uiManager->cloneNode( - shadowNodeFromValue(runtime, arguments[0]), + *shadowNodeFromValue(runtime, arguments[0]), ShadowNode::emptySharedShadowNodeSharedList(), &rawProps)); }); @@ -508,8 +361,8 @@ jsi::Value UIManagerBinding::get( jsi::Value const &thisValue, jsi::Value const *arguments, size_t count) noexcept -> jsi::Value { - auto shadowNodeList = - std::make_shared(SharedShadowNodeList({})); + auto shadowNodeList = std::make_shared( + ShadowNode::ListOfShared({})); return valueFromShadowNodeList(runtime, shadowNodeList); }); } @@ -531,20 +384,32 @@ jsi::Value UIManagerBinding::get( } if (methodName == "completeRoot") { - if (uiManager->backgroundExecutor_) { - std::weak_ptr weakUIManager = uiManager_; - // Enhanced version of the method that uses `backgroundExecutor` and - // captures a shared pointer to `UIManager`. - return jsi::Function::createFromHostFunction( - runtime, - name, - 2, - [weakUIManager, uiManager]( - jsi::Runtime &runtime, - jsi::Value const &thisValue, - jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { - auto surfaceId = surfaceIdFromValue(runtime, arguments[0]); + std::weak_ptr weakUIManager = uiManager_; + // Enhanced version of the method that uses `backgroundExecutor` and + // captures a shared pointer to `UIManager`. + return jsi::Function::createFromHostFunction( + runtime, + name, + 2, + [weakUIManager, uiManager]( + jsi::Runtime &runtime, + jsi::Value const &thisValue, + jsi::Value const *arguments, + size_t count) noexcept -> jsi::Value { + auto runtimeSchedulerBinding = + RuntimeSchedulerBinding::getBinding(runtime); + auto surfaceId = surfaceIdFromValue(runtime, arguments[0]); + + if (runtimeSchedulerBinding && + runtimeSchedulerBinding->getIsSynchronous()) { + auto weakShadowNodeList = + weakShadowNodeListFromValue(runtime, arguments[1]); + auto shadowNodeList = + shadowNodeListFromWeakList(weakShadowNodeList); + if (shadowNodeList) { + uiManager->completeSurface(surfaceId, shadowNodeList, {true}); + } + } else { auto weakShadowNodeList = weakShadowNodeListFromValue(runtime, arguments[1]); static std::atomic_uint_fast8_t completeRootEventCounter{0}; @@ -571,29 +436,10 @@ jsi::Value UIManagerBinding::get( surfaceId, shadowNodeList, {true, shouldYield}); } }); + } - return jsi::Value::undefined(); - }); - } else { - // Basic version of the method that does *not* use `backgroundExecutor` - // and does *not* capture a shared pointer to `UIManager`. - return jsi::Function::createFromHostFunction( - runtime, - name, - 2, - [uiManager]( - jsi::Runtime &runtime, - jsi::Value const &thisValue, - jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { - uiManager->completeSurface( - surfaceIdFromValue(runtime, arguments[0]), - shadowNodeListFromValue(runtime, arguments[1]), - {true, {}}); - - return jsi::Value::undefined(); - }); - } + return jsi::Value::undefined(); + }); } if (methodName == "registerEventHandler") { diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h index 947e3ecf43e615..9ddd53d77e22fe 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,13 +24,12 @@ class UIManagerBinding : public jsi::HostObject { /* * Installs UIManagerBinding into JavaScript runtime if needed. * Creates and sets `UIManagerBinding` into the global namespace. - * In case if the global namespace already has a `UIManagerBinding` installed, - * returns that. * Thread synchronization must be enforced externally. */ - static std::shared_ptr createAndInstallIfNeeded( + static void createAndInstallIfNeeded( jsi::Runtime &runtime, - RuntimeExecutor const &runtimeExecutor); + RuntimeExecutor const &runtimeExecutor, + std::shared_ptr const &uiManager); /* * Returns a pointer to UIManagerBinding previously installed into a runtime. @@ -38,50 +37,16 @@ class UIManagerBinding : public jsi::HostObject { */ static std::shared_ptr getBinding(jsi::Runtime &runtime); - UIManagerBinding(RuntimeExecutor const &runtimeExecutor); + UIManagerBinding( + std::shared_ptr uiManager, + RuntimeExecutor runtimeExecutor); ~UIManagerBinding(); - /* - * Establish a relationship between `UIManager` and `UIManagerBinding` by - * setting internal pointers to each other. - * Must be called on JavaScript thread or during VM destruction. - */ - void attach(std::shared_ptr const &uiManager); - - /* - * Starts React Native Surface with given id, moduleName, and props. - * Thread synchronization must be enforced externally. - */ - void startSurface( - jsi::Runtime &runtime, - SurfaceId surfaceId, - std::string const &moduleName, - folly::dynamic const &initalProps, - DisplayMode displayMode) const; - - /* - * Updates the React Native Surface identified with surfaceId and moduleName - * with the given props. - * Thread synchronization must be enforced externally. - */ - void setSurfaceProps( - jsi::Runtime &runtime, - SurfaceId surfaceId, - std::string const &moduleName, - folly::dynamic const &props, - DisplayMode displayMode) const; - jsi::Value getInspectorDataForInstance( jsi::Runtime &runtime, EventEmitter const &eventEmitter) const; - /* - * Stops React Native Surface with given id. - * Thread synchronization must be enforced externally. - */ - void stopSurface(jsi::Runtime &runtime, SurfaceId surfaceId) const; - /* * Delivers raw event data to JavaScript. * Thread synchronization must be enforced externally. diff --git a/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h b/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h index 50fa5ebb667894..c6fdfaab4e0579 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerCommitHook.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h b/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h index 91d8bf55107423..a36feaed21cd8e 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,7 +47,7 @@ class UIManagerDelegate { virtual void uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) = 0; + folly::dynamic const &args) = 0; /* * Called when UIManager wants to dispatch some accessibility event diff --git a/ReactCommon/react/renderer/uimanager/bindingUtils.cpp b/ReactCommon/react/renderer/uimanager/bindingUtils.cpp new file mode 100644 index 00000000000000..48bc180839517f --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/bindingUtils.cpp @@ -0,0 +1,79 @@ +/* + * 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. + */ + +#include "bindingUtils.h" + +#include +#include + +namespace facebook::react { + +static jsi::Value getModule( + jsi::Runtime &runtime, + std::string const &moduleName) { + auto batchedBridge = + runtime.global().getPropertyAsObject(runtime, "__fbBatchedBridge"); + auto getCallableModule = + batchedBridge.getPropertyAsFunction(runtime, "getCallableModule"); + auto moduleAsValue = getCallableModule.callWithThis( + runtime, + batchedBridge, + {jsi::String::createFromUtf8(runtime, moduleName)}); + if (!moduleAsValue.isObject()) { + LOG(ERROR) << "getModule of " << moduleName << " is not an object"; + } + react_native_assert(moduleAsValue.isObject()); + return moduleAsValue; +} + +static bool checkBatchedBridgeIsActive(jsi::Runtime &runtime) { + if (!runtime.global().hasProperty(runtime, "__fbBatchedBridge")) { + LOG(ERROR) + << "getPropertyAsObject: property '__fbBatchedBridge' is undefined, expected an Object"; + return false; + } + return true; +} + +static bool checkGetCallableModuleIsActive(jsi::Runtime &runtime) { + if (!checkBatchedBridgeIsActive(runtime)) { + return false; + } + auto batchedBridge = + runtime.global().getPropertyAsObject(runtime, "__fbBatchedBridge"); + if (!batchedBridge.hasProperty(runtime, "getCallableModule")) { + LOG(ERROR) + << "getPropertyAsFunction: function 'getCallableModule' is undefined, expected a Function"; + return false; + } + return true; +} + +jsi::Value callMethodOfModule( + jsi::Runtime &runtime, + std::string const &moduleName, + std::string const &methodName, + std::initializer_list args) { + if (checkGetCallableModuleIsActive(runtime)) { + auto module = getModule(runtime, moduleName); + if (module.isObject()) { + jsi::Object object = module.asObject(runtime); + react_native_assert(object.hasProperty(runtime, methodName.c_str())); + if (object.hasProperty(runtime, methodName.c_str())) { + auto method = object.getPropertyAsFunction(runtime, methodName.c_str()); + return method.callWithThis(runtime, object, args); + } else { + LOG(ERROR) << "getPropertyAsFunction: property '" << methodName + << "' is undefined, expected a Function"; + } + } + } + + return jsi::Value::undefined(); +} + +} // namespace facebook::react diff --git a/ReactCommon/react/renderer/uimanager/bindingUtils.h b/ReactCommon/react/renderer/uimanager/bindingUtils.h new file mode 100644 index 00000000000000..17c978f8cddb6e --- /dev/null +++ b/ReactCommon/react/renderer/uimanager/bindingUtils.h @@ -0,0 +1,20 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace facebook::react { + +jsi::Value callMethodOfModule( + jsi::Runtime &runtime, + std::string const &moduleName, + std::string const &methodName, + std::initializer_list args); + +} // namespace facebook::react diff --git a/ReactCommon/react/renderer/uimanager/primitives.h b/ReactCommon/react/renderer/uimanager/primitives.h index 749fca7f28105e..a7e7f5f275e673 100644 --- a/ReactCommon/react/renderer/uimanager/primitives.h +++ b/ReactCommon/react/renderer/uimanager/primitives.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -27,17 +27,27 @@ struct EventHandlerWrapper : public EventHandler { }; struct ShadowNodeWrapper : public jsi::HostObject { - ShadowNodeWrapper(SharedShadowNode shadowNode) + ShadowNodeWrapper(ShadowNode::Shared shadowNode) : shadowNode(std::move(shadowNode)) {} + // The below method needs to be implemented out-of-line in order for the class + // to have at least one "key function" (see + // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable) + ~ShadowNodeWrapper() override; + ShadowNode::Shared shadowNode; }; struct ShadowNodeListWrapper : public jsi::HostObject { - ShadowNodeListWrapper(SharedShadowNodeUnsharedList shadowNodeList) + ShadowNodeListWrapper(ShadowNode::UnsharedListOfShared shadowNodeList) : shadowNodeList(shadowNodeList) {} - SharedShadowNodeUnsharedList shadowNodeList; + // The below method needs to be implemented out-of-line in order for the class + // to have at least one "key function" (see + // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable) + ~ShadowNodeListWrapper() override; + + ShadowNode::UnsharedListOfShared shadowNodeList; }; inline static ShadowNode::Shared shadowNodeFromValue( @@ -54,12 +64,12 @@ inline static ShadowNode::Shared shadowNodeFromValue( inline static jsi::Value valueFromShadowNode( jsi::Runtime &runtime, - const ShadowNode::Shared &shadowNode) { + ShadowNode::Shared shadowNode) { return jsi::Object::createFromHostObject( - runtime, std::make_shared(shadowNode)); + runtime, std::make_shared(std::move(shadowNode))); } -inline static SharedShadowNodeUnsharedList shadowNodeListFromValue( +inline static ShadowNode::UnsharedListOfShared shadowNodeListFromValue( jsi::Runtime &runtime, jsi::Value const &value) { return value.getObject(runtime) @@ -97,7 +107,7 @@ inline static ShadowNode::UnsharedListOfWeak weakShadowNodeListFromValue( inline static jsi::Value valueFromShadowNodeList( jsi::Runtime &runtime, - const SharedShadowNodeUnsharedList &shadowNodeList) { + const ShadowNode::UnsharedListOfShared &shadowNodeList) { return jsi::Object::createFromHostObject( runtime, std::make_unique(shadowNodeList)); } diff --git a/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp b/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp index de35870cd304d1..c842a454b6592f 100644 --- a/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp +++ b/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/test_utils/BUCK b/ReactCommon/react/test_utils/BUCK index 55a8cac9d0f5d0..7c520f97297ca0 100644 --- a/ReactCommon/react/test_utils/BUCK +++ b/ReactCommon/react/test_utils/BUCK @@ -31,7 +31,10 @@ rn_xplat_cxx_library( fbobjc_frameworks = ["Foundation"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -42,7 +45,7 @@ rn_xplat_cxx_library( visibility = ["PUBLIC"], deps = [ "//xplat/jsi:jsi", - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("react/debug:debug"), ], exported_deps = [ diff --git a/ReactCommon/react/test_utils/Entropy.h b/ReactCommon/react/test_utils/Entropy.h index 7bbaf91012f2e2..e9fb4eb66a53c5 100644 --- a/ReactCommon/react/test_utils/Entropy.h +++ b/ReactCommon/react/test_utils/Entropy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/test_utils/MockClock.h b/ReactCommon/react/test_utils/MockClock.h index a5155207b2078a..00419695b04dfb 100644 --- a/ReactCommon/react/test_utils/MockClock.h +++ b/ReactCommon/react/test_utils/MockClock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/test_utils/MockSurfaceHandler.h b/ReactCommon/react/test_utils/MockSurfaceHandler.h index c6f678ce484871..3563c699109379 100644 --- a/ReactCommon/react/test_utils/MockSurfaceHandler.h +++ b/ReactCommon/react/test_utils/MockSurfaceHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -18,7 +18,8 @@ class MockSurfaceHandler : public SurfaceHandler { public: MockSurfaceHandler() : SurfaceHandler("moduleName", 0){}; - MOCK_QUALIFIED_METHOD1(setDisplayMode, const noexcept, void(DisplayMode)); + MOCK_METHOD(void, setDisplayMode, (DisplayMode), (const, noexcept)); + MOCK_METHOD(SurfaceId, getSurfaceId, (), (const, noexcept)); }; } // namespace react diff --git a/ReactCommon/react/test_utils/shadowTreeGeneration.h b/ReactCommon/react/test_utils/shadowTreeGeneration.h index f2897cb5e18791..63f037b9b4930b 100644 --- a/ReactCommon/react/test_utils/shadowTreeGeneration.h +++ b/ReactCommon/react/test_utils/shadowTreeGeneration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -308,7 +308,7 @@ static inline ShadowNode::Shared generateShadowNodeTree( return componentDescriptor.createShadowNode( ShadowNodeFragment{ generateDefaultProps(componentDescriptor), - std::make_shared(children)}, + std::make_shared(children)}, family); } diff --git a/ReactCommon/react/utils/Android.mk b/ReactCommon/react/utils/Android.mk deleted file mode 100644 index 471b15e6cff373..00000000000000 --- a/ReactCommon/react/utils/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_utils - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libreact_debug libreact_render_mapbuffer libglog libglog_init - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,react/debug) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/utils/BUCK b/ReactCommon/react/utils/BUCK index 6525d5b9b5ded4..3132286ad155d4 100644 --- a/ReactCommon/react/utils/BUCK +++ b/ReactCommon/react/utils/BUCK @@ -42,7 +42,10 @@ rn_xplat_cxx_library( fbobjc_frameworks = ["Foundation"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ @@ -54,11 +57,11 @@ rn_xplat_cxx_library( deps = [ "//third-party/glog:glog", "//xplat/folly:container_evicting_cache_map", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", "//xplat/jsi:jsi", - react_native_xplat_target("better:better"), + react_native_xplat_target("butter:butter"), react_native_xplat_target("react/debug:debug"), ], ) diff --git a/ReactCommon/react/utils/CMakeLists.txt b/ReactCommon/react/utils/CMakeLists.txt new file mode 100644 index 00000000000000..335ebf9c365e76 --- /dev/null +++ b/ReactCommon/react/utils/CMakeLists.txt @@ -0,0 +1,24 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -Wall + -DLOG_TAG=\"Fabric\") + +file(GLOB react_utils_SRC CONFIGURE_DEPENDS *.cpp *.mm) +add_library(react_utils SHARED ${react_utils_SRC}) + +target_include_directories(react_utils PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_utils + glog + glog_init + react_debug) diff --git a/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h b/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h index 4d4d2c0d056d96..09aa8812ffcb22 100644 --- a/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h +++ b/ReactCommon/react/utils/CalledOnceMovableOnlyFunction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,7 +26,7 @@ class CalledOnceMovableOnlyFunction { bool wasMovedFrom_; public: - CalledOnceMovableOnlyFunction(std::function &&function) + explicit CalledOnceMovableOnlyFunction(std::function &&function) : function_(std::move(function)) { wasCalled_ = false; wasMovedFrom_ = false; diff --git a/ReactCommon/react/utils/ContextContainer.h b/ReactCommon/react/utils/ContextContainer.h index 1431fe1af83190..636736afec7a7c 100644 --- a/ReactCommon/react/utils/ContextContainer.h +++ b/ReactCommon/react/utils/ContextContainer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,11 +9,11 @@ #include #include +#include #include -#include -#include -#include +#include +#include #include #include @@ -42,7 +42,7 @@ class ContextContainer final { */ template void insert(std::string const &key, T const &instance) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); instances_.insert({key, std::make_shared(instance)}); } @@ -52,7 +52,7 @@ class ContextContainer final { * Does nothing if the instance was not found. */ void erase(std::string const &key) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); instances_.erase(key); } @@ -63,7 +63,7 @@ class ContextContainer final { * values from the given container. */ void update(ContextContainer const &contextContainer) const { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); for (auto const &pair : contextContainer.instances_) { instances_.erase(pair.first); @@ -78,7 +78,7 @@ class ContextContainer final { */ template T at(std::string const &key) const { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); react_native_assert( instances_.find(key) != instances_.end() && @@ -92,8 +92,8 @@ class ContextContainer final { * Returns an empty optional if the instance could not be found. */ template - better::optional find(std::string const &key) const { - std::shared_lock lock(mutex_); + std::optional find(std::string const &key) const { + std::shared_lock lock(mutex_); auto iterator = instances_.find(key); if (iterator == instances_.end()) { @@ -104,9 +104,9 @@ class ContextContainer final { } private: - mutable better::shared_mutex mutex_; + mutable butter::shared_mutex mutex_; // Protected by mutex_`. - mutable better::map> instances_; + mutable butter::map> instances_; }; } // namespace react diff --git a/ReactCommon/react/utils/FloatComparison.h b/ReactCommon/react/utils/FloatComparison.h index 4dce8a8b5958a0..aa198b442a5d2f 100644 --- a/ReactCommon/react/utils/FloatComparison.h +++ b/ReactCommon/react/utils/FloatComparison.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/utils/LayoutManager.h b/ReactCommon/react/utils/LayoutManager.h deleted file mode 100644 index bc901971a3cbb2..00000000000000 --- a/ReactCommon/react/utils/LayoutManager.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include -#ifdef ANDROID -#include -#include -#include -#endif -#include - -namespace facebook { -namespace react { - -#ifdef ANDROID - -using namespace facebook::jni; - -Size measureAndroidComponent( - const ContextContainer::Shared &contextContainer, - Tag rootTag, - std::string componentName, - folly::dynamic localData, - folly::dynamic props, - folly::dynamic state, - float minWidth, - float maxWidth, - float minHeight, - float maxHeight, - jfloatArray attachmentPositions) { - const jni::global_ref &fabricUIManager = - contextContainer->at>("FabricUIManager"); - - static auto measure = - jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") - ->getMethod("measure"); - - auto componentNameRef = make_jstring(componentName); - local_ref localDataRNM = - ReadableNativeMap::newObjectCxxArgs(localData); - local_ref propsRNM = - ReadableNativeMap::newObjectCxxArgs(props); - local_ref stateRNM = - ReadableNativeMap::newObjectCxxArgs(state); - - local_ref localDataRM = - make_local(reinterpret_cast(localDataRNM.get())); - local_ref propsRM = - make_local(reinterpret_cast(propsRNM.get())); - local_ref stateRM = - make_local(reinterpret_cast(stateRNM.get())); - - auto size = yogaMeassureToSize(measure( - fabricUIManager, - rootTag, - componentNameRef.get(), - localDataRM.get(), - propsRM.get(), - stateRM.get(), - minWidth, - maxWidth, - minHeight, - maxHeight, - attachmentPositions)); - - // Explicitly release smart pointers to free up space faster in JNI tables - componentNameRef.reset(); - localDataRM.reset(); - localDataRNM.reset(); - propsRM.reset(); - propsRNM.reset(); - stateRM.reset(); - stateRNM.reset(); - - return size; -} - -Size measureAndroidComponentMapBuffer( - const ContextContainer::Shared &contextContainer, - Tag rootTag, - std::string componentName, - MapBuffer &localData, - MapBuffer &props, - float minWidth, - float maxWidth, - float minHeight, - float maxHeight, - jfloatArray attachmentPositions) { - const jni::global_ref &fabricUIManager = - contextContainer->at>("FabricUIManager"); - auto componentNameRef = make_jstring(componentName); - - static auto measure = - jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") - ->getMethod("measureMapBuffer"); - - auto localDataMap = - ReadableMapBuffer::createWithContents(std::move(localData)); - auto propsMap = ReadableMapBuffer::createWithContents(std::move(props)); - - auto size = yogaMeassureToSize(measure( - fabricUIManager, - rootTag, - componentNameRef.get(), - localDataMap.get(), - propsMap.get(), - minWidth, - maxWidth, - minHeight, - maxHeight, - attachmentPositions)); - - // Explicitly release smart pointers to free up space faster in JNI tables - componentNameRef.reset(); - localDataMap.reset(); - propsMap.reset(); - return size; -} - -#endif - -} // namespace react -} // namespace facebook diff --git a/ReactCommon/react/utils/ManagedObjectWrapper.h b/ReactCommon/react/utils/ManagedObjectWrapper.h index f91cd3e99d81d2..727499abd6bd42 100644 --- a/ReactCommon/react/utils/ManagedObjectWrapper.h +++ b/ReactCommon/react/utils/ManagedObjectWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,10 @@ #include +#if defined(__APPLE__) +#include +#endif + #if defined(__OBJC__) && defined(__cplusplus) #if TARGET_OS_MAC && TARGET_OS_IPHONE diff --git a/ReactCommon/react/utils/ManagedObjectWrapper.mm b/ReactCommon/react/utils/ManagedObjectWrapper.mm index ede1d30aad840c..69bde90f422c5e 100644 --- a/ReactCommon/react/utils/ManagedObjectWrapper.mm +++ b/ReactCommon/react/utils/ManagedObjectWrapper.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/utils/RunLoopObserver.cpp b/ReactCommon/react/utils/RunLoopObserver.cpp index d24c3ede72bb13..c957c43b42f64c 100644 --- a/ReactCommon/react/utils/RunLoopObserver.cpp +++ b/ReactCommon/react/utils/RunLoopObserver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/utils/RunLoopObserver.h b/ReactCommon/react/utils/RunLoopObserver.h index 5bd7bd7a4c84c8..469d8c26626143 100644 --- a/ReactCommon/react/utils/RunLoopObserver.h +++ b/ReactCommon/react/utils/RunLoopObserver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/react/utils/SharedFunction.h b/ReactCommon/react/utils/SharedFunction.h index 180f284d94a65f..a4a958798bef82 100644 --- a/ReactCommon/react/utils/SharedFunction.h +++ b/ReactCommon/react/utils/SharedFunction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,7 +9,7 @@ #include #include -#include +#include namespace facebook { namespace react { @@ -31,7 +31,7 @@ class SharedFunction { struct Pair { Pair(std::function &&function) : function(std::move(function)) {} std::function function; - better::shared_mutex mutex{}; + butter::shared_mutex mutex{}; }; public: @@ -45,12 +45,12 @@ class SharedFunction { SharedFunction &operator=(SharedFunction &&other) noexcept = default; void assign(std::function function) const { - std::unique_lock lock(pair_->mutex); + std::unique_lock lock(pair_->mutex); pair_->function = function; } ReturnT operator()(ArgumentT... args) const { - std::shared_lock lock(pair_->mutex); + std::shared_lock lock(pair_->mutex); return pair_->function(args...); } diff --git a/ReactCommon/react/utils/SimpleThreadSafeCache.h b/ReactCommon/react/utils/SimpleThreadSafeCache.h index b500535bb7fa4b..3954d951f0f347 100644 --- a/ReactCommon/react/utils/SimpleThreadSafeCache.h +++ b/ReactCommon/react/utils/SimpleThreadSafeCache.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,8 +8,8 @@ #include #include #include +#include -#include #include namespace facebook { @@ -22,6 +22,7 @@ template class SimpleThreadSafeCache { public: SimpleThreadSafeCache() : map_{maxSize} {} + SimpleThreadSafeCache(unsigned long size) : map_{size} {} /* * Returns a value from the map with a given key. @@ -47,7 +48,7 @@ class SimpleThreadSafeCache { * If the value wasn't found in the cache, returns empty optional. * Can be called from any thread. */ - better::optional get(const KeyT &key) const { + std::optional get(const KeyT &key) const { std::lock_guard lock(mutex_); auto iterator = map_.find(key); if (iterator == map_.end()) { diff --git a/ReactCommon/react/utils/Telemetry.h b/ReactCommon/react/utils/Telemetry.h index 10a82e07f0430e..2071ff6c70f8c1 100644 --- a/ReactCommon/react/utils/Telemetry.h +++ b/ReactCommon/react/utils/Telemetry.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -68,7 +68,7 @@ static inline double telemetryTimePointToSteadyClockSeconds( auto nanoseconds = std::chrono::duration_cast( timePoint.time_since_epoch()) .count(); - return nanoseconds / 1.0e9; + return (double)nanoseconds / 1.0e9; } /* @@ -96,7 +96,7 @@ static inline double telemetryTimePointToSecondsSinceEpoch( auto systemClockTimePoint = clockCast( timePoint); - return std::chrono::duration_cast( + return (double)std::chrono::duration_cast( systemClockTimePoint.time_since_epoch()) .count() / 1000000.0; diff --git a/ReactCommon/reactperflogger/Android.mk b/ReactCommon/reactperflogger/Android.mk deleted file mode 100644 index a65bfd18ee02fb..00000000000000 --- a/ReactCommon/reactperflogger/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/reactperflogger - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -# Name of this module. -LOCAL_MODULE := reactperflogger - -# Compile all local c++ files under ./ReactCommon -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/reactperflogger/*.cpp) - -# Build the files in this directory as a shared library -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/reactperflogger/BUCK b/ReactCommon/reactperflogger/BUCK index d1a06c09571fb5..2adcfa47635e70 100644 --- a/ReactCommon/reactperflogger/BUCK +++ b/ReactCommon/reactperflogger/BUCK @@ -1,4 +1,4 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "rn_xplat_cxx_library") +load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "rn_xplat_cxx_library") rn_xplat_cxx_library( name = "reactperflogger", @@ -11,8 +11,11 @@ rn_xplat_cxx_library( compiler_flags = [ "-Wno-global-constructors", ], - labels = ["supermodule:xplat/default/public.react_native.infra"], - platforms = (ANDROID, APPLE), + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], + platforms = (ANDROID, APPLE, CXX), preferred_linkage = "static", preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", diff --git a/ReactCommon/reactperflogger/CMakeLists.txt b/ReactCommon/reactperflogger/CMakeLists.txt new file mode 100644 index 00000000000000..5c18745cc57cc1 --- /dev/null +++ b/ReactCommon/reactperflogger/CMakeLists.txt @@ -0,0 +1,14 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall) + +file(GLOB reactperflogger_SRC CONFIGURE_DEPENDS reactperflogger/*.cpp) +add_library(reactperflogger STATIC ${reactperflogger_SRC}) + +target_include_directories(reactperflogger PUBLIC .) diff --git a/ReactCommon/reactperflogger/React-perflogger.podspec b/ReactCommon/reactperflogger/React-perflogger.podspec index 2be907ca3ae54d..24229c0eeead52 100644 --- a/ReactCommon/reactperflogger/React-perflogger.podspec +++ b/ReactCommon/reactperflogger/React-perflogger.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "**/*.{cpp,h}" s.header_dir = "reactperflogger" diff --git a/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.cpp b/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.cpp index f23256bf5cef24..7c0da26878a1ff 100644 --- a/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.cpp +++ b/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.h b/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.h index 9ac83b9615e837..c9593ec86f39c9 100644 --- a/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.h +++ b/ReactCommon/reactperflogger/reactperflogger/BridgeNativeModulePerfLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/reactperflogger/reactperflogger/NativeModulePerfLogger.h b/ReactCommon/reactperflogger/reactperflogger/NativeModulePerfLogger.h index 54def97671cd01..2cb386b48afb56 100644 --- a/ReactCommon/reactperflogger/reactperflogger/NativeModulePerfLogger.h +++ b/ReactCommon/reactperflogger/reactperflogger/NativeModulePerfLogger.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/runtimeexecutor/Android.mk b/ReactCommon/runtimeexecutor/Android.mk deleted file mode 100644 index 6b39530804dfa6..00000000000000 --- a/ReactCommon/runtimeexecutor/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := runtimeexecutor - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/runtimeexecutor/BUCK b/ReactCommon/runtimeexecutor/BUCK index b8e04dfaf72004..e6342f31dbae0f 100644 --- a/ReactCommon/runtimeexecutor/BUCK +++ b/ReactCommon/runtimeexecutor/BUCK @@ -32,7 +32,10 @@ rn_xplat_cxx_library( fbobjc_frameworks = ["Foundation"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], macosx_tests_override = [], platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ diff --git a/ReactCommon/runtimeexecutor/CMakeLists.txt b/ReactCommon/runtimeexecutor/CMakeLists.txt new file mode 100644 index 00000000000000..b07e6b636253fd --- /dev/null +++ b/ReactCommon/runtimeexecutor/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -std=c++17 -Wall) + +file(GLOB_RECURSE runtimeexecutor_SRC CONFIGURE_DEPENDS *.cpp *.h) + +add_library(runtimeexecutor SHARED ${runtimeexecutor_SRC}) + +target_include_directories(runtimeexecutor PUBLIC .) + +target_link_libraries(runtimeexecutor jsi) diff --git a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec index fd11178e5ac1f2..5cbadf30d531fe 100644 --- a/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec +++ b/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_compiler_flags = '-Wno-documentation' Pod::Spec.new do |s| @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0" } + s.platforms = { :ios => "12.4" } s.source = source s.source_files = "**/*.{cpp,h}" s.header_dir = "ReactCommon" diff --git a/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h b/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h index 3e06081e45a862..1c5180918d6431 100644 --- a/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h +++ b/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/Android.mk b/ReactCommon/yoga/Android.mk deleted file mode 100644 index d4ec34f9b32243..00000000000000 --- a/ReactCommon/yoga/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := yogacore - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/yoga/*.cpp) -LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/yoga/*/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/yoga/CMakeLists.txt b/ReactCommon/yoga/CMakeLists.txt new file mode 100644 index 00000000000000..c7e6cd4fd23cb0 --- /dev/null +++ b/ReactCommon/yoga/CMakeLists.txt @@ -0,0 +1,16 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options(-fexceptions -frtti -O3 -Wall) + +file(GLOB_RECURSE yogacore_SRC CONFIGURE_DEPENDS yoga/*.cpp) +add_library(yogacore STATIC ${yogacore_SRC}) + +target_include_directories(yogacore PUBLIC .) + +target_link_libraries(yogacore android log) diff --git a/ReactCommon/yoga/Yoga.podspec b/ReactCommon/yoga/Yoga.podspec index 701e93301a68a6..8ddf0bdcee93ec 100644 --- a/ReactCommon/yoga/Yoga.podspec +++ b/ReactCommon/yoga/Yoga.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -38,12 +38,12 @@ Pod::Spec.new do |spec| '-fexceptions', '-Wall', '-Werror', - '-std=c++1y', + '-std=c++17', '-fPIC' ] # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "11.0" } + spec.platforms = { :ios => "12.4" } # Set this environment variable when *not* using the `:path` option to install the pod. # E.g. when publishing this spec to a spec repo. @@ -51,7 +51,7 @@ Pod::Spec.new do |spec| source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.source_files = source_files - header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGNode,YGStyle,YGValue}.h' + header_files = 'yoga/*.h' header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.public_header_files = header_files end diff --git a/ReactCommon/yoga/yoga/BitUtils.h b/ReactCommon/yoga/yoga/BitUtils.h index 2161effc7bb6fe..a60ea7609cada3 100644 --- a/ReactCommon/yoga/yoga/BitUtils.h +++ b/ReactCommon/yoga/yoga/BitUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include #include #include "YGEnums.h" @@ -65,3 +67,5 @@ inline void setBooleanData(uint8_t& flags, size_t index, bool value) { } // namespace detail } // namespace yoga } // namespace facebook + +#endif diff --git a/ReactCommon/yoga/yoga/CompactValue.h b/ReactCommon/yoga/yoga/CompactValue.h index f398668e2e1389..1f03cf721aaf18 100644 --- a/ReactCommon/yoga/yoga/CompactValue.h +++ b/ReactCommon/yoga/yoga/CompactValue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include "YGValue.h" #include "YGMacros.h" #include @@ -182,3 +184,5 @@ constexpr bool operator!=(CompactValue a, CompactValue b) noexcept { } // namespace detail } // namespace yoga } // namespace facebook + +#endif diff --git a/ReactCommon/yoga/yoga/Utils.cpp b/ReactCommon/yoga/yoga/Utils.cpp index eaa74b0629ac23..f2af12b2305d44 100644 --- a/ReactCommon/yoga/yoga/Utils.cpp +++ b/ReactCommon/yoga/yoga/Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/Utils.h b/ReactCommon/yoga/yoga/Utils.h index 57e1d45d992be7..8588ecc5946122 100644 --- a/ReactCommon/yoga/yoga/Utils.h +++ b/ReactCommon/yoga/yoga/Utils.h @@ -1,11 +1,14 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #pragma once + +#ifdef __cplusplus + #include "YGNode.h" #include "Yoga-internal.h" #include "CompactValue.h" @@ -145,3 +148,5 @@ inline YGFloatOptional YGResolveValueMargin( } void throwLogicalErrorWithMessage(const char* message); + +#endif diff --git a/ReactCommon/yoga/yoga/YGConfig.cpp b/ReactCommon/yoga/yoga/YGConfig.cpp index fb72e80cfcffb1..915da52af77ac0 100644 --- a/ReactCommon/yoga/yoga/YGConfig.cpp +++ b/ReactCommon/yoga/yoga/YGConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGConfig.h b/ReactCommon/yoga/yoga/YGConfig.h index e87d67586be0ad..e15cc1225334e0 100644 --- a/ReactCommon/yoga/yoga/YGConfig.h +++ b/ReactCommon/yoga/yoga/YGConfig.h @@ -1,11 +1,14 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #pragma once + +#ifdef __cplusplus + #include "Yoga-internal.h" #include "Yoga.h" @@ -74,3 +77,5 @@ struct YOGA_EXPORT YGConfig { setCloneNodeCallback(YGCloneNodeFunc{nullptr}); } }; + +#endif diff --git a/ReactCommon/yoga/yoga/YGEnums.cpp b/ReactCommon/yoga/yoga/YGEnums.cpp index c01d3d94b3f190..b97342d8c279f6 100644 --- a/ReactCommon/yoga/yoga/YGEnums.cpp +++ b/ReactCommon/yoga/yoga/YGEnums.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGEnums.h b/ReactCommon/yoga/yoga/YGEnums.h index 3dc458dcb31a08..c14daaa1a678a4 100644 --- a/ReactCommon/yoga/yoga/YGEnums.h +++ b/ReactCommon/yoga/yoga/YGEnums.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGFloatOptional.h b/ReactCommon/yoga/yoga/YGFloatOptional.h index e4cf0284bab069..6af7bbafbfbdcb 100644 --- a/ReactCommon/yoga/yoga/YGFloatOptional.h +++ b/ReactCommon/yoga/yoga/YGFloatOptional.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include #include #include "Yoga-internal.h" @@ -68,3 +70,5 @@ inline bool operator>=(YGFloatOptional lhs, YGFloatOptional rhs) { inline bool operator<=(YGFloatOptional lhs, YGFloatOptional rhs) { return lhs < rhs || lhs == rhs; } + +#endif diff --git a/ReactCommon/yoga/yoga/YGLayout.cpp b/ReactCommon/yoga/yoga/YGLayout.cpp index e43213cdc66a6f..9aadcd4aecd02c 100644 --- a/ReactCommon/yoga/yoga/YGLayout.cpp +++ b/ReactCommon/yoga/yoga/YGLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGLayout.h b/ReactCommon/yoga/yoga/YGLayout.h index b7604d8e2dbe45..e3a4a1943b2f30 100644 --- a/ReactCommon/yoga/yoga/YGLayout.h +++ b/ReactCommon/yoga/yoga/YGLayout.h @@ -1,11 +1,14 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #pragma once + +#ifdef __cplusplus + #include "BitUtils.h" #include "YGFloatOptional.h" #include "Yoga-internal.h" @@ -85,3 +88,5 @@ struct YGLayout { bool operator==(YGLayout layout) const; bool operator!=(YGLayout layout) const { return !(*this == layout); } }; + +#endif diff --git a/ReactCommon/yoga/yoga/YGMacros.h b/ReactCommon/yoga/yoga/YGMacros.h index c6917f1b1d9aee..9211c87b317bae 100644 --- a/ReactCommon/yoga/yoga/YGMacros.h +++ b/ReactCommon/yoga/yoga/YGMacros.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index f4c14bf3d8c9b8..32eabd1d5f9253 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index 4b6e6277af8aa7..8c511236770a22 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGNodePrint.cpp b/ReactCommon/yoga/yoga/YGNodePrint.cpp index 72d147dbb7b29f..d46373c4b8144a 100644 --- a/ReactCommon/yoga/yoga/YGNodePrint.cpp +++ b/ReactCommon/yoga/yoga/YGNodePrint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGNodePrint.h b/ReactCommon/yoga/yoga/YGNodePrint.h index 3db504b460218f..83b3f860e4b5b5 100644 --- a/ReactCommon/yoga/yoga/YGNodePrint.h +++ b/ReactCommon/yoga/yoga/YGNodePrint.h @@ -1,12 +1,16 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #ifdef DEBUG + #pragma once + +#ifdef __cplusplus + #include #include "Yoga.h" @@ -22,4 +26,7 @@ void YGNodeToString( } // namespace yoga } // namespace facebook + +#endif + #endif diff --git a/ReactCommon/yoga/yoga/YGStyle.cpp b/ReactCommon/yoga/yoga/YGStyle.cpp index e8033bdf4c8762..f8bba25d5e5fe2 100644 --- a/ReactCommon/yoga/yoga/YGStyle.cpp +++ b/ReactCommon/yoga/yoga/YGStyle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGStyle.h b/ReactCommon/yoga/yoga/YGStyle.h index aab7599ccd964b..b463623abc98ec 100644 --- a/ReactCommon/yoga/yoga/YGStyle.h +++ b/ReactCommon/yoga/yoga/YGStyle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGValue.cpp b/ReactCommon/yoga/yoga/YGValue.cpp index 37383a555735f5..89ff41bab117c1 100644 --- a/ReactCommon/yoga/yoga/YGValue.cpp +++ b/ReactCommon/yoga/yoga/YGValue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/YGValue.h b/ReactCommon/yoga/yoga/YGValue.h index a20009784ea8ed..11beb3ec8b74ac 100644 --- a/ReactCommon/yoga/yoga/YGValue.h +++ b/ReactCommon/yoga/yoga/YGValue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/Yoga-internal.h b/ReactCommon/yoga/yoga/Yoga-internal.h index acd173be83f2ff..492543ef1d6b24 100644 --- a/ReactCommon/yoga/yoga/Yoga-internal.h +++ b/ReactCommon/yoga/yoga/Yoga-internal.h @@ -1,11 +1,14 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ #pragma once + +#ifdef __cplusplus + #include #include #include @@ -148,3 +151,5 @@ static const float kDefaultFlexShrink = 0.0f; static const float kWebDefaultFlexShrink = 1.0f; extern bool YGFloatsEqual(const float a, const float b); + +#endif diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 2c68674a742933..20389d4f2404f3 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -2229,7 +2229,7 @@ static float YGDistributeFreeSpaceSecondPass( depth, generationCount); node->setLayoutHadOverflow( - node->getLayout().hadOverflow() | + node->getLayout().hadOverflow() || currentRelativeChild->getLayout().hadOverflow()); } return deltaFreeSpace; diff --git a/ReactCommon/yoga/yoga/Yoga.h b/ReactCommon/yoga/yoga/Yoga.h index 86cd65e2f08f07..3444658bbe0d8e 100644 --- a/ReactCommon/yoga/yoga/Yoga.h +++ b/ReactCommon/yoga/yoga/Yoga.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/event/event.cpp b/ReactCommon/yoga/yoga/event/event.cpp index 3af3e83a065992..152c4e16f5c996 100644 --- a/ReactCommon/yoga/yoga/event/event.cpp +++ b/ReactCommon/yoga/yoga/event/event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/event/event.h b/ReactCommon/yoga/yoga/event/event.h index 404ec3766c5f52..a5978914a9b956 100644 --- a/ReactCommon/yoga/yoga/event/event.h +++ b/ReactCommon/yoga/yoga/event/event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/internal/experiments-inl.h b/ReactCommon/yoga/yoga/internal/experiments-inl.h index 959d9c3327e3df..442355901619c5 100644 --- a/ReactCommon/yoga/yoga/internal/experiments-inl.h +++ b/ReactCommon/yoga/yoga/internal/experiments-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/internal/experiments.cpp b/ReactCommon/yoga/yoga/internal/experiments.cpp index 16f196d5ed0e2d..016ea208709de3 100644 --- a/ReactCommon/yoga/yoga/internal/experiments.cpp +++ b/ReactCommon/yoga/yoga/internal/experiments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/internal/experiments.h b/ReactCommon/yoga/yoga/internal/experiments.h index 1bdb7014b02a2a..2298e247224def 100644 --- a/ReactCommon/yoga/yoga/internal/experiments.h +++ b/ReactCommon/yoga/yoga/internal/experiments.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/log.cpp b/ReactCommon/yoga/yoga/log.cpp index eb3da039c3d071..dbf7b4376e669c 100644 --- a/ReactCommon/yoga/yoga/log.cpp +++ b/ReactCommon/yoga/yoga/log.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/ReactCommon/yoga/yoga/log.h b/ReactCommon/yoga/yoga/log.h index ae33744c583cd0..b9bfea4f390f7e 100644 --- a/ReactCommon/yoga/yoga/log.h +++ b/ReactCommon/yoga/yoga/log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,8 @@ #pragma once +#ifdef __cplusplus + #include "YGEnums.h" struct YGNode; @@ -36,3 +38,5 @@ struct Log { } // namespace detail } // namespace yoga } // namespace facebook + +#endif diff --git a/bots/code-analysis-bot.js b/bots/code-analysis-bot.js index bdcaec1befcbf2..2b95ae2dd05f95 100644 --- a/bots/code-analysis-bot.js +++ b/bots/code-analysis-bot.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -230,6 +230,7 @@ async function main(messages, owner, repo, pull_number) { const {Octokit} = require('@octokit/rest'); const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN, + userAgent: 'react-native-code-analysis-bot', }); const opts = { diff --git a/bots/dangerfile.js b/bots/dangerfile.js index 91803ed129810a..40e28921179560 100644 --- a/bots/dangerfile.js +++ b/bots/dangerfile.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,19 +12,24 @@ const {danger, fail, message, warn} = require('danger'); const includes = require('lodash.includes'); +const isFromPhabricator = + danger.github.pr.body && + danger.github.pr.body.toLowerCase().includes('differential revision:'); + // Provides advice if a summary section is missing, or body is too short const includesSummary = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('## summary'); if (!danger.github.pr.body || danger.github.pr.body.length < 50) { fail(':grey_question: This pull request needs a description.'); -} else if (!includesSummary) { +} else if (!includesSummary && !isFromPhabricator) { + // PRs from Phabricator always includes the Summary by default. const title = ':clipboard: Missing Summary'; const idea = 'Can you add a Summary? ' + 'To do so, add a "## Summary" section to your PR description. ' + 'This is a good place to explain the motivation for making this change.'; - message(`${title} - ${idea}`); + warn(`${title} - ${idea}`); } // Warns if there are changes to package.json, and tags the team. @@ -41,13 +46,14 @@ if (packageChanged) { const includesTestPlan = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('## test plan'); -if (!includesTestPlan) { +if (!includesTestPlan && !isFromPhabricator) { + // PRs from Phabricator never exports the Test Plan so let's disable this check. const title = ':clipboard: Missing Test Plan'; const idea = 'Can you add a Test Plan? ' + 'To do so, add a "## Test Plan" section to your PR description. ' + 'A Test Plan lets us know how these changes were tested.'; - message(`${title} - ${idea}`); + warn(`${title} - ${idea}`); } // Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups @@ -57,7 +63,9 @@ const internalChangelogRegex = /\[\s?(INTERNAL)\s?\].*/gi; const includesChangelog = danger.github.pr.body && (danger.github.pr.body.toLowerCase().includes('## changelog') || - danger.github.pr.body.toLowerCase().includes('release notes')); + danger.github.pr.body.toLowerCase().includes('release notes') || + // PR exports from Phabricator have a `Changelog:` entry for the changelog. + danger.github.pr.body.toLowerCase().includes('changelog:')); const correctlyFormattedChangelog = changelogRegex.test(danger.github.pr.body); const containsInternalChangelog = internalChangelogRegex.test( danger.github.pr.body, @@ -72,25 +80,35 @@ if (!includesChangelog) { 'Can you add a Changelog? ' + 'To do so, add a "## Changelog" section to your PR description. ' + changelogInstructions; - message(`${title} - ${idea}`); + fail(`${title} - ${idea}`); } else if (!correctlyFormattedChangelog && !containsInternalChangelog) { const title = ':clipboard: Verify Changelog Format'; const idea = changelogInstructions; - message(`${title} - ${idea}`); + fail(`${title} - ${idea}`); } // Warns if the PR is opened against stable, as commits need to be cherry picked and tagged by a release maintainer. // Fails if the PR is opened against anything other than `main` or `-stable`. -const isMergeRefMaster = danger.github.pr.base.ref === 'main'; +const isMergeRefMain = danger.github.pr.base.ref === 'main'; const isMergeRefStable = danger.github.pr.base.ref.indexOf('-stable') !== -1; -if (!isMergeRefMaster && isMergeRefStable) { - const title = ':grey_question: Base Branch'; - const idea = - 'The base branch for this PR is something other than `main`. Are you sure you want to merge these changes into a stable release? If you are interested in backporting updates to an older release, the suggested approach is to land those changes on `main` first and then cherry-pick the commits into the branch for that release. The [Releases Guide](https://github.com/facebook/react-native/blob/HEAD/Releases.md) has more information.'; - warn(`${title} - ${idea}`); -} else if (!isMergeRefMaster && !isMergeRefStable) { +if (!isMergeRefMain && !isMergeRefStable) { const title = ':exclamation: Base Branch'; const idea = - 'The base branch for this PR is something other than `main`. [Are you sure you want to target something other than the `main` branch?](https://reactnative.dev/docs/contributing.html#pull-requests)'; + 'The base branch for this PR is something other than `main` or a `-stable` branch. [Are you sure you want to target something other than the `main` branch?](https://reactnative.dev/docs/contributing#pull-requests)'; fail(`${title} - ${idea}`); } + +// If the PR is opened against stable should add `Pick Request` label +if (isMergeRefStable) { + const {owner, repo, number: issueNumber} = danger.github.thisPR; + + danger.github.api.request( + 'POST /repos/{owner}/{repo}/issues/{issueNumber}/labels', + { + owner, + repo, + issueNumber, + labels: ['Pick Request'], + }, + ); +} diff --git a/bots/datastore.js b/bots/datastore.js index 04fbd69acc4c36..962b49c09a2118 100644 --- a/bots/datastore.js +++ b/bots/datastore.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/bots/make-comment.js b/bots/make-comment.js index b44260e245291b..5d117867ce0fbd 100644 --- a/bots/make-comment.js +++ b/bots/make-comment.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/bots/package.json b/bots/package.json index bd720cc62ef7b1..a5c45dfeb18674 100644 --- a/bots/package.json +++ b/bots/package.json @@ -4,12 +4,12 @@ "danger": "node ./node_modules/.bin/danger" }, "devDependencies": { - "danger": "^7.1.4", + "danger": "^11.0.2", "lodash.includes": "^4.3.0", "minimatch": "^3.0.4" }, "dependencies": { - "@octokit/rest": "^16.43.0", - "firebase": "^9.0.2" + "@octokit/rest": "^18.12.0", + "firebase": "^9.6.5" } } diff --git a/bots/post-artifacts-link.js b/bots/post-artifacts-link.js index 1a90d4b88f7651..314f782b1a2bb3 100644 --- a/bots/post-artifacts-link.js +++ b/bots/post-artifacts-link.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/bots/report-bundle-size.js b/bots/report-bundle-size.js index 38b293cd3add0f..35d1f468c42343 100644 --- a/bots/report-bundle-size.js +++ b/bots/report-bundle-size.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/bots/yarn.lock b/bots/yarn.lock index 6a3a5ad20aaa06..2bd83418391d7a 100644 --- a/bots/yarn.lock +++ b/bots/yarn.lock @@ -3,22 +3,22 @@ "@babel/polyfill@^7.2.5": - version "7.2.5" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.2.5.tgz#6c54b964f71ad27edddc567d065e57e87ed7fa7d" - integrity sha512-8Y/t3MWThtMLYr0YNC/Q76tqN1w30+b0uQMeFUYauG2UGTR19zyUtFrAzT23zNtBxPp+LbE5E/nwV/q/r3y6ug== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" + integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== dependencies: - core-js "^2.5.7" - regenerator-runtime "^0.12.0" + core-js "^2.6.5" + regenerator-runtime "^0.13.4" -"@firebase/analytics-compat@0.1.1": - version "0.1.1" - resolved "https://registry.yarnpkg.com/@firebase/analytics-compat/-/analytics-compat-0.1.1.tgz#77a3e5d28f15df303c3836db4740a43955fcfcac" - integrity sha512-pMTrA8cxMXFRv7bwZEXXz0NCepnyH2Jay/32RZ7xAufij2VJhF5S1BtfCO0wuri3FB94rlM8SmSEbwxxHcAtVg== +"@firebase/analytics-compat@0.1.6": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@firebase/analytics-compat/-/analytics-compat-0.1.6.tgz#a5a8c909c67128d89c0aaa1c87699d1c5e873746" + integrity sha512-xvdp4/zwOG1f+v9JSpfCQoPJ98HcJR42cEnZ9pRIQLmUy7L7QceIuaF3m+zVtoqa4agBQnJ1dhe58FshOFKOPw== dependencies: - "@firebase/analytics" "0.7.0" + "@firebase/analytics" "0.7.5" "@firebase/analytics-types" "0.7.0" - "@firebase/component" "0.5.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/analytics-types@0.7.0": @@ -26,26 +26,26 @@ resolved "https://registry.yarnpkg.com/@firebase/analytics-types/-/analytics-types-0.7.0.tgz#91960e7c87ce8bf18cf8dd9e55ccbf5dc3989b5d" integrity sha512-DNE2Waiwy5+zZnCfintkDtBfaW6MjIG883474v6Z0K1XZIvl76cLND4iv0YUb48leyF+PJK1KO2XrgHb/KpmhQ== -"@firebase/analytics@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@firebase/analytics/-/analytics-0.7.0.tgz#7f4450936a2cac3227cc6439130c09b9a0a7d83e" - integrity sha512-YEPyeW6CV8xbIvWaJMvfRdWUPKe/xchJ1bjV6GpLfkYRX+ZE1/YSNU14pX292M4bZ6Qg+bbu2DuWp8fEpa/YQg== +"@firebase/analytics@0.7.5": + version "0.7.5" + resolved "https://registry.yarnpkg.com/@firebase/analytics/-/analytics-0.7.5.tgz#c12a2ea10067e8e0947bc54758750c65a700e79f" + integrity sha512-vrKDh84hBbKPJaU2oAZDewyC79D8opJOQZ5AU3BXBBwEfRjKt3C3jj/Vl6aJUme+RKXlomTw3xcHIOoPzTgBVA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/installations" "0.5.0" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/installations" "0.5.5" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/app-check-compat@0.1.1": - version "0.1.1" - resolved "https://registry.yarnpkg.com/@firebase/app-check-compat/-/app-check-compat-0.1.1.tgz#84c7ef29bb683fd3dea66a66f82b799474c904ee" - integrity sha512-XTV5Ns0Lpwn5GgXV5T0soOkoOGACaw9xiNvAXcISQYFBIse0k7fKo8V5J9VUS1ppzGpyTRCg0m9efz4CNrwPyQ== +"@firebase/app-check-compat@0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@firebase/app-check-compat/-/app-check-compat-0.2.3.tgz#f6ee8b8581423fe4efbba6165c14c3f9625a95e4" + integrity sha512-e2mKkuecr1XgsyTGXKfg83PcV1UdT7+tXYoHIjeBeLrP5gGL4OQbWCzzt6uVQpk1gmJbUktje/rd6Et6cdL+wg== dependencies: - "@firebase/app-check" "0.4.0" - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/app-check" "0.5.3" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/app-check-interop-types@0.1.0": @@ -53,25 +53,25 @@ resolved "https://registry.yarnpkg.com/@firebase/app-check-interop-types/-/app-check-interop-types-0.1.0.tgz#83afd9d41f99166c2bdb2d824e5032e9edd8fe53" integrity sha512-uZfn9s4uuRsaX5Lwx+gFP3B6YsyOKUE+Rqa6z9ojT4VSRAsZFko9FRn6OxQUA1z5t5d08fY4pf+/+Dkd5wbdbA== -"@firebase/app-check@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@firebase/app-check/-/app-check-0.4.0.tgz#a048fc396b2a97ef8eba77fe909efbff07a5c75c" - integrity sha512-KQ/k8cukzZbH/LC9Iu5/Dbhr7w6byu8bYjfCA38B6v8aISgASYfP/nirxRD+hSuDoxXtAnPGEuv+v0YU3D1R2w== +"@firebase/app-check@0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@firebase/app-check/-/app-check-0.5.3.tgz#477ea3d925bde898dce1c25bc3d3886252ad2aaf" + integrity sha512-M2/UO5PgxHCl0wPYWGdF6lO8nqclwuRMCIrc+75xv3/Dr3hhUu4ztF5JNaAV5tktSCt1UrnASG+4rNVifCzSRw== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/app-compat@0.1.1": - version "0.1.1" - resolved "https://registry.yarnpkg.com/@firebase/app-compat/-/app-compat-0.1.1.tgz#47d5f5ac350f59ea4b721f17e01b1e46a1a3154a" - integrity sha512-AoUO7PnQlDPyMAvAE972kBhrwXRZRLGdHM8obyIeTzPNqIiEoULD4Rdq5TBB4UmV2HYAlYdrS+dk4nuWx67w6A== +"@firebase/app-compat@0.1.16": + version "0.1.16" + resolved "https://registry.yarnpkg.com/@firebase/app-compat/-/app-compat-0.1.16.tgz#cf006b7c9639731a9f13e9d20c6a36298f73eeef" + integrity sha512-PCGqanykO1H2jO3gzT0x7VxjZ0stBkF89VBqpOJfZ+srjSQgfWZuHjwbaVoq2Ayza1/s79iF0Eg7LSBx54TBSg== dependencies: - "@firebase/app" "0.7.0" - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/app" "0.7.15" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/app-types@0.7.0": @@ -79,26 +79,26 @@ resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.7.0.tgz#c9e16d1b8bed1a991840b8d2a725fb58d0b5899f" integrity sha512-6fbHQwDv2jp/v6bXhBw2eSRbNBpxHcd1NBF864UksSMVIqIyri9qpJB1Mn6sGZE+bnDsSQBC5j2TbMxYsJQkQg== -"@firebase/app@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.7.0.tgz#989e9f354951de2a8ac806f6e3fa0afd9f80b470" - integrity sha512-l4Pd69re6JyjumQrl719dnY5JSKROSYda/0N2wzOhSzqg8DsZOIErr8+xj6QAE6BtNsoIEk7ma9WMS/2r02MhA== +"@firebase/app@0.7.15": + version "0.7.15" + resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.7.15.tgz#b437bc6a0a2f8c592fc40812084df63aa302435f" + integrity sha512-jZzopQ5rKC3QcivZ9tBsYjPWB0+d5+lSO4tASIgAia30pyACCFaN2M1PKX/lwoGmB+oklHzSIMu+iNtLUyDl2A== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/auth-compat@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@firebase/auth-compat/-/auth-compat-0.1.2.tgz#a971cb7859eb4d45c233043bea102993376d9fca" - integrity sha512-0eqWSV4XoyOltT4HVJUzh8hBFNO5f78ZGDplRQImQ97/6wR45x6Q/9R19KTWOd109+3Axw6Orfq2cSNY0opgEA== +"@firebase/auth-compat@0.2.7": + version "0.2.7" + resolved "https://registry.yarnpkg.com/@firebase/auth-compat/-/auth-compat-0.2.7.tgz#9386ea64096a445c244061b9a8686389a560b7bc" + integrity sha512-VdwGPf5Gr6s7JCW9Y7NOuCIp/izOHVdWcVKLlotcaWep3z+C+1eTws7bbQU+sy2xbsXEXETHAM6Gb6AMu8fC4g== dependencies: - "@firebase/auth" "0.17.2" + "@firebase/auth" "0.19.7" "@firebase/auth-types" "0.11.0" - "@firebase/component" "0.5.6" - "@firebase/util" "1.3.0" - node-fetch "2.6.1" + "@firebase/component" "0.5.10" + "@firebase/util" "1.4.3" + node-fetch "2.6.7" selenium-webdriver "^4.0.0-beta.2" tslib "^2.1.0" @@ -112,67 +112,67 @@ resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.11.0.tgz#b9c73c60ca07945b3bbd7a097633e5f78fa9e886" integrity sha512-q7Bt6cx+ySj9elQHTsKulwk3+qDezhzRBFC9zlQ1BjgMueUOnGMcvqmU0zuKlQ4RhLSH7MNAdBV2znVaoN3Vxw== -"@firebase/auth@0.17.2": - version "0.17.2" - resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.17.2.tgz#54ad76cfdc2f6d1201fb780365cf7d362586f3c6" - integrity sha512-t1iHB5Eg7vAbyOEzMMarsyJNGiO2xP8Zag0hLRVXWVaWymXZnyVKp62sXqyonvz4eVT8+iGBjDySB9zKIb5Pqg== +"@firebase/auth@0.19.7": + version "0.19.7" + resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.19.7.tgz#0c537e3966fc95f9e79783c49242818426956c96" + integrity sha512-+9a5ideiY+ey3LeRsg9RdnR+BjxJwN8+nfifNl1Hucuj2MZOXIv/D6D/6xzi4XdZj3cFrFvBjZdg5nCiKZsZ7w== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" - node-fetch "2.6.1" - selenium-webdriver "4.0.0-beta.1" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" + node-fetch "2.6.7" + selenium-webdriver "4.0.0-rc-1" tslib "^2.1.0" -"@firebase/component@0.5.6": - version "0.5.6" - resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.5.6.tgz#6b7c7aff69866e0925721543a2ef5f47b0f97cbe" - integrity sha512-GyQJ+2lrhsDqeGgd1VdS7W+Y6gNYyI0B51ovNTxeZVG/W8I7t9MwEiCWsCvfm5wQgfsKp9dkzOcJrL5k8oVO/Q== +"@firebase/component@0.5.10": + version "0.5.10" + resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.5.10.tgz#eab8acfd9b1a2b6534a63cbcd7cbc7660c47663d" + integrity sha512-mzUpg6rsBbdQJvAdu1rNWabU3O7qdd+B+/ubE1b+pTbBKfw5ySRpRRE6sKcZ/oQuwLh0HHB6FRJHcylmI7jDzA== dependencies: - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/database-compat@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@firebase/database-compat/-/database-compat-0.1.0.tgz#f02abaa9f493fd14aaae6e2b34262bafc5d033c7" - integrity sha512-jLN0JMYnYijg8f3QFtSuPGNuKAt3yYVRsHHlR8sADgx8MptByRRwVmMOk7QPc/DY7qscZIJow3hXFwvbeApFLA== - dependencies: - "@firebase/component" "0.5.6" - "@firebase/database" "0.12.0" - "@firebase/database-types" "0.9.0" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" +"@firebase/database-compat@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@firebase/database-compat/-/database-compat-0.1.5.tgz#df451ce6a8d0ea2ebc2b1c8017da7d773424371d" + integrity sha512-UVxkHL24sZfsjsjs+yiKIdYdrWXHrLxSFCYNdwNXDlTkAc0CWP9AAY3feLhBVpUKk+4Cj0I4sGnyIm2C1ltAYg== + dependencies: + "@firebase/component" "0.5.10" + "@firebase/database" "0.12.5" + "@firebase/database-types" "0.9.4" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/database-types@0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.9.0.tgz#dad3db745531f40b60f7726a76b2bf6bbf6c6471" - integrity sha512-x2TeTVnMZGPvT3y4Nayio4WprQA/zGwqMrPMQwSdF+PFnaFJAhA/eLgUB6cmWFzFYO9VvmuRkFzDzo6ezTo1Zw== +"@firebase/database-types@0.9.4": + version "0.9.4" + resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.9.4.tgz#08b7da33d8dca8f5adab45bfb1cdf8654f2c6720" + integrity sha512-uAQuc6NUZ5Oh/cWZPeMValtcZ+4L1stgKOeYvz7mLn8+s03tnCDL2N47OLCHdntktVkhImQTwGNARgqhIhtNeA== dependencies: "@firebase/app-types" "0.7.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" -"@firebase/database@0.12.0": - version "0.12.0" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.12.0.tgz#2aa33138128cfcaf74388efe13e0eda10825d564" - integrity sha512-/gl6z6fAxAAFAdDllzidzweGpuXJu0b9AusSLrdW4LpP6KCuxJbhonMJuSGpHLzAHzx6Q9uitbvqHqBb17sttQ== +"@firebase/database@0.12.5": + version "0.12.5" + resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.12.5.tgz#e7f8e8052c3038aff79633e5395c3cc5c30ca7b2" + integrity sha512-1Pd2jYqvqZI7SQWAiXbTZxmsOa29PyOaPiUtr8pkLSfLp4AeyMBegYAXCLYLW6BNhKn3zNKFkxYDxYHq4q+Ixg== dependencies: "@firebase/auth-interop-types" "0.1.6" - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" - faye-websocket "0.11.3" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" + faye-websocket "0.11.4" tslib "^2.1.0" -"@firebase/firestore-compat@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@firebase/firestore-compat/-/firestore-compat-0.1.2.tgz#af9e28735376ee04c147ea3ac11b592b3f7a68ac" - integrity sha512-xtjj2qOBN0+S5KlXmWa5UozGmYJ1OAGBNT0qkCSvzQitHED5/B2fNwKnpy7Em+Zu3Yc3r/eM94OGx93USFXifg== +"@firebase/firestore-compat@0.1.13": + version "0.1.13" + resolved "https://registry.yarnpkg.com/@firebase/firestore-compat/-/firestore-compat-0.1.13.tgz#d249d9ae92b33799ca836de7d0ba48ad0c872c8a" + integrity sha512-FJSSn0zYBuf8YQAqrRWnXT/fHI/PBgwNEz6IzGw7EN7KHLWX4lCwNBFhAK5+ieJJDN3CbXjtSeVH3qc+cPiOjA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/firestore" "3.0.2" + "@firebase/component" "0.5.10" + "@firebase/firestore" "3.4.4" "@firebase/firestore-types" "2.5.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/firestore-types@2.5.0": @@ -180,29 +180,29 @@ resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-2.5.0.tgz#16fca40b6980fdb000de86042d7a96635f2bcdd7" integrity sha512-I6c2m1zUhZ5SH0cWPmINabDyH5w0PPFHk2UHsjBpKdZllzJZ2TwTkXbDtpHUZNmnc/zAa0WNMNMvcvbb/xJLKA== -"@firebase/firestore@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-3.0.2.tgz#594130bb125803b6e28611075c2f396f59ba8186" - integrity sha512-AWh1pugDifwCXHaQalZHp+Hr/3o+cxYvlbgQrPB35bh1A3do4I1xim/8Pba7gtpTzlClDryd5pK/XbK0TC/2kg== +"@firebase/firestore@3.4.4": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-3.4.4.tgz#6810b2b9a9fa2cafe7c1d1d83f9274e15b95268d" + integrity sha512-IC8KZ6LbhECch9xPWp2Kj/0dqN+douzw7SWMAfWxXKmg+CjXpoyUoCh7UU/jshWafd4AUU3OV8QTv8tXRaMpdA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" - "@firebase/webchannel-wrapper" "0.5.1" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" + "@firebase/webchannel-wrapper" "0.6.1" "@grpc/grpc-js" "^1.3.2" "@grpc/proto-loader" "^0.6.0" - node-fetch "2.6.1" + node-fetch "2.6.7" tslib "^2.1.0" -"@firebase/functions-compat@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@firebase/functions-compat/-/functions-compat-0.1.2.tgz#557461ed4f2928747461c6b2d246ac328aea3248" - integrity sha512-eisJazUrqOL/pAZJPqamYiaAyV3ch6GQMx8Sso792tvRr8SFsNCFbN9eVun0U0ubWAON5qdLoruoc6npXg6FIg== +"@firebase/functions-compat@0.1.9": + version "0.1.9" + resolved "https://registry.yarnpkg.com/@firebase/functions-compat/-/functions-compat-0.1.9.tgz#c81b98a0b1378e234533b3552dcef9529da6c389" + integrity sha512-XhcLUVgxwqyk4euz1VO/qM6LUrkbR0vibh/2triR2ciJS2epkpvPICVMxWXaetsKOVpcaTs15eGpJClCRHGLjw== dependencies: - "@firebase/component" "0.5.6" - "@firebase/functions" "0.7.1" + "@firebase/component" "0.5.10" + "@firebase/functions" "0.7.8" "@firebase/functions-types" "0.5.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/functions-types@0.5.0": @@ -210,42 +210,44 @@ resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.5.0.tgz#b50ba95ccce9e96f7cda453228ffe1684645625b" integrity sha512-qza0M5EwX+Ocrl1cYI14zoipUX4gI/Shwqv0C1nB864INAD42Dgv4v94BCyxGHBg2kzlWy8PNafdP7zPO8aJQA== -"@firebase/functions@0.7.1": - version "0.7.1" - resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.7.1.tgz#aa95aaed34649d0656d50df0ed21802f117cca88" - integrity sha512-F6XZVVBpqupCX7/YXpdzyXKYCeLVmHO/jxAKbN9I4B+c8doDqVtGkO23DPzf4ppzR4FuXDiKEEU9ZZ85kqZ1QA== +"@firebase/functions@0.7.8": + version "0.7.8" + resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.7.8.tgz#5cc45dddc42e8ce0fac7d8ce2f95e92bfbe33544" + integrity sha512-WNpKnQqufNkqHkFm1ol4oeF+/mA1y5gtj1csRFZqQS2EeDcq6FCs49abBFpjBOxWz8XDDNlSasCKhIrAAKIFfg== dependencies: "@firebase/app-check-interop-types" "0.1.0" "@firebase/auth-interop-types" "0.1.6" - "@firebase/component" "0.5.6" + "@firebase/component" "0.5.10" "@firebase/messaging-interop-types" "0.1.0" - "@firebase/util" "1.3.0" - node-fetch "2.6.1" + "@firebase/util" "1.4.3" + node-fetch "2.6.7" tslib "^2.1.0" -"@firebase/installations@0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@firebase/installations/-/installations-0.5.0.tgz#4a21e1c7467795802b031af413df2555b17cf1b1" - integrity sha512-wF1CKIx+SoiEbtNdutulxW4z80B5lGXW+8JdAtcKQwgKxF0VtlCaDFsd9AEB3aTtzIve5UkGak8hQOMvvOpydg== +"@firebase/installations@0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@firebase/installations/-/installations-0.5.5.tgz#b517e20fe4ce4b9e2f3349596391d54f2294bf7f" + integrity sha512-mYWUxYXPlxcR0YOikPw88TjIS2NK35Z0ivkJL0+FevNnVIsqwGSe12AtPlZB/kzjB0RtHoKW+cWC0V9xiTgJ3Q== dependencies: - "@firebase/component" "0.5.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/util" "1.4.3" idb "3.0.2" tslib "^2.1.0" -"@firebase/logger@0.2.6": - version "0.2.6" - resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.2.6.tgz#3aa2ca4fe10327cabf7808bd3994e88db26d7989" - integrity sha512-KIxcUvW/cRGWlzK9Vd2KB864HlUnCfdTH0taHE0sXW5Xl7+W68suaeau1oKNEqmc3l45azkd4NzXTCWZRZdXrw== +"@firebase/logger@0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.3.2.tgz#5046ffa8295c577846d54b6ca95645a03809800e" + integrity sha512-lzLrcJp9QBWpo40OcOM9B8QEtBw2Fk1zOZQdvv+rWS6gKmhQBCEMc4SMABQfWdjsylBcDfniD1Q+fUX1dcBTXA== + dependencies: + tslib "^2.1.0" -"@firebase/messaging-compat@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@firebase/messaging-compat/-/messaging-compat-0.1.0.tgz#ab164540f6ba954c8d150b2e96dc6bf8c1536eb4" - integrity sha512-58qQmKwOiXhxZwrRwwjQDbjlRx1uMVVuV/DNbDzqilDJDdoYXMdK6RBTF9Bs51qy/Z1BI2Q9B1JX01QYlgZpxQ== +"@firebase/messaging-compat@0.1.7": + version "0.1.7" + resolved "https://registry.yarnpkg.com/@firebase/messaging-compat/-/messaging-compat-0.1.7.tgz#db9066032bbb001f18d34d707e42f4703d3c8ffb" + integrity sha512-EKKcMin7myL8GXu2Mq6daje6o13VZtgxUKe+sLVL4DfxPbJdhVvNirYTi14KM81tDPdKAIakZNIGiIm/r8S2zA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/messaging" "0.9.0" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/messaging" "0.9.7" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/messaging-interop-types@0.1.0": @@ -253,28 +255,28 @@ resolved "https://registry.yarnpkg.com/@firebase/messaging-interop-types/-/messaging-interop-types-0.1.0.tgz#bdac02dd31edd5cb9eec37b1db698ea5e2c1a631" integrity sha512-DbvUl/rXAZpQeKBnwz0NYY5OCqr2nFA0Bj28Fmr3NXGqR4PAkfTOHuQlVtLO1Nudo3q0HxAYLa68ZDAcuv2uKQ== -"@firebase/messaging@0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.9.0.tgz#a868bea75d0c26210903178cf22d31c47bc84584" - integrity sha512-NTUB+gVJsgL/f6wqwUlgadaNuLZvyk1IlTcRvR3391t8jDSWOT2efwzNqcI7Xv4nhzaiPhzAQ4ncH/m8kfUUXQ== +"@firebase/messaging@0.9.7": + version "0.9.7" + resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.9.7.tgz#fa4e566f3632d3437cbc667c7755ed0c83ee38a2" + integrity sha512-qRPWO5fvS1yahe0As0rlpo+Gc3v5IKHlULGJPYvWGJWE3W5aCvooxsT3vYgYNmAMFjgLlugfg8KKd41O1ebgqg== dependencies: - "@firebase/component" "0.5.6" - "@firebase/installations" "0.5.0" + "@firebase/component" "0.5.10" + "@firebase/installations" "0.5.5" "@firebase/messaging-interop-types" "0.1.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" idb "3.0.2" tslib "^2.1.0" -"@firebase/performance-compat@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@firebase/performance-compat/-/performance-compat-0.1.0.tgz#c1edeccd9b60d83de26d8e645e0d2ddd64e9a2d7" - integrity sha512-H+/A5+y/15hFn5FHRP8lcogDzO6qm9YoACNEXn71UN4PiGQ+/BbHkQafDEXxD6wLfqfqR8u8oclHPFIYxMBF7Q== +"@firebase/performance-compat@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@firebase/performance-compat/-/performance-compat-0.1.5.tgz#e5e13629740ad28fdcbb7bb4e6e49160bbe71550" + integrity sha512-s9mqR0GXJaqvIZD/GsshacpKOGa3NP6Yht33mNEtpL7ERqj35mvD1CBoUwH52eMYAaxlQd9y9JrphQgK3EmWWw== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/performance" "0.5.0" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/performance" "0.5.5" "@firebase/performance-types" "0.1.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/performance-types@0.1.0": @@ -282,15 +284,15 @@ resolved "https://registry.yarnpkg.com/@firebase/performance-types/-/performance-types-0.1.0.tgz#5e6efa9dc81860aee2cb7121b39ae8fa137e69fc" integrity sha512-6p1HxrH0mpx+622Ql6fcxFxfkYSBpE3LSuwM7iTtYU2nw91Hj6THC8Bc8z4nboIq7WvgsT/kOTYVVZzCSlXl8w== -"@firebase/performance@0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@firebase/performance/-/performance-0.5.0.tgz#cc237e65791c75dba856ace8971b94d7adcbc60b" - integrity sha512-E+L18eJKshr/ijnWZMexEEddwkp2T4Ye2dJSK4TcOKRYfrmfZJ95RRZ+MPNp1ES7RH2JYiyym1NIQKPcNNvhug== +"@firebase/performance@0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@firebase/performance/-/performance-0.5.5.tgz#2ec0167f4d318f05a5a4fe6daac3977cc1bc598d" + integrity sha512-eA8mEKVnyY64fwAKxHbJF5t1hNkdR0EZVib0LfEWl/2elPmFcjik097hqLHzdFE88JYCxNGfFaSPo9Lbk/qe6A== dependencies: - "@firebase/component" "0.5.6" - "@firebase/installations" "0.5.0" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/installations" "0.5.5" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/polyfill@0.3.36": @@ -302,16 +304,16 @@ promise-polyfill "8.1.3" whatwg-fetch "2.0.4" -"@firebase/remote-config-compat@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@firebase/remote-config-compat/-/remote-config-compat-0.1.0.tgz#8eb2582d1909dd4d5023383e43d73ad605d56daa" - integrity sha512-PpCh5f5hUUaDCmiJsuu/u9a0g0G5WH3YSbfH1jPejVOaJ1lS82615E7WOzco4zMllLYfX62VaUYD2vvcLyXE/w== +"@firebase/remote-config-compat@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@firebase/remote-config-compat/-/remote-config-compat-0.1.5.tgz#560aef7ce56d235ac2cfbebccc65fbe9545f6574" + integrity sha512-bgpmrCGyOj46c0xNFvivcXRHlaVkbt4mX2etbF9s6jaOILPd4rBHIfAiBpKL64GGwTkrOjWO9/HZun4I01gbpg== dependencies: - "@firebase/component" "0.5.6" - "@firebase/logger" "0.2.6" - "@firebase/remote-config" "0.2.0" + "@firebase/component" "0.5.10" + "@firebase/logger" "0.3.2" + "@firebase/remote-config" "0.3.4" "@firebase/remote-config-types" "0.2.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/remote-config-types@0.2.0": @@ -319,26 +321,26 @@ resolved "https://registry.yarnpkg.com/@firebase/remote-config-types/-/remote-config-types-0.2.0.tgz#1e2759fc01f20b58c564db42196f075844c3d1fd" integrity sha512-hqK5sCPeZvcHQ1D6VjJZdW6EexLTXNMJfPdTwbD8NrXUw6UjWC4KWhLK/TSlL0QPsQtcKRkaaoP+9QCgKfMFPw== -"@firebase/remote-config@0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@firebase/remote-config/-/remote-config-0.2.0.tgz#aa2bd7b34e0e40a259c3f0409a5084864f234f0f" - integrity sha512-hNZ+BqsTmfe8ogpeow95NSwQmKIeetKdPxKpyC6RZBeFUae782+2HrUx4/Quep6OZjOHQF6xZ5d3VOxu2ZKEfg== +"@firebase/remote-config@0.3.4": + version "0.3.4" + resolved "https://registry.yarnpkg.com/@firebase/remote-config/-/remote-config-0.3.4.tgz#1197c92513130bcb1fe67c4978e6a9b034ef88be" + integrity sha512-SLlyVVNJ6DnU1AOjNrmv5u9Fge7gUwZVooyxMIkaT3Lj9MBM5MwfJsoG3UyiV4l7yI0iPj34LuKPpMJXOOcs4w== dependencies: - "@firebase/component" "0.5.6" - "@firebase/installations" "0.5.0" - "@firebase/logger" "0.2.6" - "@firebase/util" "1.3.0" + "@firebase/component" "0.5.10" + "@firebase/installations" "0.5.5" + "@firebase/logger" "0.3.2" + "@firebase/util" "1.4.3" tslib "^2.1.0" -"@firebase/storage-compat@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@firebase/storage-compat/-/storage-compat-0.1.2.tgz#98e6b3516a70799935618c32e6b8937370587929" - integrity sha512-eff0e2qcDX188mqr7aKrqr4TIS25/cE6E7Xo9WRLe3c17nqGgmrYM4DDS3VDttNbf1j5XaoEnZVZafE9/BR3Rg== +"@firebase/storage-compat@0.1.10": + version "0.1.10" + resolved "https://registry.yarnpkg.com/@firebase/storage-compat/-/storage-compat-0.1.10.tgz#94a7fbe89e901f4cd0d8fbec4be554186f897fea" + integrity sha512-l/mvUhDEJ/0/F2uBqmEqxZk+jvIEwLc9BO6lGPE3TtPdT2896u3GIzbI4XHjSLLUo5bA0ZKz8Z7GVev9CLsHfA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/storage" "0.8.2" + "@firebase/component" "0.5.10" + "@firebase/storage" "0.9.2" "@firebase/storage-types" "0.6.0" - "@firebase/util" "1.3.0" + "@firebase/util" "1.4.3" tslib "^2.1.0" "@firebase/storage-types@0.6.0": @@ -346,168 +348,147 @@ resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.6.0.tgz#0b1af64a2965af46fca138e5b70700e9b7e6312a" integrity sha512-1LpWhcCb1ftpkP/akhzjzeFxgVefs6eMD2QeKiJJUGH1qOiows2w5o0sKCUSQrvrRQS1lz3SFGvNR1Ck/gqxeA== -"@firebase/storage@0.8.2": - version "0.8.2" - resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.8.2.tgz#e08c05d070a468f0976a3d0cd32318655f0ae3b7" - integrity sha512-I9mVYhQ/DkWI1MKHhYvI4dnguXdXC50S5ryehOcR/JmSwyYjh1+T+IFQp0hHb1VWTixShzWoSGo1PhbrolFmIA== +"@firebase/storage@0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.9.2.tgz#ca7bd034a45a9ec41412238eb82fe9413b1b4653" + integrity sha512-5xWgVHnE+n+cZAnFYd3NyNAQbp6/t3NL7TdqRGu1OaW5L7ioN7Rhq+L4I2yjIskVCoTaemYQDF+vICjCWoalbA== dependencies: - "@firebase/component" "0.5.6" - "@firebase/util" "1.3.0" - node-fetch "2.6.1" + "@firebase/component" "0.5.10" + "@firebase/util" "1.4.3" + node-fetch "2.6.7" tslib "^2.1.0" -"@firebase/util@1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@firebase/util/-/util-1.3.0.tgz#e71113bdd5073e9736ceca665b54d9f6df232b20" - integrity sha512-SESvmYwuKOVCZ1ZxLbberbx+9cnbxpCa4CG2FUSQYqN6Ab8KyltegMDIsqMw5KyIBZ4n1phfHoOa22xo5NzAlQ== +"@firebase/util@1.4.3": + version "1.4.3" + resolved "https://registry.yarnpkg.com/@firebase/util/-/util-1.4.3.tgz#4358cf5f18beaa9c8a1e5a5fc4c7c44a4ccd4b7b" + integrity sha512-gQJl6r0a+MElLQEyU8Dx0kkC2coPj67f/zKZrGR7z7WpLgVanhaCUqEsptwpwoxi9RMFIaebleG+C9xxoARq+Q== dependencies: tslib "^2.1.0" -"@firebase/webchannel-wrapper@0.5.1": - version "0.5.1" - resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.5.1.tgz#a64d1af3c62e3bb89576ec58af880980a562bf4e" - integrity sha512-dZMzN0uAjwJXWYYAcnxIwXqRTZw3o14hGe7O6uhwjD1ZQWPVYA5lASgnNskEBra0knVBsOXB4KXg+HnlKewN/A== +"@firebase/webchannel-wrapper@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.6.1.tgz#0c74724ba6e9ea6ad25a391eab60a79eaba4c556" + integrity sha512-9FqhNjKQWpQ3fGnSOCovHOm+yhhiorKEqYLAfd525jWavunDJcx8rOW6i6ozAh+FbwcYMkL7b+3j4UR/30MpoQ== "@grpc/grpc-js@^1.3.2": - version "1.3.7" - resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.3.7.tgz#58b687aff93b743aafde237fd2ee9a3259d7f2d8" - integrity sha512-CKQVuwuSPh40tgOkR7c0ZisxYRiN05PcKPW72mQL5y++qd7CwBRoaJZvU5xfXnCJDFBmS3qZGQ71Frx6Ofo2XA== + version "1.5.4" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.5.4.tgz#dd0237ad7df80a7a24766fe516d7e4a22cb4855e" + integrity sha512-+nJTOsqpFAXnfFrMZ7Too4XXZ/J9O+8jYvSoaunupoC7I7b9H4iex1BRsbTdOmiowfPGJrWit7jUPmbENSUSpw== dependencies: + "@grpc/proto-loader" "^0.6.4" "@types/node" ">=12.12.47" -"@grpc/proto-loader@^0.6.0": - version "0.6.5" - resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.6.5.tgz#f23c7cb3e7076a8702f40c2b6678f06fb9950a55" - integrity sha512-GZdzyVQI1Bln/kCzIYgTKu+rQJ5dno0gVrfmLe4jqQu7T2e7svSwJzpCBqVU5hhBSJP3peuPjOMWsj5GR61YmQ== +"@grpc/proto-loader@^0.6.0", "@grpc/proto-loader@^0.6.4": + version "0.6.9" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.6.9.tgz#4014eef366da733f8e04a9ddd7376fe8a58547b7" + integrity sha512-UlcCS8VbsU9d3XTXGiEVFonN7hXk+oMXZtoHHG2oSA1/GcDP1q6OUgs20PzHDGizzyi8ufGSUDlk3O2NyY7leg== dependencies: "@types/long" "^4.0.1" lodash.camelcase "^4.3.0" long "^4.0.0" protobufjs "^6.10.0" - yargs "^16.1.1" - -"@octokit/auth-token@^2.4.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f" - integrity sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg== - dependencies: - "@octokit/types" "^2.0.0" + yargs "^16.2.0" -"@octokit/endpoint@^3.1.1": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-3.1.2.tgz#22b5aa8596482fbefc3f1ce22c24ad217aed60fa" - integrity sha512-iRx4kDYybAv9tOrHDBE6HwlgiFi8qmbZl8SHliZWtxbUFuXLZXh2yv8DxGIK9wzD9J0wLDMZneO8vNYJNUSJ9Q== - dependencies: - deepmerge "3.1.0" - is-plain-object "^2.0.4" - universal-user-agent "^2.0.1" - url-template "^2.0.8" - -"@octokit/endpoint@^5.5.0": - version "5.5.2" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.2.tgz#ed19d01fe85ac58bc2b774661658f9e5429b8164" - integrity sha512-ICDcRA0C2vtTZZGud1nXRrBLXZqFayodXAKZfo3dkdcLNqcHsgaz3YSTupbURusYeucSVRjjG+RTcQhx6HPPcg== - dependencies: - "@octokit/types" "^2.0.0" - is-plain-object "^3.0.0" - universal-user-agent "^4.0.0" - -"@octokit/plugin-paginate-rest@^1.1.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz#004170acf8c2be535aba26727867d692f7b488fc" - integrity sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q== - dependencies: - "@octokit/types" "^2.0.1" - -"@octokit/plugin-request-log@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" - integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== - -"@octokit/plugin-rest-endpoint-methods@2.4.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz#3288ecf5481f68c494dd0602fc15407a59faf61e" - integrity sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ== - dependencies: - "@octokit/types" "^2.0.1" +"@octokit/auth-token@^2.4.4": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" + integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== + dependencies: + "@octokit/types" "^6.0.3" + +"@octokit/core@^3.5.1": + version "3.5.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b" + integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw== + dependencies: + "@octokit/auth-token" "^2.4.4" + "@octokit/graphql" "^4.5.8" + "@octokit/request" "^5.6.0" + "@octokit/request-error" "^2.0.5" + "@octokit/types" "^6.0.3" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + +"@octokit/endpoint@^6.0.1": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658" + integrity sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA== + dependencies: + "@octokit/types" "^6.0.3" + is-plain-object "^5.0.0" + universal-user-agent "^6.0.0" + +"@octokit/graphql@^4.5.8": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" + integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== + dependencies: + "@octokit/request" "^5.6.0" + "@octokit/types" "^6.0.3" + universal-user-agent "^6.0.0" + +"@octokit/openapi-types@^11.2.0": + version "11.2.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6" + integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA== + +"@octokit/plugin-paginate-rest@^2.16.8": + version "2.17.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7" + integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw== + dependencies: + "@octokit/types" "^6.34.0" + +"@octokit/plugin-request-log@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" + integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== + +"@octokit/plugin-rest-endpoint-methods@^5.12.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba" + integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA== + dependencies: + "@octokit/types" "^6.34.0" deprecation "^2.3.1" -"@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801" - integrity sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA== +"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" + integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== dependencies: - "@octokit/types" "^2.0.0" + "@octokit/types" "^6.0.3" deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-2.3.0.tgz#da2672308bcf0b9376ef66f51bddbe5eb87cc00a" - integrity sha512-5YRqYNZOAaL7+nt7w3Scp6Sz4P2g7wKFP9npx1xdExMomk8/M/ICXVLYVam2wzxeY0cIc6wcKpjC5KI4jiNbGw== - dependencies: - "@octokit/endpoint" "^3.1.1" - is-plain-object "^2.0.4" - node-fetch "^2.3.0" - universal-user-agent "^2.0.1" - -"@octokit/request@^5.2.0": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.1.tgz#3a1ace45e6f88b1be4749c5da963b3a3b4a2f120" - integrity sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg== - dependencies: - "@octokit/endpoint" "^5.5.0" - "@octokit/request-error" "^1.0.1" - "@octokit/types" "^2.0.0" - deprecation "^2.0.0" - is-plain-object "^3.0.0" - node-fetch "^2.3.0" - once "^1.4.0" - universal-user-agent "^4.0.0" - -"@octokit/rest@^16.14.1": - version "16.15.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.15.0.tgz#648a88d5de055bcf38976709c5b2bdf1227b926f" - integrity sha512-Un+e7rgh38RtPOTe453pT/KPM/p2KZICimBmuZCd2wEo8PacDa4h6RqTPZs+f2DPazTTqdM7QU4LKlUjgiBwWw== - dependencies: - "@octokit/request" "2.3.0" - before-after-hook "^1.2.0" - btoa-lite "^1.0.0" - lodash.get "^4.4.2" - lodash.set "^4.3.2" - lodash.uniq "^4.5.0" - octokit-pagination-methods "^1.1.0" - universal-user-agent "^2.0.0" - url-template "^2.0.8" - -"@octokit/rest@^16.43.0": - version "16.43.1" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.1.tgz#3b11e7d1b1ac2bbeeb23b08a17df0b20947eda6b" - integrity sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw== - dependencies: - "@octokit/auth-token" "^2.4.0" - "@octokit/plugin-paginate-rest" "^1.1.1" - "@octokit/plugin-request-log" "^1.0.0" - "@octokit/plugin-rest-endpoint-methods" "2.4.0" - "@octokit/request" "^5.2.0" - "@octokit/request-error" "^1.0.2" - atob-lite "^2.0.0" - before-after-hook "^2.0.0" - btoa-lite "^1.0.0" - deprecation "^2.0.0" - lodash.get "^4.4.2" - lodash.set "^4.3.2" - lodash.uniq "^4.5.0" - octokit-pagination-methods "^1.1.0" - once "^1.4.0" - universal-user-agent "^4.0.0" +"@octokit/request@^5.6.0": + version "5.6.3" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" + integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.1.0" + "@octokit/types" "^6.16.1" + is-plain-object "^5.0.0" + node-fetch "^2.6.7" + universal-user-agent "^6.0.0" -"@octokit/types@^2.0.0", "@octokit/types@^2.0.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.1.tgz#77e80d1b663c5f1f829e5377b728fa3c4fe5a97d" - integrity sha512-89LOYH+d/vsbDX785NOfLxTW88GjNd0lWRz1DVPVsZgg9Yett5O+3MOvwo7iHgvUwbFz0mf/yPIjBkUbs4kxoQ== +"@octokit/rest@^16.43.0 || ^17.11.0 || ^18.12.0", "@octokit/rest@^18.12.0": + version "18.12.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" + integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== dependencies: - "@types/node" ">= 8" + "@octokit/core" "^3.5.1" + "@octokit/plugin-paginate-rest" "^2.16.8" + "@octokit/plugin-request-log" "^1.0.4" + "@octokit/plugin-rest-endpoint-methods" "^5.12.0" + +"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.34.0": + version "6.34.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.34.0.tgz#c6021333334d1ecfb5d370a8798162ddf1ae8218" + integrity sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw== + dependencies: + "@octokit/openapi-types" "^11.2.0" "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" @@ -567,34 +548,26 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== -"@types/node@>= 8": - version "13.7.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.1.tgz#238eb34a66431b71d2aaddeaa7db166f25971a0d" - integrity sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA== - "@types/node@>=12.12.47", "@types/node@>=13.7.0": - version "16.9.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.1.tgz#0611b37db4246c937feef529ddcc018cf8e35708" - integrity sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g== + version "17.0.14" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.14.tgz#33b9b94f789a8fedd30a68efdbca4dbb06b61f20" + integrity sha512-SbjLmERksKOGzWzPNuW7fJM7fk3YXVTFiZWB/Hs99gwhk+/dnrQRPBQjPW9aO+fi1tAffi9PrwFvsmOKmDTyng== -agent-base@4, agent-base@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" - integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg== +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== dependencies: - es6-promisify "^5.0.0" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + event-target-shim "^5.0.0" -ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= +agent-base@4, agent-base@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" + integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== + dependencies: + es6-promisify "^5.0.0" -ansi-regex@^5.0.0: +ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== @@ -613,68 +586,27 @@ ansi-styles@^4.0.0: dependencies: color-convert "^2.0.1" -arr-diff@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" - integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= - -arr-flatten@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== - -arr-union@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" - integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= - -array-unique@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" - integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= - -assign-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" - integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= - -atob-lite@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696" - integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY= +async-retry@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.2.3.tgz#a6521f338358d322b1a0012b79030c6f411d1ce0" + integrity sha512-tfDb02Th6CE6pJUF2gjW5ZVjsgwlucVXOEQMvEX9JgSJMs9gAX+Nz3xRuJBKuUYjTSYORqvDBORdAQ3LU59g7Q== + dependencies: + retry "0.12.0" -atob@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -base@^0.11.1: - version "0.11.2" - resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" - integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== - dependencies: - cache-base "^1.0.1" - class-utils "^0.3.5" - component-emitter "^1.2.1" - define-property "^1.0.0" - isobject "^3.0.1" - mixin-deep "^1.2.0" - pascalcase "^0.1.1" - -before-after-hook@^1.2.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-1.3.2.tgz#7bfbf844ad670aa7a96b5a4e4e15bd74b08ed66b" - integrity sha512-zyPgY5dgbf99c0uGUjhY4w+mxqEGxPKg9RQDl34VvrVh2bM31lFN+mwR1ZHepq/KA3VCPk1gwJZL6IIJqjLy2w== - -before-after-hook@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" - integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +before-after-hook@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" + integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== brace-expansion@^1.1.7: version "1.1.11" @@ -684,52 +616,18 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^2.3.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" - integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== +braces@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: - arr-flatten "^1.1.0" - array-unique "^0.3.2" - extend-shallow "^2.0.1" - fill-range "^4.0.0" - isobject "^3.0.1" - repeat-element "^1.1.2" - snapdragon "^0.8.1" - snapdragon-node "^2.0.1" - split-string "^3.0.2" - to-regex "^3.0.1" - -btoa-lite@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337" - integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc= + fill-range "^7.0.1" buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= -cache-base@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" - integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== - dependencies: - collection-visit "^1.0.0" - component-emitter "^1.2.1" - get-value "^2.0.6" - has-value "^1.0.0" - isobject "^3.0.1" - set-value "^2.0.0" - to-object-path "^0.3.0" - union-value "^1.0.0" - unset-value "^1.0.0" - -camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= - chalk@^2.3.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -739,25 +637,6 @@ chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -class-utils@^0.3.5: - version "0.3.6" - resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" - integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== - dependencies: - arr-union "^3.1.0" - define-property "^0.2.5" - isobject "^3.0.0" - static-extend "^0.1.1" - -cliui@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" - integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== - dependencies: - string-width "^2.1.1" - strip-ansi "^4.0.0" - wrap-ansi "^2.0.0" - cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -767,19 +646,6 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= - -collection-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" - integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= - dependencies: - map-visit "^1.0.0" - object-visit "^1.0.0" - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -804,78 +670,62 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -commander@^2.18.0: - version "2.19.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" - integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== +colors@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== -component-emitter@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" - integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== +combined-stream@^1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +commander@^2.18.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -copy-descriptor@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" - integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= - core-js@3.6.5: version "3.6.5" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a" integrity sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA== -core-js@^2.5.7: - version "2.6.4" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.4.tgz#b8897c062c4d769dd30a0ac5c73976c47f92ea0d" - integrity sha512-05qQ5hXShcqGkPZpXEFLIpxayZscVD2kuMBZewxiIPPEagukO4mqgPA9CWhUvFBJfy3ODdK2p9xyHh7FTU9/7A== +core-js@^2.6.5: + version "2.6.12" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" + integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" - -cross-spawn@^6.0.0: - version "6.0.5" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" - integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== - dependencies: - nice-try "^1.0.4" - path-key "^2.0.1" - semver "^5.5.0" - shebang-command "^1.2.0" - which "^1.2.9" - -danger@^7.1.4: - version "7.1.4" - resolved "https://registry.yarnpkg.com/danger/-/danger-7.1.4.tgz#de068b9277143505a7aaa698f27aac90c00303ae" - integrity sha512-Q6Qi7GZ58k2kyGbZkToGquM8ELtY9GR2CsfHeKGzIa77cRzaTMvn/x1W4FH3Vd0WPIASDV1yFp0xjvbK9sPcpg== + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +danger@^11.0.2: + version "11.0.2" + resolved "https://registry.yarnpkg.com/danger/-/danger-11.0.2.tgz#245b65aaf26c9b5eb3d0c65fcd403b5c31782138" + integrity sha512-TKE5E1Zrb0uV7Ft3mhbTA3bwVf4hZs7DVx6Mo8weVdIcaXJIIle3+aCjn259GX9/pF4ewoYuof7eLRPJligOgA== dependencies: "@babel/polyfill" "^7.2.5" - "@octokit/rest" "^16.14.1" + "@octokit/rest" "^18.12.0" + async-retry "1.2.3" chalk "^2.3.0" commander "^2.18.0" debug "^4.1.1" + fast-json-patch "^3.0.0-1" get-stdin "^6.0.0" + gitlab "^10.0.1" http-proxy-agent "^2.1.0" https-proxy-agent "^2.2.1" hyperlinker "^1.0.0" - jsome "^2.3.25" json5 "^2.1.0" - jsonpointer "^4.0.1" + jsonpointer "^5.0.0" jsonwebtoken "^8.4.0" lodash.find "^4.6.0" lodash.includes "^4.3.0" @@ -883,20 +733,20 @@ danger@^7.1.4: lodash.keys "^4.0.8" lodash.mapvalues "^4.6.0" lodash.memoize "^4.1.2" - memfs-or-file-map-to-github-branch "^1.1.0" - micromatch "^3.1.10" + memfs-or-file-map-to-github-branch "^1.2.1" + micromatch "^4.0.4" node-cleanup "^2.1.2" - node-fetch "^2.3.0" + node-fetch "^2.6.7" override-require "^1.1.1" p-limit "^2.1.0" - parse-diff "^0.5.1" + parse-diff "^0.7.0" parse-git-config "^2.0.3" parse-github-url "^1.0.2" - parse-link-header "^1.0.1" + parse-link-header "^2.0.0" pinpoint "^1.1.0" + prettyjson "^1.2.1" readline-sync "^1.4.9" require-from-string "^2.0.2" - rfc6902 "^3.0.1" supports-hyperlinks "^1.0.1" debug@3.1.0: @@ -906,73 +756,39 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@^2.2.0, debug@^2.3.3: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - debug@^3.1.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== dependencies: ms "^2.1.1" debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + version "4.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" + integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== dependencies: - ms "^2.1.1" - -decamelize@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + ms "2.1.2" decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deepmerge@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.1.0.tgz#a612626ce4803da410d77554bfd80361599c034d" - integrity sha512-/TnecbwXEdycfbsM2++O3eGiatEFHjjNciHEwJclM+T5Kd94qD1AP+2elP/Mq0L5b9VZJao5znR01Mz6eX8Seg== - -define-property@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" - integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= - dependencies: - is-descriptor "^0.1.0" - -define-property@^1.0.0: +delayed-stream@~1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" - integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= - dependencies: - is-descriptor "^1.0.0" - -define-property@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" - integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== - dependencies: - is-descriptor "^1.0.2" - isobject "^3.0.1" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= deprecation@^2.0.0, deprecation@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== -ecdsa-sig-formatter@1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz#1c595000f04a8897dfb85000892a0f4c33af86c3" - integrity sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM= +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== dependencies: safe-buffer "^5.0.1" @@ -982,9 +798,9 @@ emoji-regex@^8.0.0: integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== es6-promise@^4.0.3: - version "4.2.5" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054" - integrity sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg== + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== es6-promisify@^5.0.0: version "5.0.0" @@ -1003,44 +819,10 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -execa@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.10.0.tgz#ff456a8f53f90f8eccc71a96d11bdfc7f082cb50" - integrity sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw== - dependencies: - cross-spawn "^6.0.0" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - -expand-brackets@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" - integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= - dependencies: - debug "^2.3.3" - define-property "^0.2.5" - extend-shallow "^2.0.1" - posix-character-classes "^0.1.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== expand-tilde@^2.0.2: version "2.0.2" @@ -1056,95 +838,70 @@ extend-shallow@^2.0.1: dependencies: is-extendable "^0.1.0" -extend-shallow@^3.0.0, extend-shallow@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" - integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= - dependencies: - assign-symbols "^1.0.0" - is-extendable "^1.0.1" - -extglob@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" - integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== - dependencies: - array-unique "^0.3.2" - define-property "^1.0.0" - expand-brackets "^2.1.4" - extend-shallow "^2.0.1" - fragment-cache "^0.2.1" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" +fast-json-patch@^3.0.0-1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.0.tgz#ec8cd9b9c4c564250ec8b9140ef7a55f70acaee6" + integrity sha512-IhpytlsVTRndz0hU5t0/MGzS/etxLlfrpG5V5M9mVbuj9TrJLWaMfsox9REM5rkuGX0T+5qjpe8XA1o0gZ42nA== -faye-websocket@0.11.3: - version "0.11.3" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.3.tgz#5c0e9a8968e8912c286639fde977a8b209f2508e" - integrity sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA== +faye-websocket@0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" + integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== dependencies: websocket-driver ">=0.5.1" -fill-range@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" - integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== dependencies: - extend-shallow "^2.0.1" - is-number "^3.0.0" - repeat-string "^1.6.1" - to-regex-range "^2.1.0" + to-regex-range "^5.0.1" -find-up@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= - dependencies: - locate-path "^2.0.0" - -firebase@^9.0.2: - version "9.0.2" - resolved "https://registry.yarnpkg.com/firebase/-/firebase-9.0.2.tgz#092019326f1c9a67ec00ec78d50f80244581c705" - integrity sha512-+wdsD3Sk3fOgplzv4yzBmJ3Pdr01QiFF38Zq+8hzd+Dv6ZKMrgiq5CRljCaWenhZ/j8nuvHlq82u64ZARaXC+w== - dependencies: - "@firebase/analytics" "0.7.0" - "@firebase/analytics-compat" "0.1.1" - "@firebase/app" "0.7.0" - "@firebase/app-check" "0.4.0" - "@firebase/app-check-compat" "0.1.1" - "@firebase/app-compat" "0.1.1" +filter-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b" + integrity sha1-mzERErxsYSehbgFsbF1/GeCAXFs= + +firebase@^9.6.5: + version "9.6.5" + resolved "https://registry.yarnpkg.com/firebase/-/firebase-9.6.5.tgz#cf664a953e85f8c7013783db9be21f063877ca9b" + integrity sha512-RtJjR5iWU4B9FyGIQ3uorJwp9vXiu5ozAJZZjd1m2Lh9lWqfTKVQitG6nZOdK/Bcc/p4X3OEzlCcBnbi+XFZBA== + dependencies: + "@firebase/analytics" "0.7.5" + "@firebase/analytics-compat" "0.1.6" + "@firebase/app" "0.7.15" + "@firebase/app-check" "0.5.3" + "@firebase/app-check-compat" "0.2.3" + "@firebase/app-compat" "0.1.16" "@firebase/app-types" "0.7.0" - "@firebase/auth" "0.17.2" - "@firebase/auth-compat" "0.1.2" - "@firebase/database" "0.12.0" - "@firebase/database-compat" "0.1.0" - "@firebase/firestore" "3.0.2" - "@firebase/firestore-compat" "0.1.2" - "@firebase/functions" "0.7.1" - "@firebase/functions-compat" "0.1.2" - "@firebase/installations" "0.5.0" - "@firebase/messaging" "0.9.0" - "@firebase/messaging-compat" "0.1.0" - "@firebase/performance" "0.5.0" - "@firebase/performance-compat" "0.1.0" + "@firebase/auth" "0.19.7" + "@firebase/auth-compat" "0.2.7" + "@firebase/database" "0.12.5" + "@firebase/database-compat" "0.1.5" + "@firebase/firestore" "3.4.4" + "@firebase/firestore-compat" "0.1.13" + "@firebase/functions" "0.7.8" + "@firebase/functions-compat" "0.1.9" + "@firebase/installations" "0.5.5" + "@firebase/messaging" "0.9.7" + "@firebase/messaging-compat" "0.1.7" + "@firebase/performance" "0.5.5" + "@firebase/performance-compat" "0.1.5" "@firebase/polyfill" "0.3.36" - "@firebase/remote-config" "0.2.0" - "@firebase/remote-config-compat" "0.1.0" - "@firebase/storage" "0.8.2" - "@firebase/storage-compat" "0.1.2" - "@firebase/util" "1.3.0" - -for-in@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + "@firebase/remote-config" "0.3.4" + "@firebase/remote-config-compat" "0.1.5" + "@firebase/storage" "0.9.2" + "@firebase/storage-compat" "0.1.10" + "@firebase/util" "1.4.3" -fragment-cache@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" - integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= +form-data@^2.5.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" + integrity sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA== dependencies: - map-cache "^0.2.2" + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" fs-exists-sync@^0.1.0: version "0.1.0" @@ -1156,11 +913,6 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== - get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" @@ -1171,16 +923,6 @@ get-stdin@^6.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-value@^2.0.3, get-value@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" - integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= - git-config-path@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/git-config-path/-/git-config-path-1.0.1.tgz#6d33f7ed63db0d0e118131503bab3aca47d54664" @@ -1190,10 +932,23 @@ git-config-path@^1.0.1: fs-exists-sync "^0.1.0" homedir-polyfill "^1.0.0" +gitlab@^10.0.1: + version "10.2.1" + resolved "https://registry.yarnpkg.com/gitlab/-/gitlab-10.2.1.tgz#1f5fb2c2bad08f95b7c7d91dd41805ab5eea3960" + integrity sha512-z+DxRF1C9uayVbocs9aJkJz+kGy14TSm1noB/rAIEBbXOkOYbjKxyuqJzt+0zeFpXFdgA0yq6DVVbvM7HIfGwg== + dependencies: + form-data "^2.5.0" + humps "^2.0.1" + ky "^0.12.0" + ky-universal "^0.3.0" + li "^1.3.0" + query-string "^6.8.2" + universal-url "^2.0.0" + glob@^7.1.3: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -1212,48 +967,22 @@ has-flag@^3.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= -has-value@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" - integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= - dependencies: - get-value "^2.0.3" - has-values "^0.1.4" - isobject "^2.0.0" - -has-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" - integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= - dependencies: - get-value "^2.0.6" - has-values "^1.0.0" - isobject "^3.0.0" - -has-values@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" - integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= - -has-values@^1.0.0: +hasurl@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" - integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" + resolved "https://registry.yarnpkg.com/hasurl/-/hasurl-1.0.0.tgz#e4c619097ae1e8fc906bee904ce47e94f5e1ea37" + integrity sha512-43ypUd3DbwyCT01UYpA99AEZxZ4aKtRxWGBHEIbjcOsUghd9YUON0C+JF6isNjaiwC/UF5neaUudy6JS9jZPZQ== homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc" - integrity sha1-TCu8inWJmP7r9e1oWA921GdotLw= + version "1.0.3" + resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" + integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== dependencies: parse-passwd "^1.0.0" -"http-parser-js@>=0.4.0 <0.4.11": - version "0.4.10" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.4.10.tgz#92c9c1374c35085f75db359ec56cc257cbb93fa4" - integrity sha1-ksnBN0w1CF912zWexWzCV8u5P6Q= +http-parser-js@>=0.5.1: + version "0.5.5" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.5.tgz#d7c30d5d3c90d865b4a2e870181f9d6f22ac7ac5" + integrity sha512-x+JVEkO2PoM8qqpbPbOL3cqHPwerep7OwzK7Ay+sMQjKzaKCqWvjoXm5tqMP9tXWWTnTzAjIhXg+J99XYuPhPA== http-proxy-agent@^2.1.0: version "2.1.0" @@ -1264,13 +993,18 @@ http-proxy-agent@^2.1.0: debug "3.1.0" https-proxy-agent@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" - integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ== + version "2.2.4" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" + integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== dependencies: - agent-base "^4.1.0" + agent-base "^4.3.0" debug "^3.1.0" +humps@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/humps/-/humps-2.0.1.tgz#dd02ea6081bd0568dc5d073184463957ba9ef9aa" + integrity sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao= + hyperlinker@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/hyperlinker/-/hyperlinker-1.0.0.tgz#23dc9e38a206b208ee49bc2d6c8ef47027df0c0e" @@ -1300,185 +1034,53 @@ inherits@2, inherits@~2.0.3: integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== ini@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== - -invert-kv@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" - integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= - -is-accessor-descriptor@^0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" - integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= - dependencies: - kind-of "^3.0.2" - -is-accessor-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" - integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== - dependencies: - kind-of "^6.0.0" + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -is-buffer@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" - integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== - -is-data-descriptor@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" - integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= - dependencies: - kind-of "^3.0.2" - -is-data-descriptor@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" - integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== - dependencies: - kind-of "^6.0.0" - -is-descriptor@^0.1.0: - version "0.1.6" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" - integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== - dependencies: - is-accessor-descriptor "^0.1.6" - is-data-descriptor "^0.1.4" - kind-of "^5.0.0" - -is-descriptor@^1.0.0, is-descriptor@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" - integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== - dependencies: - is-accessor-descriptor "^1.0.0" - is-data-descriptor "^1.0.0" - kind-of "^6.0.2" - -is-extendable@^0.1.0, is-extendable@^0.1.1: +is-extendable@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= -is-extendable@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" - integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== - dependencies: - is-plain-object "^2.0.4" - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= - is-fullwidth-code-point@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-number@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= - dependencies: - kind-of "^3.0.2" - -is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-plain-object@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.0.tgz#47bfc5da1b5d50d64110806c199359482e75a928" - integrity sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg== - dependencies: - isobject "^4.0.0" - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-windows@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" - integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== -isarray@1.0.0, isarray@~1.0.0: +isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= - dependencies: - isarray "1.0.0" - -isobject@^3.0.0, isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= - -isobject@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" - integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== - -jsome@^2.3.25: - version "2.5.0" - resolved "https://registry.yarnpkg.com/jsome/-/jsome-2.5.0.tgz#5e417eef4341ffeb83ee8bfa9265b36d56fe49ed" - integrity sha1-XkF+70NB/+uD7ov6kmWzbVb+Se0= - dependencies: - chalk "^2.3.0" - json-stringify-safe "^5.0.1" - yargs "^11.0.0" - -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - json5@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850" - integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ== + version "2.2.0" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" + integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== dependencies: - minimist "^1.2.0" + minimist "^1.2.5" -jsonpointer@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" - integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= +jsonpointer@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-5.0.0.tgz#f802669a524ec4805fa7389eadbc9921d5dc8072" + integrity sha512-PNYZIdMjVIvVgDSYKTT63Y+KZ6IZvGRNNWcxwD+GNnUz1MKPfv30J8ueCjdwcN0nDx2SlshgyB7Oy0epAzVRRg== jsonwebtoken@^8.4.0: - version "8.4.0" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.4.0.tgz#8757f7b4cb7440d86d5e2f3becefa70536c8e46a" - integrity sha512-coyXjRTCy0pw5WYBpMvWOMN+Kjaik2MwTUIq9cna/W7NpO9E+iYbumZONAz3hcr+tXFJECoQVrtmIoC3Oz0gvg== + version "8.5.1" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" + integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== dependencies: - jws "^3.1.5" + jws "^3.2.2" lodash.includes "^4.3.0" lodash.isboolean "^3.0.3" lodash.isinteger "^4.0.4" @@ -1487,8 +1089,9 @@ jsonwebtoken@^8.4.0: lodash.isstring "^4.0.1" lodash.once "^4.0.0" ms "^2.1.1" + semver "^5.6.0" -jszip@^3.5.0, jszip@^3.6.0: +jszip@^3.6.0: version "3.7.1" resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.7.1.tgz#bd63401221c15625a1228c556ca8a68da6fda3d9" integrity sha512-ghL0tz1XG9ZEmRMcEN2vt7xabrDdqHHeykgARpmZ0BiIctWxM47Vt63ZO2dnp4QYt/xJVLLy5Zv1l/xRdh2byg== @@ -1498,53 +1101,40 @@ jszip@^3.5.0, jszip@^3.6.0: readable-stream "~2.3.6" set-immediate-shim "~1.0.1" -jwa@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.2.0.tgz#606da70c1c6d425cad329c77c99f2df2a981489a" - integrity sha512-Grku9ZST5NNQ3hqNUodSkDfEBqAmGA1R8yiyPHOnLzEKI0GaCQC/XhFmsheXYuXzFQJdILbh+lYBiliqG5R/Vg== +jwa@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.1.tgz#743c32985cb9e98655530d53641b66c8645b039a" + integrity sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA== dependencies: buffer-equal-constant-time "1.0.1" - ecdsa-sig-formatter "1.0.10" + ecdsa-sig-formatter "1.0.11" safe-buffer "^5.0.1" -jws@^3.1.5: - version "3.2.1" - resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.1.tgz#d79d4216a62c9afa0a3d5e8b5356d75abdeb2be5" - integrity sha512-bGA2omSrFUkd72dhh05bIAN832znP4wOU3lfuXtRBuGTbsmNmDXMQg28f0Vsxaxgk4myF5YkKQpz6qeRpMgX9g== - dependencies: - jwa "^1.2.0" - safe-buffer "^5.0.1" - -kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: +jws@^3.2.2: version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304" + integrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA== dependencies: - is-buffer "^1.1.5" + jwa "^1.4.1" + safe-buffer "^5.0.1" -kind-of@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= +ky-universal@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/ky-universal/-/ky-universal-0.3.0.tgz#3fcbb0dd03da39b5f05100d9362a630d5e1d402e" + integrity sha512-CM4Bgb2zZZpsprcjI6DNYTaH3oGHXL2u7BU4DK+lfCuC4snkt9/WRpMYeKbBbXscvKkeqBwzzjFX2WwmKY5K/A== dependencies: - is-buffer "^1.1.5" + abort-controller "^3.0.0" + node-fetch "^2.6.0" -kind-of@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" - integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== - -kind-of@^6.0.0, kind-of@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" - integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== +ky@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/ky/-/ky-0.12.0.tgz#c05be95e6745ba422a6d2cc8ae964164962279f9" + integrity sha512-t9b7v3V2fGwAcQnnDDQwKQGF55eWrf4pwi1RN08Fy8b/9GEwV7Ea0xQiaSW6ZbeghBHIwl8kgnla4vVo9seepQ== -lcid@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" - integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= - dependencies: - invert-kv "^1.0.0" +li@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/li/-/li-1.3.0.tgz#22c59bcaefaa9a8ef359cf759784e4bf106aea1b" + integrity sha1-IsWbyu+qmo7zWc91l4TkvxBq6hs= lie@~3.3.0: version "3.3.0" @@ -1553,14 +1143,6 @@ lie@~3.3.0: dependencies: immediate "~3.0.5" -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - lodash.camelcase@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" @@ -1571,11 +1153,6 @@ lodash.find@^4.6.0: resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1" integrity sha1-ywcE1Hq3F4n/oN6Ll92Sb7iLE7E= -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= - lodash.includes@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" @@ -1631,86 +1208,42 @@ lodash.once@^4.0.0: resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= -lodash.set@^4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" - integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= - -lodash.uniq@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" - integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= long@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -lru-cache@^4.0.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== +memfs-or-file-map-to-github-branch@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/memfs-or-file-map-to-github-branch/-/memfs-or-file-map-to-github-branch-1.2.1.tgz#fdb9a85408262316a9bd5567409bf89be7d72f96" + integrity sha512-I/hQzJ2a/pCGR8fkSQ9l5Yx+FQ4e7X6blNHyWBm2ojeFLT3GVzGkTj7xnyWpdclrr7Nq4dmx3xrvu70m3ypzAQ== dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" + "@octokit/rest" "^16.43.0 || ^17.11.0 || ^18.12.0" -macos-release@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" - integrity sha512-iCM3ZGeqIzlrH7KxYK+fphlJpCCczyHXc+HhRVbEu9uNTCrzYJjvvtefzeKTCVHd5AP/aD/fzC80JZ4ZP+dQ/A== - -macos-release@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f" - integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA== - -map-cache@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" - integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= - -map-visit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" - integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= +micromatch@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" + integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== dependencies: - object-visit "^1.0.0" + braces "^3.0.1" + picomatch "^2.2.3" -mem@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" - integrity sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y= - dependencies: - mimic-fn "^1.0.0" +mime-db@1.51.0: + version "1.51.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" + integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== -memfs-or-file-map-to-github-branch@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/memfs-or-file-map-to-github-branch/-/memfs-or-file-map-to-github-branch-1.1.2.tgz#9d46c02481b7eca8e5ee8a94f170b7e0138cad67" - integrity sha512-D2JKK2DTuVYQqquBWco3K6UfSVyVwmd58dgNqh+TgxHOZdTmR8I130gjMbVCkemDl/EzqDA62417cJxKL3/FFA== - -micromatch@^3.1.10: - version "3.1.10" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" - integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - braces "^2.3.1" - define-property "^2.0.2" - extend-shallow "^3.0.2" - extglob "^2.0.4" - fragment-cache "^0.2.1" - kind-of "^6.0.2" - nanomatch "^1.2.9" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.2" - -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== +mime-types@^2.1.12: + version "2.1.34" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" + integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== + dependencies: + mime-db "1.51.0" minimatch@^3.0.4: version "3.0.4" @@ -1719,105 +1252,37 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= - -mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== - dependencies: - for-in "^1.0.2" - is-extendable "^1.0.1" +minimist@^1.2.0, minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - -nanomatch@^1.2.9: - version "1.2.13" - resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" - integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - define-property "^2.0.2" - extend-shallow "^3.0.2" - fragment-cache "^0.2.1" - is-windows "^1.0.2" - kind-of "^6.0.2" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -nice-try@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" - integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== node-cleanup@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c" integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw= -node-fetch@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" - integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== - -node-fetch@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5" - integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA== - -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= - -object-copy@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" - integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= - dependencies: - copy-descriptor "^0.1.0" - define-property "^0.2.5" - kind-of "^3.0.3" - -object-visit@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" - integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= +node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: - isobject "^3.0.0" - -object.pick@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" - integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= - dependencies: - isobject "^3.0.1" - -octokit-pagination-methods@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4" - integrity sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ== + whatwg-url "^5.0.0" once@^1.3.0, once@^1.4.0: version "1.4.0" @@ -1826,81 +1291,32 @@ once@^1.3.0, once@^1.4.0: dependencies: wrappy "1" -os-locale@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" - integrity sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA== - dependencies: - execa "^0.7.0" - lcid "^1.0.0" - mem "^1.1.0" - -os-name@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.0.0.tgz#e1434dbfddb8e74b44c98b56797d951b7648a5d9" - integrity sha512-7c74tib2FsdFbQ3W+qj8Tyd1R3Z6tuVRNNxXjJcZ4NgjIEQU9N/prVMqcW29XZPXGACqaXN3jq58/6hoaoXH6g== - dependencies: - macos-release "^2.0.0" - windows-release "^3.1.0" - -os-name@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801" - integrity sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg== - dependencies: - macos-release "^2.2.0" - windows-release "^3.1.0" - override-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/override-require/-/override-require-1.1.1.tgz#6ae22fadeb1f850ffb0cf4c20ff7b87e5eb650df" integrity sha1-auIvresfhQ/7DPTCD/e4fl62UN8= -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-limit@^1.1.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" - integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== - dependencies: - p-try "^1.0.0" - p-limit@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.1.0.tgz#1d5a0d20fb12707c758a655f6bbc4386b5930d68" - integrity sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g== + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== dependencies: p-try "^2.0.0" -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= - dependencies: - p-limit "^1.1.0" - -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= - p-try@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1" - integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ== + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== pako@~1.0.2: version "1.0.11" resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== -parse-diff@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/parse-diff/-/parse-diff-0.5.1.tgz#18b3e82a0765ac1c8796e3854e475073a691c4fb" - integrity sha512-/qXjo9x/pFa5bVk/ZXaJD0yr3Tf3Yp6MWWMr4vnUmumDrE0yoE6YDH2A8vmcCD/Ko3tW2o0X+zGYh2zMLXshsg== +parse-diff@^0.7.0: + version "0.7.1" + resolved "https://registry.yarnpkg.com/parse-diff/-/parse-diff-0.7.1.tgz#9b7a2451c3725baf2c87c831ba192d40ee2237d4" + integrity sha512-1j3l8IKcy4yRK2W4o9EYvJLSzpAVwz4DXqCewYyx2vEwk2gcf3DBPqc8Fj4XV3K33OYJ08A8fWwyu/ykD/HUSg== parse-git-config@^2.0.3: version "2.0.3" @@ -1916,10 +1332,10 @@ parse-github-url@^1.0.2: resolved "https://registry.yarnpkg.com/parse-github-url/-/parse-github-url-1.0.2.tgz#242d3b65cbcdda14bb50439e3242acf6971db395" integrity sha512-kgBf6avCbO3Cn6+RnzRGLkUsv4ZVqv/VfAYkRsyBcgkshNvVBkRn1FEZcW0Jb+npXQWm2vHPnnOqFteZxRRGNw== -parse-link-header@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parse-link-header/-/parse-link-header-1.0.1.tgz#bedfe0d2118aeb84be75e7b025419ec8a61140a7" - integrity sha1-vt/g0hGK64S+deewJUGeyKYRQKc= +parse-link-header@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/parse-link-header/-/parse-link-header-2.0.0.tgz#949353e284f8aa01f2ac857a98f692b57733f6b7" + integrity sha512-xjU87V0VyHZybn2RrCX5TIFGxTVZE6zqqZWMPlIKiSKuWh/X5WZdt+w1Ki1nXB+8L/KtL+nZ4iq+sfI6MrhhMw== dependencies: xtend "~4.0.1" @@ -1928,35 +1344,28 @@ parse-passwd@^1.0.0: resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= -pascalcase@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" - integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= - -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= - path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-key@^2.0.0, path-key@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" - integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= +picomatch@^2.2.3: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== pinpoint@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pinpoint/-/pinpoint-1.1.0.tgz#0cf7757a6977f1bf7f6a32207b709e377388e874" integrity sha1-DPd1eml38b9/ajIge3CeN3OI6HQ= -posix-character-classes@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" - integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +prettyjson@^1.2.1: + version "1.2.5" + resolved "https://registry.yarnpkg.com/prettyjson/-/prettyjson-1.2.5.tgz#ef3cfffcc70505c032abc59785884b4027031835" + integrity sha512-rksPWtoZb2ZpT5OVgtmy0KHVM+Dca3iVwWY9ifwhcexfjebtgjg3wmrUt9PvJ59XIYBcknQeYHD8IAnVlh9lAw== + dependencies: + colors "1.4.0" + minimist "^1.2.0" process-nextick-args@~2.0.0: version "2.0.1" @@ -1987,10 +1396,20 @@ protobufjs@^6.10.0: "@types/node" ">=13.7.0" long "^4.0.0" -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +query-string@^6.8.2: + version "6.14.1" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.14.1.tgz#7ac2dca46da7f309449ba0f86b1fd28255b0c86a" + integrity sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw== + dependencies: + decode-uri-component "^0.2.0" + filter-obj "^1.1.0" + split-on-first "^1.0.0" + strict-uri-encode "^2.0.0" readable-stream@~2.3.6: version "2.3.7" @@ -2006,32 +1425,14 @@ readable-stream@~2.3.6: util-deprecate "~1.0.1" readline-sync@^1.4.9: - version "1.4.9" - resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.9.tgz#3eda8e65f23cd2a17e61301b1f0003396af5ecda" - integrity sha1-PtqOZfI80qF+YTAbHwADOWr17No= - -regenerator-runtime@^0.12.0: - version "0.12.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" - integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== - -regex-not@^1.0.0, regex-not@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" - integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== - dependencies: - extend-shallow "^3.0.2" - safe-regex "^1.1.0" - -repeat-element@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" - integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + version "1.4.10" + resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.10.tgz#41df7fbb4b6312d673011594145705bf56d8873b" + integrity sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw== -repeat-string@^1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +regenerator-runtime@^0.13.4: + version "0.13.9" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" + integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== require-directory@^2.1.1: version "2.1.1" @@ -2043,32 +1444,10 @@ require-from-string@^2.0.2: resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= - -resolve-url@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" - integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= - -ret@~0.1.10: - version "0.1.15" - resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" - integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== - -rfc6902@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/rfc6902/-/rfc6902-3.0.1.tgz#03a3d38329dbc266fbc92aa7fc14546d7839e89f" - integrity sha512-a4t5OlaOgAejBg48/lkyQMcV6EWpljjSjmXAtSXLhw83x1OhlcVGLMLf//GoUSpHsWt8x/7oxaf5FEGM9QH/iQ== - -rimraf@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" +retry@0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" + integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" @@ -2077,34 +1456,17 @@ rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" -safe-buffer@>=5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" - integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== +safe-buffer@>=5.1.0, safe-buffer@^5.0.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" - integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= - dependencies: - ret "~0.1.10" - -selenium-webdriver@4.0.0-beta.1: - version "4.0.0-beta.1" - resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.0.0-beta.1.tgz#db645b0d775f26e4e12235db05796a1bc1e7efda" - integrity sha512-DJ10z6Yk+ZBaLrt1CLElytQ/FOayx29ANKDtmtyW1A6kCJx3+dsc5fFMOZxwzukDniyYsC3OObT5pUAsgkjpxQ== - dependencies: - jszip "^3.5.0" - rimraf "^2.7.1" - tmp "^0.2.1" - ws "^7.3.1" - -selenium-webdriver@^4.0.0-beta.2: +selenium-webdriver@4.0.0-rc-1: version "4.0.0-rc-1" resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.0.0-rc-1.tgz#b1e7e5821298c8a071e988518dd6b759f0c41281" integrity sha512-bcrwFPRax8fifRP60p7xkWDGSJJoMkPAzufMlk5K2NyLPht/YZzR2WcIk1+3gR8VOCLlst1P2PI+MXACaFzpIw== @@ -2114,149 +1476,43 @@ selenium-webdriver@^4.0.0-beta.2: tmp "^0.2.1" ws ">=7.4.6" -semver@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" - integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== +selenium-webdriver@^4.0.0-beta.2: + version "4.1.1" + resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.1.1.tgz#da083177d811f36614950e809e2982570f67d02e" + integrity sha512-Fr9e9LC6zvD6/j7NO8M1M/NVxFX67abHcxDJoP5w2KN/Xb1SyYLjMVPGgD14U2TOiKe4XKHf42OmFw9g2JgCBQ== + dependencies: + jszip "^3.6.0" + tmp "^0.2.1" + ws ">=7.4.6" -set-blocking@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= +semver@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== set-immediate-shim@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" integrity sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E= -set-value@^0.4.3: - version "0.4.3" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" - integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.1" - to-object-path "^0.3.0" +split-on-first@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f" + integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw== -set-value@^2.0.0: +strict-uri-encode@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" - integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg== - dependencies: - extend-shallow "^2.0.1" - is-extendable "^0.1.1" - is-plain-object "^2.0.3" - split-string "^3.0.1" - -shebang-command@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" - integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= - dependencies: - shebang-regex "^1.0.0" - -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= - -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= - -snapdragon-node@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" - integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== - dependencies: - define-property "^1.0.0" - isobject "^3.0.0" - snapdragon-util "^3.0.1" - -snapdragon-util@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" - integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== - dependencies: - kind-of "^3.2.0" - -snapdragon@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" - integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== - dependencies: - base "^0.11.1" - debug "^2.2.0" - define-property "^0.2.5" - extend-shallow "^2.0.1" - map-cache "^0.2.2" - source-map "^0.5.6" - source-map-resolve "^0.5.0" - use "^3.1.0" - -source-map-resolve@^0.5.0: - version "0.5.2" - resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" - integrity sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA== - dependencies: - atob "^2.1.1" - decode-uri-component "^0.2.0" - resolve-url "^0.2.1" - source-map-url "^0.4.0" - urix "^0.1.0" - -source-map-url@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" - integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= - -source-map@^0.5.6: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -split-string@^3.0.1, split-string@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" - integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== - dependencies: - extend-shallow "^3.0.0" - -static-extend@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" - integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= - dependencies: - define-property "^0.2.5" - object-copy "^0.1.0" - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -string-width@^2.0.0, string-width@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" - integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== - dependencies: - is-fullwidth-code-point "^2.0.0" - strip-ansi "^4.0.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" + integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= string-width@^4.1.0, string-width@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: emoji-regex "^8.0.0" is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" + strip-ansi "^6.0.1" string_decoder@~1.1.1: version "1.1.1" @@ -2265,31 +1521,12 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= - dependencies: - ansi-regex "^2.0.0" - -strip-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= - dependencies: - ansi-regex "^3.0.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^5.0.0" - -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= + ansi-regex "^5.0.1" supports-color@^5.0.0, supports-color@^5.3.0: version "5.5.0" @@ -2313,133 +1550,93 @@ tmp@^0.2.1: dependencies: rimraf "^3.0.0" -to-object-path@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" - integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - kind-of "^3.0.2" + is-number "^7.0.0" -to-regex-range@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" - integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk= dependencies: - is-number "^3.0.0" - repeat-string "^1.6.1" + punycode "^2.1.0" -to-regex@^3.0.1, to-regex@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" - integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== - dependencies: - define-property "^2.0.2" - extend-shallow "^3.0.2" - regex-not "^1.0.2" - safe-regex "^1.1.0" +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= tslib@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== -union-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" - integrity sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ= - dependencies: - arr-union "^3.1.0" - get-value "^2.0.6" - is-extendable "^0.1.1" - set-value "^0.4.3" - -universal-user-agent@^2.0.0, universal-user-agent@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-2.0.3.tgz#9f6f09f9cc33de867bb720d84c08069b14937c6c" - integrity sha512-eRHEHhChCBHrZsA4WEhdgiOKgdvgrMIHwnwnqD0r5C6AO8kwKcG7qSku3iXdhvHL3YvsS9ZkSGN8h/hIpoFC8g== - dependencies: - os-name "^3.0.0" - -universal-user-agent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16" - integrity sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA== - dependencies: - os-name "^3.1.0" - -unset-value@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" - integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= +universal-url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universal-url/-/universal-url-2.0.0.tgz#35e7fc2c3374804905cee67ea289ed3a47669809" + integrity sha512-3DLtXdm/G1LQMCnPj+Aw7uDoleQttNHp2g5FnNQKR6cP6taNWS1b/Ehjjx4PVyvejKi3TJyu8iBraKM4q3JQPg== dependencies: - has-value "^0.3.1" - isobject "^3.0.0" + hasurl "^1.0.0" + whatwg-url "^7.0.0" -urix@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" - integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= - -url-template@^2.0.8: - version "2.0.8" - resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21" - integrity sha1-/FZaPMy/93MMd19WQflVV5FDnyE= - -use@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" - integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== +universal-user-agent@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" + integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= + +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + websocket-driver@>=0.5.1: - version "0.7.3" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.3.tgz#a2d4e0d4f4f116f1e6297eba58b05d430100e9f9" - integrity sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg== + version "0.7.4" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" + integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== dependencies: - http-parser-js ">=0.4.0 <0.4.11" + http-parser-js ">=0.5.1" safe-buffer ">=5.1.0" websocket-extensions ">=0.1.1" websocket-extensions@>=0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" - integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== whatwg-fetch@2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== -which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= - -which@^1.2.9: - version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== - dependencies: - isexe "^2.0.0" - -windows-release@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/windows-release/-/windows-release-3.1.0.tgz#8d4a7e266cbf5a233f6c717dac19ce00af36e12e" - integrity sha512-hBb7m7acFgQPQc222uEQTmdcGLeBmQLNLFIh0rDk3CwFOBrfjefLzEfEfmpMq8Af/n/GnFf3eYf203FY1PmudA== +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= dependencies: - execa "^0.10.0" + tr46 "~0.0.3" + webidl-conversions "^3.0.0" -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= +whatwg-url@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" + integrity sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg== dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" wrap-ansi@^7.0.0: version "7.0.0" @@ -2456,66 +1653,26 @@ wrappy@1: integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= ws@>=7.4.6: - version "8.2.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.2.tgz#ca684330c6dd6076a737250ed81ac1606cb0a63e" - integrity sha512-Q6B6H2oc8QY3llc3cB8kVmQ6pnJWVQbP7Q5algTcIxx7YEpc0oU4NBVHlztA7Ekzfhw2r0rPducMUiCGWKQRzw== - -ws@^7.3.1: - version "7.5.5" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.5.tgz#8b4bc4af518cfabd0473ae4f99144287b33eb881" - integrity sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w== + version "8.4.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.2.tgz#18e749868d8439f2268368829042894b6907aa0b" + integrity sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA== xtend@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" - integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= - -y18n@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= - yargs-parser@^20.2.2: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs-parser@^9.0.2: - version "9.0.2" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077" - integrity sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc= - dependencies: - camelcase "^4.1.0" - -yargs@^11.0.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.1.0.tgz#90b869934ed6e871115ea2ff58b03f4724ed2d77" - integrity sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A== - dependencies: - cliui "^4.0.0" - decamelize "^1.1.1" - find-up "^2.1.0" - get-caller-file "^1.0.1" - os-locale "^2.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1" - yargs-parser "^9.0.2" - -yargs@^16.1.1: +yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== diff --git a/build.gradle.kts b/build.gradle.kts index dbe8e69b2d615b..d08c06c100347d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,49 +1,72 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ +val ndkPath by extra(System.getenv("ANDROID_NDK")) +val ndkVersion by extra(System.getenv("ANDROID_NDK_VERSION")) + buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - val kotlin_version: String by project - classpath("com.android.tools.build:gradle:4.2.2") - classpath("de.undercouch:gradle-download-task:4.1.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } + repositories { + google() + mavenCentral() + } + dependencies { + classpath("com.android.tools.build:gradle:7.2.1") + classpath("de.undercouch:gradle-download-task:5.0.1") + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } } allprojects { - repositories { - maven { - url = uri("$rootDir/node_modules/jsc-android/dist") - } - maven { - // https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md - // All of Detox's artifacts are provided via the npm module - url = uri("$rootDir/node_modules/detox/Detox-android") - } - google() - mavenCentral { - // We don't want to fetch react-native from Maven Central as there are - // older versions over there. - content { - excludeGroup("com.facebook.react") - } - } + repositories { + maven { url = uri("$rootDir/node_modules/jsc-android/dist") } + maven { url = uri("$rootDir/android") } + google() + mavenCentral { + // We don't want to fetch react-native from Maven Central as there are + // older versions over there. + content { excludeGroup("com.facebook.react") } } + } +} - // used to override ndk path/version from env variables on CI - ext["ANDROID_NDK_PATH"] = null - if (System.getenv("LOCAL_ANDROID_NDK_VERSION") != null) { - setProperty("ANDROID_NDK_VERSION", System.getenv("LOCAL_ANDROID_NDK_VERSION")) - ext["ANDROID_NDK_PATH"] = System.getenv("ANDROID_NDK") - } +tasks.register("cleanAll", Delete::class.java) { + description = "Remove all the build files and intermediate build outputs" + dependsOn(gradle.includedBuild("react-native-gradle-plugin").task(":clean")) + delete(allprojects.map { it.buildDir }) + delete(rootProject.file("./ReactAndroid/.cxx")) + delete(rootProject.file("./ReactAndroid/hermes-engine/.cxx")) + delete(rootProject.file("./sdks/download/")) + delete(rootProject.file("./sdks/hermes/")) + delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/")) + delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/")) + delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/x86/")) + delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/x86_64/")) + delete(rootProject.file("./packages/react-native-codegen/lib")) + delete(rootProject.file("./packages/rn-tester/android/app/.cxx")) +} + +tasks.register("buildAll") { + description = "Build and test all the React Native relevant projects." + dependsOn(gradle.includedBuild("react-native-gradle-plugin").task(":build")) + // This builds both the React Native framework for both debug and release + dependsOn(":ReactAndroid:assemble") + // This creates all the Maven artifacts and makes them available in the /android folder + dependsOn(":ReactAndroid:installArchives") + // This builds RN Tester for Hermes/JSC for debug only + dependsOn(":packages:rn-tester:android:app:assembleDebug") +} + +tasks.register("downloadAll") { + description = "Download all the depedencies needed locally so they can be cached on CI." + dependsOn(gradle.includedBuild("react-native-gradle-plugin").task(":dependencies")) + dependsOn(":ReactAndroid:downloadNdkBuildDependencies") + dependsOn(":ReactAndroid:dependencies") + dependsOn(":ReactAndroid:androidDependencies") + dependsOn(":ReactAndroid:hermes-engine:dependencies") + dependsOn(":ReactAndroid:hermes-engine:androidDependencies") } diff --git a/cli.js b/cli.js index 7e2f49a760892c..609c8498e5c609 100755 --- a/cli.js +++ b/cli.js @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow-typed/npm/prop-types_v15.x.x.js b/flow-typed/npm/prop-types_v15.x.x.js deleted file mode 100644 index f5f6dba9e23852..00000000000000 --- a/flow-typed/npm/prop-types_v15.x.x.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @flow strict - * @nolint - * @format - */ - -// flow-typed signature: d9a983bb1ac458a256c31c139047bdbb -// flow-typed version: 927687984d/prop-types_v15.x.x/flow_>=v0.41.x - -type $npm$propTypes$ReactPropsCheckType = ( - props: any, - propName: string, - componentName: string, - href?: string, -) => ?Error; - -declare module 'prop-types' { - declare var array: React$PropType$Primitive>; - declare var bool: React$PropType$Primitive; - declare var func: React$PropType$Primitive; - declare var number: React$PropType$Primitive; - declare var object: React$PropType$Primitive; - declare var string: React$PropType$Primitive; - declare var symbol: React$PropType$Primitive; - declare var any: React$PropType$Primitive; - declare var arrayOf: React$PropType$ArrayOf; - declare var element: React$PropType$Primitive; /* TODO */ - declare var instanceOf: React$PropType$InstanceOf; - declare var node: React$PropType$Primitive; /* TODO */ - declare var objectOf: React$PropType$ObjectOf; - declare var oneOf: React$PropType$OneOf; - declare var oneOfType: React$PropType$OneOfType; - declare var shape: React$PropType$Shape; - - declare function checkPropTypes( - propTypes: {[_: $Keys]: $npm$propTypes$ReactPropsCheckType, ...}, - values: V, - location: string, - componentName: string, - getStack: ?() => ?string, - ): void; -} diff --git a/flow/HermesInternalType.js b/flow/HermesInternalType.js index c9d11b1d0f56cb..134adf9c2cb447 100644 --- a/flow/HermesInternalType.js +++ b/flow/HermesInternalType.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/JSITimerInternalType.js b/flow/JSITimerInternalType.js new file mode 100644 index 00000000000000..d6ace6a943749e --- /dev/null +++ b/flow/JSITimerInternalType.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +// Declarations for functionality exposed by Hermes' TimerStats decorator. +// +// For backwards-compatibility, code that uses such functionality must also +// check explicitly at run-time whether the object(s) and method(s) exist, and +// fail safely if not. + +/** + * JSITimerInternalType is the global object installed by Hermes' TimedRuntime + * decorator, and it is used to extract runtime timing information. + */ +declare type $JSITimerInternalType = { + /** + * Returns the counters that TimedRuntime keep track. + * There are no guarantees about what keys exist in it, but they can be + * printed for informational purposes. + * @return An object that maps strings to various types of performance + * statistics. + */ + +getTimes?: () => {[string]: number | string, ...}, +}; diff --git a/flow/Position.js b/flow/Position.js index b831a3d2097fd1..eb94b2af67b84f 100644 --- a/flow/Position.js +++ b/flow/Position.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/Promise.js b/flow/Promise.js deleted file mode 100644 index 85d70bd41bae02..00000000000000 --- a/flow/Promise.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict - * @format - */ - -// These annotations are copy/pasted from the built-in Flow definitions for -// Native Promises with some non-standard APIs added in -declare class Promise<+R> { - constructor( - callback: ( - resolve: (result?: Promise | R) => void, - reject: (error?: any) => void, - ) => mixed, - ): void; - - then( - onFulfill?: ?(value: R) => Promise | ?U, - onReject?: ?(error: any) => Promise | ?U, - ): Promise; - - catch(onReject?: (error: any) => ?Promise | U): Promise; - - static resolve(object?: Promise | T): Promise; - static reject(error?: any): Promise; - - static all>( - promises: T, - ): Promise<$TupleMap>; - static race(promises: Array>): Promise; - - // Non-standard APIs - - // See https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/__forks__/Promise.native.js#L21 - finally(onFinally?: ?(value: any) => Promise | U): Promise; - - done( - onFulfill?: ?(value: R) => mixed, - onReject?: ?(error: any) => mixed, - ): void; - - static cast(object?: T): Promise; -} diff --git a/flow/Stringish.js b/flow/Stringish.js index 4fbf0e7853260b..3c0eb61f8cca3b 100644 --- a/flow/Stringish.js +++ b/flow/Stringish.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/console.js b/flow/console.js index a3c431bc7bac78..10f3d30ce21017 100644 --- a/flow/console.js +++ b/flow/console.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/global.js b/flow/global.js index 3d5166f9ca8230..ee60a57fdb03cc 100644 --- a/flow/global.js +++ b/flow/global.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/jest.js b/flow/jest.js index 69cc3f50089947..8f56211696167c 100644 --- a/flow/jest.js +++ b/flow/jest.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/flow/use-subscription.js b/flow/use-sync-external-store.js similarity index 62% rename from flow/use-subscription.js rename to flow/use-sync-external-store.js index 4b555c3b60e2a5..4edac0dbfa6d47 100644 --- a/flow/use-subscription.js +++ b/flow/use-sync-external-store.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,9 +11,9 @@ 'use strict'; -declare module 'use-subscription' { - declare export function useSubscription(subscription: {| - getCurrentValue: () => Value, +declare module 'use-sync-external-store/shim' { + declare export function useSyncExternalStore( subscribe: (callback: Function) => () => void, - |}): Value; + getCurrentValue: () => Value, + ): Value; } diff --git a/gradle.properties b/gradle.properties index af9ce5ae9b642f..da451d743405fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,10 @@ # This is causing issue with dependencies task: https://github.com/gradle/gradle/issues/9645#issuecomment-530746758 # org.gradle.configureondemand=true org.gradle.daemon=true -org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8 org.gradle.parallel=true -ANDROID_NDK_VERSION=21.4.7075529 android.useAndroidX=true -kotlin_version=1.5.31 # Use this property to specify which architecture you want to build. # You can also override it from the CLI using diff --git a/gradle/gradle-enterprise.gradle.kts.sample b/gradle/gradle-enterprise.gradle.kts.sample new file mode 100644 index 00000000000000..91940e25ec4c5b --- /dev/null +++ b/gradle/gradle-enterprise.gradle.kts.sample @@ -0,0 +1,17 @@ +/* + * 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. + */ + +// You can use this script to configure the gradleEnterprise{} block in your build. +// You need to rename this file to ./gradle/gradle-enterprise.gradle.kts in order for +// this to be processed. +extensions.getByName("gradleEnterprise").withGroovyBuilder { + setProperty("server", "https://your-gradle-enterprise-instance.example.com") + getProperty("buildScan").withGroovyBuilder { + "publishAlways"() + "tag"(if(System.getenv("CI") != null) "CI" else "Local") + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae884..41d9927a4d4fb3 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071a31a26b..92f06b50fd65b4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/index.js b/index.js index 4970fa10faeb3c..d59ba3454e9cab 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -30,7 +30,6 @@ import typeof RefreshControl from './Libraries/Components/RefreshControl/Refresh import typeof SafeAreaView from './Libraries/Components/SafeAreaView/SafeAreaView'; import typeof ScrollView from './Libraries/Components/ScrollView/ScrollView'; import typeof SectionList from './Libraries/Lists/SectionList'; -import typeof SegmentedControlIOS from './Libraries/Components/SegmentedControlIOS/SegmentedControlIOS'; import typeof Slider from './Libraries/Components/Slider/Slider'; import typeof StatusBar from './Libraries/Components/StatusBar/StatusBar'; import typeof Switch from './Libraries/Components/Switch/Switch'; @@ -193,16 +192,6 @@ module.exports = { get SectionList(): SectionList { return require('./Libraries/Lists/SectionList').default; }, - // $FlowFixMe[value-as-type] - get SegmentedControlIOS(): SegmentedControlIOS { - warnOnce( - 'segmented-control-ios-moved', - 'SegmentedControlIOS has been extracted from react-native core and will be removed in a future release. ' + - "It can now be installed and imported from '@react-native-segmented-control/segmented-control' instead of 'react-native'. " + - 'See https://github.com/react-native-segmented-control/segmented-control', - ); - return require('./Libraries/Components/SegmentedControlIOS/SegmentedControlIOS'); - }, get Slider(): Slider { warnOnce( 'slider-moved', @@ -446,32 +435,32 @@ module.exports = { }, // Deprecated Prop Types get ColorPropType(): $FlowFixMe { - console.warn( - 'ColorPropType will be removed from React Native. Migrate to ' + + invariant( + false, + 'ColorPropType has been removed from React Native. Migrate to ' + "ColorPropType exported from 'deprecated-react-native-prop-types'.", ); - return require('deprecated-react-native-prop-types').ColorPropType; }, get EdgeInsetsPropType(): $FlowFixMe { - console.warn( - 'EdgeInsetsPropType will be removed from React Native. Migrate to ' + + invariant( + false, + 'EdgeInsetsPropType has been removed from React Native. Migrate to ' + "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.", ); - return require('deprecated-react-native-prop-types').EdgeInsetsPropType; }, get PointPropType(): $FlowFixMe { - console.warn( - 'PointPropType will be removed from React Native. Migrate to ' + + invariant( + false, + 'PointPropType has been removed from React Native. Migrate to ' + "PointPropType exported from 'deprecated-react-native-prop-types'.", ); - return require('deprecated-react-native-prop-types').PointPropType; }, get ViewPropTypes(): $FlowFixMe { - console.warn( - 'ViewPropTypes will be removed from React Native. Migrate to ' + + invariant( + false, + 'ViewPropTypes has been removed from React Native. Migrate to ' + "ViewPropTypes exported from 'deprecated-react-native-prop-types'.", ); - return require('deprecated-react-native-prop-types').ViewPropTypes; }, }; @@ -647,8 +636,8 @@ if (__DEV__) { invariant( false, 'ViewPagerAndroid has been removed from React Native. ' + - "It can now be installed and imported from '@react-native-community/viewpager' instead of 'react-native'. " + - 'See https://github.com/callstack/react-native-viewpager', + "It can now be installed and imported from 'react-native-pager-view' instead of 'react-native'. " + + 'See https://github.com/callstack/react-native-pager-view', ); }, }); @@ -669,6 +658,22 @@ if (__DEV__) { }, }); + /* $FlowFixMe[prop-missing] This is intentional: Flow will error when + * attempting to access SegmentedControlIOS. */ + /* $FlowFixMe[invalid-export] This is intentional: Flow will error when + * attempting to access SegmentedControlIOS. */ + Object.defineProperty(module.exports, 'SegmentedControlIOS', { + configurable: true, + get() { + invariant( + false, + 'SegmentedControlIOS has been removed from React Native. ' + + "It can now be installed and imported from '@react-native-community/segmented-checkbox' instead of 'react-native'." + + 'See https://github.com/react-native-segmented-control/segmented-control', + ); + }, + }); + /* $FlowFixMe[prop-missing] This is intentional: Flow will error when * attempting to access StatusBarIOS. */ /* $FlowFixMe[invalid-export] This is intentional: Flow will error when diff --git a/interface.js b/interface.js index 22337a98731be1..85325036dcf4e1 100644 --- a/interface.js +++ b/interface.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest-preset.js b/jest-preset.js index b5554b8f5f65c8..e49c4062687ea5 100644 --- a/jest-preset.js +++ b/jest-preset.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest.config.js b/jest.config.js index eb798365a9386e..512bd1b538ef76 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,7 +13,7 @@ module.exports = { transform: { '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': '/jest/assetFileTransformer.js', - '.*': './jest/preprocessor.js', + '.*': './jest/private/preprocessor.js', }, setupFiles: ['./jest/setup.js'], timers: 'fake', diff --git a/jest/MockNativeMethods.js b/jest/MockNativeMethods.js index f37fcd34c87bad..c0917b7f3a74e1 100644 --- a/jest/MockNativeMethods.js +++ b/jest/MockNativeMethods.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest/assetFileTransformer.js b/jest/assetFileTransformer.js index c4730114f46aa3..2e131c58923b27 100644 --- a/jest/assetFileTransformer.js +++ b/jest/assetFileTransformer.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,12 +20,13 @@ module.exports = { // the correct images are loaded for components. Essentially // require('img1.png') becomes `Object { "testUri": 'path/to/img1.png' }` in // the Jest snapshot. - process: (_, filename) => - `module.exports = { + process: (_, filename) => ({ + code: `module.exports = { testUri: ${JSON.stringify( path.relative(__dirname, filename).replace(/\\/g, '/'), )} };`, + }), getCacheKey: createCacheKeyFunction([__filename]), }; diff --git a/jest/mockComponent.js b/jest/mockComponent.js index 42a30c8c6e68ac..9e21dfaa45747b 100644 --- a/jest/mockComponent.js +++ b/jest/mockComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest/mockModal.js b/jest/mockModal.js index 8c5bfc7ec092cf..e38944d52dc599 100644 --- a/jest/mockModal.js +++ b/jest/mockModal.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,11 +13,11 @@ 'use strict'; const React = require('react'); -const Modal = require('../Libraries/Modal/Modal'); +import typeof Modal from '../Libraries/Modal/Modal'; function mockModal(BaseComponent: $FlowFixMe) { class ModalMock extends BaseComponent { - render(): React.Element { + render(): React.Element { return ( {this.props.visible !== true ? null : this.props.children} diff --git a/jest/mockNativeComponent.js b/jest/mockNativeComponent.js index f6545e3bcffbfe..c42baec2be2ae7 100644 --- a/jest/mockNativeComponent.js +++ b/jest/mockNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest/mockScrollView.js b/jest/mockScrollView.js index 4155be9661cef3..ceeb1843bbdada 100644 --- a/jest/mockScrollView.js +++ b/jest/mockScrollView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest/preprocessor.js b/jest/private/preprocessor.js similarity index 50% rename from jest/preprocessor.js rename to jest/private/preprocessor.js index fd365c847a6c3e..c908e48da773a3 100644 --- a/jest/preprocessor.js +++ b/jest/private/preprocessor.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -30,7 +30,7 @@ babelRegisterOnly([]); const transformer = require('metro-react-native-babel-transformer'); module.exports = { - process(src /*: string */, file /*: string */) /*: string */ { + process(src /*: string */, file /*: string */) /*: {code: string, ...} */ { if (nodeFiles.test(file)) { // node specific transforms only return babelTransformSync(src, { @@ -38,7 +38,7 @@ module.exports = { sourceType: 'script', ...nodeOptions, ast: false, - }).code; + }); } const {ast} = transformer.transform({ @@ -59,44 +59,6 @@ module.exports = { sourceType: 'unambiguous', // b7 required. detects module vs script mode }, src, - plugins: [ - [require('@babel/plugin-transform-block-scoping')], - // the flow strip types plugin must go BEFORE class properties! - // there'll be a test case that fails if you don't. - [require('@babel/plugin-transform-flow-strip-types')], - [ - require('@babel/plugin-proposal-class-properties'), - // use `this.foo = bar` instead of `this.defineProperty('foo', ...)` - {loose: true}, - ], - [require('@babel/plugin-transform-computed-properties')], - [require('@babel/plugin-transform-destructuring')], - [require('@babel/plugin-transform-function-name')], - [require('@babel/plugin-transform-literals')], - [require('@babel/plugin-transform-parameters')], - [require('@babel/plugin-transform-shorthand-properties')], - [require('@babel/plugin-transform-react-jsx')], - [require('@babel/plugin-transform-regenerator')], - [require('@babel/plugin-transform-sticky-regex')], - [require('@babel/plugin-transform-unicode-regex')], - [ - require('@babel/plugin-transform-modules-commonjs'), - {strict: false, allowTopLevelThis: true}, - ], - [require('@babel/plugin-transform-classes')], - [require('@babel/plugin-transform-arrow-functions')], - [require('@babel/plugin-transform-spread')], - [require('@babel/plugin-proposal-object-rest-spread')], - [ - require('@babel/plugin-transform-template-literals'), - {loose: true}, // dont 'a'.concat('b'), just use 'a'+'b' - ], - [require('@babel/plugin-transform-exponentiation-operator')], - [require('@babel/plugin-transform-object-assign')], - [require('@babel/plugin-transform-for-of'), {loose: true}], - [require('@babel/plugin-transform-react-display-name')], - [require('@babel/plugin-transform-react-jsx-source')], - ], }); return generate( @@ -112,7 +74,7 @@ module.exports = { sourceMaps: true, }, src, - ).code; + ); }, getCacheKey: (createCacheKeyFunction([ diff --git a/jest/renderer.js b/jest/renderer.js index 04b5674c26872c..46f06212e4995f 100644 --- a/jest/renderer.js +++ b/jest/renderer.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/jest/setup.js b/jest/setup.js index 69e937fdd3a0ff..8a53d7e8d6ece3 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -132,7 +132,7 @@ jest isScreenReaderEnabled: jest.fn(() => Promise.resolve(false)), removeEventListener: jest.fn(), setAccessibilityFocus: jest.fn(), - sendAccessibilityEvent_unstable: jest.fn(), + sendAccessibilityEvent: jest.fn(), getRecommendedTimeoutMillis: jest.fn(), }, })) @@ -355,6 +355,10 @@ jest '../Libraries/Utilities/verifyComponentAttributeEquivalence', () => function () {}, ) + .mock('../Libraries/Vibration/Vibration', () => ({ + vibrate: jest.fn(), + cancel: jest.fn(), + })) .mock('../Libraries/Components/View/ViewNativeComponent', () => { const React = require('react'); const Component = class extends React.Component { diff --git a/local-cli/cli.js b/local-cli/cli.js index 459b77e3a631b6..b5deb9fdb247c4 100644 --- a/local-cli/cli.js +++ b/local-cli/cli.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/metro.config.js b/metro.config.js index 69a20e6346a450..9125b65f004e64 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/package.json b/package.json index d6aa7bf9f0204d..47d6ffdbe277a5 100644 --- a/package.json +++ b/package.json @@ -7,16 +7,13 @@ "license": "MIT", "repository": "github:facebook/react-native", "engines": { - "node": ">=12" + "node": ">=14" }, "jest-junit": { "outputDirectory": "reports/junit", "outputName": "js-test-results.xml" }, "files": [ - "!template/node_modules", - "!template/package-lock.json", - "!template/yarn.lock", "android", "cli.js", "flow", @@ -25,6 +22,7 @@ "interface.js", "jest-preset.js", "jest", + "!jest/private", "Libraries", "LICENSE", "local-cli", @@ -38,17 +36,36 @@ "README.md", "rn-get-polyfills.js", "scripts/compose-source-maps.js", - "scripts/find-node.sh", + "scripts/find-node-for-xcode.sh", + "scripts/generate-artifacts.js", + "scripts/generate-provider-cli.js", "scripts/generate-specs-cli.js", + "scripts/codegen/codegen-utils.js", + "scripts/codegen/generate-artifacts-executor.js", + "scripts/codegen/generate-specs-cli-executor.js", + "scripts/hermes/hermes-utils.js", + "scripts/hermes/prepare-hermes-for-build.js", "scripts/ios-configure-glog.sh", + "scripts/xcode/with-environment.sh", "scripts/launchPackager.bat", "scripts/launchPackager.command", + "scripts/native_modules.rb", "scripts/node-binary.sh", "scripts/packager.sh", + "scripts/packager-reporter.js", + "scripts/react_native_pods_utils/script_phases.rb", + "scripts/react_native_pods_utils/script_phases.sh", "scripts/react_native_pods.rb", + "scripts/cocoapods", "scripts/react-native-xcode.sh", + "sdks/.hermesversion", + "sdks/hermes-engine", + "sdks/hermesc", "template.config.js", "template", + "!template/node_modules", + "!template/package-lock.json", + "!template/yarn.lock", "third-party-podspecs" ], "scripts": { @@ -67,7 +84,7 @@ "prettier": "prettier --write \"./**/*.{js,md,yml}\"", "format-check": "prettier --list-different \"./**/*.{js,md,yml}\"", "update-lock": "npx yarn-deduplicate", - "docker-setup-android": "docker pull reactnativecommunity/react-native-android:5.1", + "docker-setup-android": "docker pull reactnativecommunity/react-native-android:5.2", "docker-build-android": "docker build -t reactnativeci/android -f .circleci/Dockerfiles/Dockerfile.android .", "test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh", "test-android-run-unit": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh", @@ -76,8 +93,6 @@ "test-android-instrumentation": "yarn run docker-build-android && yarn run test-android-run-instrumentation", "test-android-unit": "yarn run docker-build-android && yarn run test-android-run-unit", "test-android-e2e": "yarn run docker-build-android && yarn run test-android-run-e2e", - "build-ios-e2e": "detox build -c ios.sim.release", - "test-ios-e2e": "detox test -c ios.sim.release packages/rn-tester/e2e", "test-ios": "./scripts/objc-test.sh test" }, "workspaces": [ @@ -85,80 +100,46 @@ "repo-config" ], "peerDependencies": { - "react": "17.0.2" + "react": "18.1.0" }, "dependencies": { "@jest/create-cache-key-function": "^27.0.1", - "@react-native-community/cli": "^6.0.0", - "@react-native-community/cli-platform-android": "^6.0.0", - "@react-native-community/cli-platform-ios": "^6.0.0", + "@react-native-community/cli": "^9.0.0-alpha.3", + "@react-native-community/cli-platform-android": "^9.0.0-alpha.3", + "@react-native-community/cli-platform-ios": "^9.0.0-alpha.3", "@react-native/assets": "1.0.0", "@react-native/normalize-color": "2.0.0", "@react-native/polyfills": "2.0.0", "abort-controller": "^3.0.0", "anser": "^1.4.9", "base64-js": "^1.1.2", - "deprecated-react-native-prop-types": "^2.1.0", "event-target-shim": "^5.0.1", - "hermes-engine": "~0.10.0", "invariant": "^2.2.4", "jsc-android": "^250230.2.1", - "metro-react-native-babel-transformer": "0.66.2", - "metro-runtime": "0.66.2", - "metro-source-map": "0.66.2", + "memoize-one": "^5.0.0", + "metro-react-native-babel-transformer": "0.71.3", + "metro-runtime": "0.71.3", + "metro-source-map": "0.71.3", + "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", "promise": "^8.0.3", - "prop-types": "^15.7.2", - "react-devtools-core": "4.21.0", + "react-devtools-core": "4.24.0", + "react-native-gradle-plugin": "^0.70.0", "react-refresh": "^0.4.0", + "react-shallow-renderer": "^16.15.0", "regenerator-runtime": "^0.13.2", - "scheduler": "^0.20.2", + "scheduler": "^0.22.0", "stacktrace-parser": "^0.1.3", - "use-subscription": "^1.0.0", + "use-sync-external-store": "^1.0.0", "whatwg-fetch": "^3.0.0", "ws": "^6.1.4" }, "devDependencies": { - "flow-bin": "^0.165.0", - "react": "17.0.2" - }, - "detox": { - "test-runner": "jest", - "runner-config": "packages/rn-tester/e2e/config.json", - "specs": "", - "configurations": { - "android.emu.release": { - "binaryPath": "packages/rn-tester/android/app/build/outputs/apk/hermes/release/app-hermes-x86-release.apk", - "testBinaryPath": "packages/rn-tester/android/app/build/outputs/apk/androidTest/hermes/release/app-hermes-release-androidTest.apk", - "build": "./gradlew :packages:rn-tester:android:app:assembleRelease :packages:rn-tester:android:app:assembleAndroidTest -DtestBuildType=release", - "type": "android.emulator", - "device": { - "avdName": "Nexus_6_API_29" - } - }, - "android.emu.debug": { - "binaryPath": "packages/rn-tester/android/app/build/outputs/apk/hermes/debug/app-hermes-x86-debug.apk", - "testBinaryPath": "packages/rn-tester/android/app/build/outputs/apk/androidTest/hermes/debug/app-hermes-debug-androidTest.apk", - "build": "./gradlew :packages:rn-tester:android:app:assembleDebug :packages:rn-tester:android:app:assembleAndroidTest -DtestBuildType=debug", - "type": "android.emulator", - "device": { - "avdName": "Nexus_6_API_29" - } - }, - "ios.sim.release": { - "binaryPath": "packages/rn-tester/build/Build/Products/Release-iphonesimulator/RNTester.app/", - "build": "xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -configuration Release -sdk iphonesimulator -derivedDataPath packages/rn-tester/build -UseModernBuildSystem=NO -quiet", - "type": "ios.simulator", - "name": "iPhone 8" - }, - "ios.sim.debug": { - "binaryPath": "packages/rn-tester/build/Build/Products/Debug-iphonesimulator/RNTester.app/", - "build": "xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -configuration Debug -sdk iphonesimulator -derivedDataPath packages/rn-tester/build -UseModernBuildSystem=NO -quiet", - "type": "ios.simulator", - "name": "iPhone 8" - } - } + "flow-bin": "^0.182.0", + "hermes-eslint": "0.8.0", + "react": "18.1.0", + "react-test-renderer": "^18.1.0" }, "codegenConfig": { "libraries": [ diff --git a/packages/assets/BUCK b/packages/assets/BUCK index 424f33a0003ce6..a1c34d6e1504cb 100644 --- a/packages/assets/BUCK +++ b/packages/assets/BUCK @@ -1,14 +1,12 @@ -load("@fbsource//tools/build_defs:js_glob.bzl", "js_glob") load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace") load("@fbsource//xplat/js:JS_DEFS.bzl", "rn_library") rn_library( name = "assets", - srcs = js_glob([ - "**/*", - "package.json", - ]), - labels = ["supermodule:xplat/default/public.react_native.core"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.core", + ], skip_processors = True, visibility = ["PUBLIC"], ) diff --git a/packages/assets/__tests__/path-support-test.js b/packages/assets/__tests__/path-support-test.js index 7508c3d16ee3c6..37cc3ba7fee68a 100644 --- a/packages/assets/__tests__/path-support-test.js +++ b/packages/assets/__tests__/path-support-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/assets/path-support.js b/packages/assets/path-support.js index ef2e42d71b7842..a6c30d42375a55 100644 --- a/packages/assets/path-support.js +++ b/packages/assets/path-support.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -44,6 +44,7 @@ const drawableFileTypes = new Set([ 'gif', 'jpeg', 'jpg', + 'ktx', 'png', 'svg', 'webp', diff --git a/packages/assets/registry.js b/packages/assets/registry.js index 088187ff3e70ab..02470da3c4962a 100644 --- a/packages/assets/registry.js +++ b/packages/assets/registry.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/babel-plugin-codegen/__test_fixtures__/failures.js b/packages/babel-plugin-codegen/__test_fixtures__/failures.js index 40e46fd5b58fd8..908a83488e070e 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/failures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/failures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js index 946b622ea87d66..a55b940eabcc3c 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/fixtures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap index c324b68b283f31..474b3878339318 100644 --- a/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-codegen/__tests__/__snapshots__/index-test.js.snap @@ -24,12 +24,16 @@ interface NativeCommands { const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const { + ConditionallyIgnoredEventHandlers +} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); + const { dispatchCommand } = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); let nativeComponentName = 'RCTModule'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'RCTModule', bubblingEventTypes: { topBubblingEventDefinedInlineNull: { @@ -46,10 +50,13 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ }, validAttributes: { boolean_default_true_optional_both: true, - onDirectEventDefinedInlineNull: true, - onBubblingEventDefinedInlineNull: true + ...ConditionallyIgnoredEventHandlers({ + onDirectEventDefinedInlineNull: true, + onBubblingEventDefinedInlineNull: true + }) } -})); +}; +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); export const Commands = { hotspotUpdate(ref, x, y) { dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]); @@ -86,12 +93,16 @@ interface NativeCommands { const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const { + ConditionallyIgnoredEventHandlers +} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); + const { dispatchCommand } = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\"); let nativeComponentName = 'RCTModule'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'RCTModule', bubblingEventTypes: { topBubblingEventDefinedInlineNull: { @@ -108,10 +119,13 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ }, validAttributes: { boolean_default_true_optional_both: true, - onDirectEventDefinedInlineNull: true, - onBubblingEventDefinedInlineNull: true + ...ConditionallyIgnoredEventHandlers({ + onDirectEventDefinedInlineNull: true, + onBubblingEventDefinedInlineNull: true + }) } -})); +}; +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); export const Commands = { hotspotUpdate(ref, x, y) { dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]); diff --git a/packages/babel-plugin-codegen/__tests__/index-test.js b/packages/babel-plugin-codegen/__tests__/index-test.js index 06b9ad76dfe469..820a711f86850e 100644 --- a/packages/babel-plugin-codegen/__tests__/index-test.js +++ b/packages/babel-plugin-codegen/__tests__/index-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/babel-plugin-codegen/index.js b/packages/babel-plugin-codegen/index.js index 2e59816d9d2b18..33a71e403109c8 100644 --- a/packages/babel-plugin-codegen/index.js +++ b/packages/babel-plugin-codegen/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,12 +9,21 @@ 'use strict'; -const {parseString} = require('react-native-codegen/src/parsers/flow'); -const RNCodegen = require('react-native-codegen/src/generators/RNCodegen'); +let flow, RNCodegen; + const {basename} = require('path'); +try { + flow = require('react-native-codegen/src/parsers/flow'); + 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) + flow = require('react-native-codegen/lib/parsers/flow'); + RNCodegen = require('react-native-codegen/lib/generators/RNCodegen'); +} + function generateViewConfig(filename, code) { - const schema = parseString(code); + const schema = flow.parseString(code); const libraryName = basename(filename).replace(/NativeComponent\.js$/, ''); return RNCodegen.generateViewConfig({ @@ -77,6 +86,7 @@ module.exports = function ({parse, types: t}) { if (firstDeclaration.type === 'VariableDeclarator') { if ( + firstDeclaration.init && firstDeclaration.init.type === 'CallExpression' && firstDeclaration.init.callee.type === 'Identifier' && firstDeclaration.init.callee.name === 'codegenNativeCommands' diff --git a/packages/babel-plugin-codegen/package.json b/packages/babel-plugin-codegen/package.json index 858148ff6ae1fb..56dc4f1d6c7ede 100644 --- a/packages/babel-plugin-codegen/package.json +++ b/packages/babel-plugin-codegen/package.json @@ -7,6 +7,9 @@ "url": "git@github.com:facebook/react-native.git", "directory": "packages/babel-plugin-codegen" }, + "files": [ + "index.js" + ], "dependencies": { "react-native-codegen": "*" }, diff --git a/packages/eslint-config-react-native-community/index.js b/packages/eslint-config-react-native-community/index.js index 71480dca05b2b0..563a400c02ab4d 100644 --- a/packages/eslint-config-react-native-community/index.js +++ b/packages/eslint-config-react-native-community/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -36,14 +36,14 @@ module.exports = { overrides: [ { files: ['*.js'], - parser: 'babel-eslint', - plugins: ['flowtype'], + parser: '@babel/eslint-parser', + plugins: ['ft-flow'], rules: { // Flow Plugin - // The following rules are made available via `eslint-plugin-flowtype` + // The following rules are made available via `eslint-plugin-ft-flow` - 'flowtype/define-flow-type': 1, - 'flowtype/use-flow-type': 1, + 'ft-flow/define-flow-type': 1, + 'ft-flow/use-flow-type': 1, }, }, { @@ -56,6 +56,11 @@ module.exports = { {argsIgnorePattern: '^_'}, ], 'no-unused-vars': 'off', + 'no-shadow': 'off', + '@typescript-eslint/no-shadow': 1, + 'no-undef': 'off', + 'func-call-spacing': 'off', + '@typescript-eslint/func-call-spacing': 1, }, }, { @@ -80,6 +85,7 @@ module.exports = { __dirname: false, __fbBatchedBridgeConfig: false, AbortController: false, + Blob: true, alert: false, cancelAnimationFrame: false, cancelIdleCallback: false, @@ -94,6 +100,7 @@ module.exports = { EventTarget: false, exports: false, fetch: false, + File: true, FileReader: false, FormData: false, global: false, @@ -254,7 +261,7 @@ module.exports = { 'no-empty-character-class': 1, // disallow the use of empty character classes in regular expressions 'no-lonely-if': 0, // disallow if as the only statement in an else block (off by default) 'no-new-object': 1, // disallow use of the Object constructor - 'no-spaced-func': 1, // disallow space between function identifier and application + 'func-call-spacing': 1, // disallow space between function identifier and application 'no-ternary': 0, // disallow the use of ternary operators (off by default) 'no-trailing-spaces': 1, // disallow trailing whitespace at the end of lines 'no-underscore-dangle': 0, // disallow dangling underscores in identifiers @@ -297,6 +304,7 @@ module.exports = { 'react/no-multi-comp': 0, 'react/no-string-refs': 1, 'react/no-unknown-property': 0, + 'react/no-unstable-nested-components': 1, 'react/prop-types': 0, 'react/react-in-jsx-scope': 1, 'react/self-closing-comp': 1, @@ -304,8 +312,8 @@ module.exports = { // React-Hooks Plugin // The following rules are made available via `eslint-plugin-react-hooks` - 'react-hooks/rules-of-hooks': 'error', - 'react-hooks/exhaustive-deps': 'error', + 'react-hooks/rules-of-hooks': 2, + 'react-hooks/exhaustive-deps': 2, // React-Native Plugin // The following rules are made available via `eslint-plugin-react-native` diff --git a/packages/eslint-config-react-native-community/package.json b/packages/eslint-config-react-native-community/package.json index 79f74a9ddfccca..8d74bb7eb48b18 100644 --- a/packages/eslint-config-react-native-community/package.json +++ b/packages/eslint-config-react-native-community/package.json @@ -1,6 +1,6 @@ { "name": "@react-native-community/eslint-config", - "version": "3.0.1", + "version": "3.0.3", "description": "ESLint config for React Native", "main": "index.js", "license": "MIT", @@ -11,26 +11,26 @@ }, "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/eslint-config-react-native-community#readme", "dependencies": { + "@babel/core": "^7.14.0", + "@babel/eslint-parser": "^7.18.2", "@react-native-community/eslint-plugin": "^1.1.0", - "@typescript-eslint/eslint-plugin": "^4.22.1", - "@typescript-eslint/parser": "^4.22.1", - "babel-eslint": "^10.1.0", - "eslint-config-prettier": "^8.3.0", + "@typescript-eslint/eslint-plugin": "^5.30.5", + "@typescript-eslint/parser": "^5.30.5", + "eslint-config-prettier": "^8.5.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-flowtype": "^7.0.0", - "eslint-plugin-jest": "^25.2.4", - "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-react": "^7.26.1", - "eslint-plugin-react-hooks": "^4.2.0", - "eslint-plugin-react-native": "^3.11.0", - "prettier": "^2.4.1" + "eslint-plugin-ft-flow": "^2.0.1", + "eslint-plugin-jest": "^26.5.3", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-react": "^7.30.1", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-native": "^4.0.0" }, "peerDependencies": { "eslint": ">=7", "prettier": ">=2" }, "devDependencies": { - "eslint": "^7.32.0", + "eslint": "^8.19.0", "prettier": "^2.4.1" } } diff --git a/packages/eslint-config-react-native-community/yarn.lock b/packages/eslint-config-react-native-community/yarn.lock index 74bfe98204661a..54b7d2e9821217 100644 --- a/packages/eslint-config-react-native-community/yarn.lock +++ b/packages/eslint-config-react-native-community/yarn.lock @@ -2,133 +2,265 @@ # yarn lockfile v1 -"@babel/code-frame@7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" - integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== - dependencies: - "@babel/highlight" "^7.10.4" +"@ampproject/remapping@^2.1.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" + integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== + dependencies: + "@jridgewell/gen-mapping" "^0.1.0" + "@jridgewell/trace-mapping" "^0.3.9" + +"@babel/code-frame@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" + integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== + dependencies: + "@babel/highlight" "^7.16.7" + +"@babel/compat-data@^7.17.10": + version "7.18.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.5.tgz#acac0c839e317038c73137fbb6ef71a1d6238471" + integrity sha512-BxhE40PVCBxVEJsSBhB6UWyAuqJRxGsAw8BdHMJ3AKGydcwuWW4kOO3HmqBQAdcq/OP+/DlTVxLvsCzRTnZuGg== + +"@babel/core@^7.14.0": + version "7.18.5" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.18.5.tgz#c597fa680e58d571c28dda9827669c78cdd7f000" + integrity sha512-MGY8vg3DxMnctw0LdvSEojOsumc70g0t18gNyUdAZqB1Rpd1Bqo/svHGvt+UJ6JcGX+DIekGFDxxIWofBxLCnQ== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.18.2" + "@babel/helper-compilation-targets" "^7.18.2" + "@babel/helper-module-transforms" "^7.18.0" + "@babel/helpers" "^7.18.2" + "@babel/parser" "^7.18.5" + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.18.5" + "@babel/types" "^7.18.4" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== +"@babel/eslint-parser@^7.18.2": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.18.2.tgz#e14dee36c010edfb0153cf900c2b0815e82e3245" + integrity sha512-oFQYkE8SuH14+uR51JVAmdqwKYXGRjEXx7s+WiagVjqQ+HPE+nnwyF2qlVG8evUsUHmPcA+6YXMEDbIhEyQc5A== dependencies: - "@babel/highlight" "^7.10.4" + eslint-scope "^5.1.1" + eslint-visitor-keys "^2.1.0" + semver "^6.3.0" -"@babel/generator@^7.12.10": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.10.tgz#2b188fc329fb8e4f762181703beffc0fe6df3460" - integrity sha512-6mCdfhWgmqLdtTkhXjnIz0LcdVCd26wS2JXRtj2XY0u5klDsXBREA/pG5NVOuVnF2LUrBGNFtQkIqqTbblg0ww== +"@babel/generator@^7.18.2": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.2.tgz#33873d6f89b21efe2da63fe554460f3df1c5880d" + integrity sha512-W1lG5vUwFvfMd8HVXqdfbuG7RuaSrTCCD8cl8fP8wOivdbtbIg2Db3IWUcgvfxKbbn6ZBGYRW/Zk1MIwK49mgw== dependencies: - "@babel/types" "^7.12.10" + "@babel/types" "^7.18.2" + "@jridgewell/gen-mapping" "^0.3.0" jsesc "^2.5.1" - source-map "^0.5.0" - -"@babel/helper-function-name@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz#d2d3b20c59ad8c47112fa7d2a94bc09d5ef82f1a" - integrity sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ== - dependencies: - "@babel/helper-get-function-arity" "^7.10.4" - "@babel/template" "^7.10.4" - "@babel/types" "^7.10.4" - -"@babel/helper-get-function-arity@^7.10.4": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.10.tgz#b158817a3165b5faa2047825dfa61970ddcc16cf" - integrity sha512-mm0n5BPjR06wh9mPQaDdXWDoll/j5UpCAPl1x8fS71GHm7HA6Ua2V4ylG1Ju8lvcTOietbPNNPaSilKj+pj+Ag== - dependencies: - "@babel/types" "^7.12.10" -"@babel/helper-split-export-declaration@^7.11.0": - version "7.11.0" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz#f8a491244acf6a676158ac42072911ba83ad099f" - integrity sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg== +"@babel/helper-compilation-targets@^7.18.2": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.2.tgz#67a85a10cbd5fc7f1457fec2e7f45441dc6c754b" + integrity sha512-s1jnPotJS9uQnzFtiZVBUxe67CuBa679oWFHpxYYnTpRL/1ffhyX44R9uYiXoa/pLXcY9H2moJta0iaanlk/rQ== dependencies: - "@babel/types" "^7.11.0" - -"@babel/helper-validator-identifier@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" - integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== + "@babel/compat-data" "^7.17.10" + "@babel/helper-validator-option" "^7.16.7" + browserslist "^4.20.2" + semver "^6.3.0" -"@babel/highlight@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.4.tgz#7d1bdfd65753538fabe6c38596cdb76d9ac60143" - integrity sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" +"@babel/helper-environment-visitor@^7.16.7", "@babel/helper-environment-visitor@^7.18.2": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.2.tgz#8a6d2dedb53f6bf248e31b4baf38739ee4a637bd" + integrity sha512-14GQKWkX9oJzPiQQ7/J36FTXcD4kSp8egKjO9nINlSKiHITRA9q/R74qu8S9xlc/b/yjsJItQUeeh3xnGN0voQ== + +"@babel/helper-function-name@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz#136fcd54bc1da82fcb47565cf16fd8e444b1ff12" + integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== + dependencies: + "@babel/template" "^7.16.7" + "@babel/types" "^7.17.0" + +"@babel/helper-hoist-variables@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz#86bcb19a77a509c7b77d0e22323ef588fa58c246" + integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-module-imports@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" + integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-module-transforms@^7.18.0": + version "7.18.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.0.tgz#baf05dec7a5875fb9235bd34ca18bad4e21221cd" + integrity sha512-kclUYSUBIjlvnzN2++K9f2qzYKFgjmnmjwL4zlmU5f8ZtzgWe8s0rUPSTGy2HmK4P8T52MQsS+HTQAgZd3dMEA== + dependencies: + "@babel/helper-environment-visitor" "^7.16.7" + "@babel/helper-module-imports" "^7.16.7" + "@babel/helper-simple-access" "^7.17.7" + "@babel/helper-split-export-declaration" "^7.16.7" + "@babel/helper-validator-identifier" "^7.16.7" + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.18.0" + "@babel/types" "^7.18.0" + +"@babel/helper-simple-access@^7.17.7": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.2.tgz#4dc473c2169ac3a1c9f4a51cfcd091d1c36fcff9" + integrity sha512-7LIrjYzndorDY88MycupkpQLKS1AFfsVRm2k/9PtKScSy5tZq0McZTj+DiMRynboZfIqOKvo03pmhTaUgiD6fQ== + dependencies: + "@babel/types" "^7.18.2" + +"@babel/helper-split-export-declaration@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz#0b648c0c42da9d3920d85ad585f2778620b8726b" + integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-validator-identifier@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" + integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== + +"@babel/helper-validator-option@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" + integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== + +"@babel/helpers@^7.18.2": + version "7.18.2" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.18.2.tgz#970d74f0deadc3f5a938bfa250738eb4ac889384" + integrity sha512-j+d+u5xT5utcQSzrh9p+PaJX94h++KN+ng9b9WEJq7pkUPAd61FGqhjuUEdfknb3E/uDBb7ruwEeKkIxNJPIrg== + dependencies: + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.18.2" + "@babel/types" "^7.18.2" + +"@babel/highlight@^7.16.7": + version "7.17.12" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.17.12.tgz#257de56ee5afbd20451ac0a75686b6b404257351" + integrity sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg== + dependencies: + "@babel/helper-validator-identifier" "^7.16.7" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.12.10", "@babel/parser@^7.12.7", "@babel/parser@^7.7.0": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" - integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== - -"@babel/template@^7.10.4": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc" - integrity sha512-GkDzmHS6GV7ZeXfJZ0tLRBhZcMcY0/Lnb+eEbXDBfCAcZCjrZKe6p3J4we/D24O9Y8enxWAg1cWwof59yLh2ow== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/parser" "^7.12.7" - "@babel/types" "^7.12.7" - -"@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" - integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.10" - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-split-export-declaration" "^7.11.0" - "@babel/parser" "^7.12.10" - "@babel/types" "^7.12.10" +"@babel/parser@^7.16.7", "@babel/parser@^7.18.5": + version "7.18.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.5.tgz#337062363436a893a2d22faa60be5bb37091c83c" + integrity sha512-YZWVaglMiplo7v8f1oMQ5ZPQr0vn7HPeZXxXWsxXJRjGVrzUFn9OxFQl1sb5wzfootjA/yChhW84BV+383FSOw== + +"@babel/template@^7.16.7": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155" + integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/parser" "^7.16.7" + "@babel/types" "^7.16.7" + +"@babel/traverse@^7.18.0", "@babel/traverse@^7.18.2", "@babel/traverse@^7.18.5", "@babel/traverse@^7.7.4": + version "7.18.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.5.tgz#94a8195ad9642801837988ab77f36e992d9a20cd" + integrity sha512-aKXj1KT66sBj0vVzk6rEeAO6Z9aiiQ68wfDgge3nHhA/my6xMM/7HGQUNumKZaoa2qUPQ5whJG9aAifsxUKfLA== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.18.2" + "@babel/helper-environment-visitor" "^7.18.2" + "@babel/helper-function-name" "^7.17.9" + "@babel/helper-hoist-variables" "^7.16.7" + "@babel/helper-split-export-declaration" "^7.16.7" + "@babel/parser" "^7.18.5" + "@babel/types" "^7.18.4" debug "^4.1.0" globals "^11.1.0" - lodash "^4.17.19" -"@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.10", "@babel/types@^7.12.7", "@babel/types@^7.7.0": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" - integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== +"@babel/types@^7.16.7", "@babel/types@^7.17.0", "@babel/types@^7.18.0", "@babel/types@^7.18.2", "@babel/types@^7.18.4": + version "7.18.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.4.tgz#27eae9b9fd18e9dccc3f9d6ad051336f307be354" + integrity sha512-ThN1mBcMq5pG/Vm2IcBmPPfyPXbd8S02rS+OBIDENdufvqC7Z/jHPCv9IcP01277aKtDI8g/2XysBN4hA8niiw== dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - lodash "^4.17.19" + "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@eslint/eslintrc@^0.4.3": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" - integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw== +"@eslint/eslintrc@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.0.tgz#29f92c30bb3e771e4a2048c95fa6855392dfac4f" + integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw== dependencies: ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^13.9.0" - ignore "^4.0.6" + debug "^4.3.2" + espree "^9.3.2" + globals "^13.15.0" + ignore "^5.2.0" import-fresh "^3.2.1" - js-yaml "^3.13.1" - minimatch "^3.0.4" + js-yaml "^4.1.0" + minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" - integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg== +"@humanwhocodes/config-array@^0.9.2": + version "0.9.5" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.5.tgz#2cbaf9a89460da24b5ca6531b8bbfc23e1df50c7" + integrity sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw== dependencies: - "@humanwhocodes/object-schema" "^1.2.0" + "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" minimatch "^3.0.4" -"@humanwhocodes/object-schema@^1.2.0": +"@humanwhocodes/object-schema@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@jridgewell/gen-mapping@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" + integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== + dependencies: + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@jridgewell/gen-mapping@^0.3.0": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz#cf92a983c83466b8c0ce9124fadeaf09f7c66ea9" + integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg== + dependencies: + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz#30cd49820a962aff48c8fffc5cd760151fca61fe" + integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== + +"@jridgewell/set-array@^1.0.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea" + integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.13" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c" + integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== + +"@jridgewell/trace-mapping@^0.3.9": + version "0.3.13" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea" + integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@nodelib/fs.scandir@2.1.4": version "2.1.4" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69" @@ -155,151 +287,100 @@ resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.1.0.tgz#e42b1bef12d2415411519fd528e64b593b1363dc" integrity sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ== -"@types/color-name@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" - integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== - -"@types/json-schema@^7.0.3": - version "7.0.4" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" - integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== - "@types/json-schema@^7.0.9": version "7.0.9" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== -"@typescript-eslint/eslint-plugin@^4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.1.tgz#6bcdbaa4548553ab861b4e5f34936ead1349a543" - integrity sha512-kVTAghWDDhsvQ602tHBc6WmQkdaYbkcTwZu+7l24jtJiYvm9l+/y/b2BZANEezxPDiX5MK2ZecE+9BFi/YJryw== +"@typescript-eslint/eslint-plugin@^5.30.5": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.6.tgz#9c6017b6c1d04894141b4a87816388967f64c359" + integrity sha512-J4zYMIhgrx4MgnZrSDD7sEnQp7FmhKNOaqaOpaoQ/SfdMfRB/0yvK74hTnvH+VQxndZynqs5/Hn4t+2/j9bADg== dependencies: - "@typescript-eslint/experimental-utils" "4.22.1" - "@typescript-eslint/scope-manager" "4.22.1" - debug "^4.1.1" + "@typescript-eslint/scope-manager" "5.30.6" + "@typescript-eslint/type-utils" "5.30.6" + "@typescript-eslint/utils" "5.30.6" + debug "^4.3.4" functional-red-black-tree "^1.0.1" - lodash "^4.17.15" - regexpp "^3.0.0" - semver "^7.3.2" - tsutils "^3.17.1" - -"@typescript-eslint/experimental-utils@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.22.1.tgz#3938a5c89b27dc9a39b5de63a62ab1623ab27497" - integrity sha512-svYlHecSMCQGDO2qN1v477ax/IDQwWhc7PRBiwAdAMJE7GXk5stF4Z9R/8wbRkuX/5e9dHqbIWxjeOjckK3wLQ== - dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.22.1" - "@typescript-eslint/types" "4.22.1" - "@typescript-eslint/typescript-estree" "4.22.1" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" - -"@typescript-eslint/experimental-utils@^5.0.0": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.3.1.tgz#bbd8f9b67b4d5fdcb9d2f90297d8fcda22561e05" - integrity sha512-RgFn5asjZ5daUhbK5Sp0peq0SSMytqcrkNfU4pnDma2D8P3ElZ6JbYjY8IMSFfZAJ0f3x3tnO3vXHweYg0g59w== - dependencies: - "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.3.1" - "@typescript-eslint/types" "5.3.1" - "@typescript-eslint/typescript-estree" "5.3.1" - eslint-scope "^5.1.1" - eslint-utils "^3.0.0" + ignore "^5.2.0" + regexpp "^3.2.0" + semver "^7.3.7" + tsutils "^3.21.0" -"@typescript-eslint/parser@^4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.22.1.tgz#a95bda0fd01d994a15fc3e99dc984294f25c19cc" - integrity sha512-l+sUJFInWhuMxA6rtirzjooh8cM/AATAe3amvIkqKFeMzkn85V+eLzb1RyuXkHak4dLfYzOmF6DXPyflJvjQnw== +"@typescript-eslint/parser@^5.30.5": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.30.6.tgz#add440db038fa9d777e4ebdaf66da9e7fb7abe92" + integrity sha512-gfF9lZjT0p2ZSdxO70Xbw8w9sPPJGfAdjK7WikEjB3fcUI/yr9maUVEdqigBjKincUYNKOmf7QBMiTf719kbrA== dependencies: - "@typescript-eslint/scope-manager" "4.22.1" - "@typescript-eslint/types" "4.22.1" - "@typescript-eslint/typescript-estree" "4.22.1" - debug "^4.1.1" + "@typescript-eslint/scope-manager" "5.30.6" + "@typescript-eslint/types" "5.30.6" + "@typescript-eslint/typescript-estree" "5.30.6" + debug "^4.3.4" -"@typescript-eslint/scope-manager@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz#5bb357f94f9cd8b94e6be43dd637eb73b8f355b4" - integrity sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g== +"@typescript-eslint/scope-manager@5.30.6": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.30.6.tgz#ce1b49ff5ce47f55518d63dbe8fc9181ddbd1a33" + integrity sha512-Hkq5PhLgtVoW1obkqYH0i4iELctEKixkhWLPTYs55doGUKCASvkjOXOd/pisVeLdO24ZX9D6yymJ/twqpJiG3g== dependencies: - "@typescript-eslint/types" "4.22.1" - "@typescript-eslint/visitor-keys" "4.22.1" + "@typescript-eslint/types" "5.30.6" + "@typescript-eslint/visitor-keys" "5.30.6" -"@typescript-eslint/scope-manager@5.3.1": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.3.1.tgz#3cfbfbcf5488fb2a9a6fbbe97963ee1e8d419269" - integrity sha512-XksFVBgAq0Y9H40BDbuPOTUIp7dn4u8oOuhcgGq7EoDP50eqcafkMVGrypyVGvDYHzjhdUCUwuwVUK4JhkMAMg== +"@typescript-eslint/type-utils@5.30.6": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.30.6.tgz#a64aa9acbe609ab77f09f53434a6af2b9685f3af" + integrity sha512-GFVVzs2j0QPpM+NTDMXtNmJKlF842lkZKDSanIxf+ArJsGeZUIaeT4jGg+gAgHt7AcQSFwW7htzF/rbAh2jaVA== dependencies: - "@typescript-eslint/types" "5.3.1" - "@typescript-eslint/visitor-keys" "5.3.1" - -"@typescript-eslint/types@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.22.1.tgz#bf99c6cec0b4a23d53a61894816927f2adad856a" - integrity sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw== - -"@typescript-eslint/types@5.3.1": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.3.1.tgz#afaa715b69ebfcfde3af8b0403bf27527912f9b7" - integrity sha512-bG7HeBLolxKHtdHG54Uac750eXuQQPpdJfCYuw4ZI3bZ7+GgKClMWM8jExBtp7NSP4m8PmLRM8+lhzkYnSmSxQ== + "@typescript-eslint/utils" "5.30.6" + debug "^4.3.4" + tsutils "^3.21.0" -"@typescript-eslint/typescript-estree@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz#dca379eead8cdfd4edc04805e83af6d148c164f9" - integrity sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A== - dependencies: - "@typescript-eslint/types" "4.22.1" - "@typescript-eslint/visitor-keys" "4.22.1" - debug "^4.1.1" - globby "^11.0.1" - is-glob "^4.0.1" - semver "^7.3.2" - tsutils "^3.17.1" +"@typescript-eslint/types@5.30.6": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.30.6.tgz#86369d0a7af8c67024115ac1da3e8fb2d38907e1" + integrity sha512-HdnP8HioL1F7CwVmT4RaaMX57RrfqsOMclZc08wGMiDYJBsLGBM7JwXM4cZJmbWLzIR/pXg1kkrBBVpxTOwfUg== -"@typescript-eslint/typescript-estree@5.3.1": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.3.1.tgz#50cc4bfb93dc31bc75e08ae52e29fcb786d606ec" - integrity sha512-PwFbh/PKDVo/Wct6N3w+E4rLZxUDgsoII/GrWM2A62ETOzJd4M6s0Mu7w4CWsZraTbaC5UQI+dLeyOIFF1PquQ== +"@typescript-eslint/typescript-estree@5.30.6": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.6.tgz#a84a0d6a486f9b54042da1de3d671a2c9f14484e" + integrity sha512-Z7TgPoeYUm06smfEfYF0RBkpF8csMyVnqQbLYiGgmUSTaSXTP57bt8f0UFXstbGxKIreTwQCujtaH0LY9w9B+A== dependencies: - "@typescript-eslint/types" "5.3.1" - "@typescript-eslint/visitor-keys" "5.3.1" - debug "^4.3.2" - globby "^11.0.4" + "@typescript-eslint/types" "5.30.6" + "@typescript-eslint/visitor-keys" "5.30.6" + debug "^4.3.4" + globby "^11.1.0" is-glob "^4.0.3" - semver "^7.3.5" + semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz#6045ae25a11662c671f90b3a403d682dfca0b7a6" - integrity sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ== +"@typescript-eslint/utils@5.30.6", "@typescript-eslint/utils@^5.10.0": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.30.6.tgz#1de2da14f678e7d187daa6f2e4cdb558ed0609dc" + integrity sha512-xFBLc/esUbLOJLk9jKv0E9gD/OH966M40aY9jJ8GiqpSkP2xOV908cokJqqhVd85WoIvHVHYXxSFE4cCSDzVvA== dependencies: - "@typescript-eslint/types" "4.22.1" - eslint-visitor-keys "^2.0.0" + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.30.6" + "@typescript-eslint/types" "5.30.6" + "@typescript-eslint/typescript-estree" "5.30.6" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" -"@typescript-eslint/visitor-keys@5.3.1": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.3.1.tgz#c2860ff22939352db4f3806f34b21d8ad00588ba" - integrity sha512-3cHUzUuVTuNHx0Gjjt5pEHa87+lzyqOiHXy/Gz+SJOCW1mpw9xQHIIEwnKn+Thph1mgWyZ90nboOcSuZr/jTTQ== +"@typescript-eslint/visitor-keys@5.30.6": + version "5.30.6" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.6.tgz#94dd10bb481c8083378d24de1742a14b38a2678c" + integrity sha512-41OiCjdL2mCaSDi2SvYbzFLlqqlm5v1ZW9Ym55wXKL/Rx6OOB1IbuFGo71Fj6Xy90gJDFTlgOS+vbmtGHPTQQA== dependencies: - "@typescript-eslint/types" "5.3.1" - eslint-visitor-keys "^3.0.0" - -acorn-jsx@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe" - integrity sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ== + "@typescript-eslint/types" "5.30.6" + eslint-visitor-keys "^3.3.0" -acorn-jsx@^5.3.1: +acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn@^7.4.0: - version "7.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" - integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== +acorn@^8.7.1: + version "8.7.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" + integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" @@ -311,26 +392,6 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.7.1.tgz#52be6f1736b076074798124293618f132ad07a7e" - integrity sha512-gPpOObTO1QjbnN1sVMjJcp1TF9nggMfO4MBR5uQl6ZVTOaEPq5i4oq/6R9q2alMMPB3eg53wFv1RuJBLuxf3Hw== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -ansi-colors@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-regex@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" - integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== - ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -343,27 +404,17 @@ ansi-styles@^3.2.1: dependencies: color-convert "^1.9.0" -ansi-styles@^4.0.0: +ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: color-convert "^2.0.1" -ansi-styles@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359" - integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA== - dependencies: - "@types/color-name" "^1.1.1" - color-convert "^2.0.1" - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== array-includes@^3.1.3: version "3.1.4" @@ -376,36 +427,31 @@ array-includes@^3.1.3: get-intrinsic "^1.1.1" is-string "^1.0.7" +array-includes@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.5.tgz#2c320010db8d31031fd2a5f6b3bbd4b1aad31bdb" + integrity sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" + get-intrinsic "^1.1.1" + is-string "^1.0.7" + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -array.prototype.flatmap@^1.2.4: - version "1.2.5" - resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.2.5.tgz#908dc82d8a406930fdf38598d51e7411d18d4446" - integrity sha512-08u6rVyi1Lj7oqWbS9nUxliETrtIROT4XGTA4D/LWGten6E3ocm7cy9SIrmNHOL5XVbVuckUp3X6Xyg8/zpvHA== +array.prototype.flatmap@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.0.tgz#a7e8ed4225f4788a70cd910abcf0791e76a5534f" + integrity sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg== dependencies: - call-bind "^1.0.0" + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.19.0" - -astral-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" - integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== - -babel-eslint@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232" - integrity sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.7.0" - "@babel/traverse" "^7.7.0" - "@babel/types" "^7.7.0" - eslint-visitor-keys "^1.0.0" - resolve "^1.12.0" + es-abstract "^1.19.2" + es-shim-unscopables "^1.0.0" balanced-match@^1.0.0: version "1.0.0" @@ -420,13 +466,24 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1: +braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" +browserslist@^4.20.2: + version "4.20.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.4.tgz#98096c9042af689ee1e0271333dbc564b8ce4477" + integrity sha512-ok1d+1WpnU24XYN7oC3QWgTyMhY/avPJ/r9T00xxvUOIparA/gc+UPUMaod3i+G6s+nI2nUb9xZ5k794uIwShw== + dependencies: + caniuse-lite "^1.0.30001349" + electron-to-chromium "^1.4.147" + escalade "^3.1.1" + node-releases "^2.0.5" + picocolors "^1.0.0" + call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -440,6 +497,11 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.0.0.tgz#fb7eb569b72ad7a45812f93fd9430a3e410b3dd3" integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw== +caniuse-lite@^1.0.30001349: + version "1.0.30001364" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001364.tgz" + integrity sha512-9O0xzV3wVyX0SlegIQ6knz+okhBB5pE0PC40MNdwcipjwpxoUEHL24uJ+gG42cgklPjfO5ZjZPme9FTSN3QT2Q== + chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -486,6 +548,13 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +convert-source-map@^1.7.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" + integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== + dependencies: + safe-buffer "~5.1.1" + cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -495,20 +564,20 @@ cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" -debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - -debug@^4.3.2: +debug@^4.1.0, debug@^4.1.1, debug@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== dependencies: ms "2.1.2" +debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + deep-is@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -521,6 +590,14 @@ define-properties@^1.1.3: dependencies: object-keys "^1.0.12" +define-properties@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" + integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== + dependencies: + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -542,17 +619,10 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -enquirer@^2.3.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== - dependencies: - ansi-colors "^4.1.1" +electron-to-chromium@^1.4.147: + version "1.4.160" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.160.tgz#da54e24fddeaca52f37965c7bec1bd964c97d487" + integrity sha512-O1Z12YfyeX2LXYO7MdHIPazGXzLzQnr1ADW55U2ARQsJBPgfpJz3u+g3Mo2l1wSyfOCdiGqaX9qtV4XKZ0HNRA== es-abstract@^1.19.0, es-abstract@^1.19.1: version "1.19.1" @@ -580,6 +650,42 @@ es-abstract@^1.19.0, es-abstract@^1.19.1: string.prototype.trimstart "^1.0.4" unbox-primitive "^1.0.1" +es-abstract@^1.19.2, es-abstract@^1.19.5: + version "1.20.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814" + integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA== + dependencies: + call-bind "^1.0.2" + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.1.1" + get-symbol-description "^1.0.0" + has "^1.0.3" + has-property-descriptors "^1.0.0" + has-symbols "^1.0.3" + internal-slot "^1.0.3" + is-callable "^1.2.4" + is-negative-zero "^2.0.2" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + is-string "^1.0.7" + is-weakref "^1.0.2" + object-inspect "^1.12.0" + object-keys "^1.1.1" + object.assign "^4.1.2" + regexp.prototype.flags "^1.4.3" + string.prototype.trimend "^1.0.5" + string.prototype.trimstart "^1.0.5" + unbox-primitive "^1.0.2" + +es-shim-unscopables@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz#702e632193201e3edf8713635d083d378e510241" + integrity sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w== + dependencies: + has "^1.0.3" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -589,6 +695,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -599,10 +710,10 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-config-prettier@^8.3.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" - integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== eslint-plugin-eslint-comments@^3.2.0: version "3.2.0" @@ -612,67 +723,67 @@ eslint-plugin-eslint-comments@^3.2.0: escape-string-regexp "^1.0.5" ignore "^5.0.5" -eslint-plugin-flowtype@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-7.0.0.tgz#da07684b5f0caf7c42ed013c2d0c04dbaf2960f4" - integrity sha512-kW3eipG2Vth6e0apYqmFs05IHhFklJJNokYNiNEO5AIjm7H29oTDybYNB2bMULUYcf7iX7Wf3GdRhfBORKcT1g== +eslint-plugin-ft-flow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-ft-flow/-/eslint-plugin-ft-flow-2.0.1.tgz#57d9a12ef02b7af8f9bd6ccd6bd8fa4034809716" + integrity sha512-dGBnCo+ok6H9p6Vw2oPFEM4vA9IEclRXQQAA/Zws51/L5zr3FDl9FxQiWGfaw0WaTIX5biiAxp/q1W5bGXjlVA== dependencies: lodash "^4.17.21" string-natural-compare "^3.0.1" -eslint-plugin-jest@^25.2.4: - version "25.2.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.2.4.tgz#bb9f6a0bd1fd524ffb0b8b7a159cd70a58a1a793" - integrity sha512-HRyinpgmEdkVr7pNPaYPHCoGqEzpgk79X8pg/xCeoAdurbyQjntJQ4pTzHl7BiVEBlam/F1Qsn+Dk0HtJO7Aaw== +eslint-plugin-jest@^26.5.3: + version "26.5.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.5.3.tgz#a3ceeaf4a757878342b8b00eca92379b246e5505" + integrity sha512-sICclUqJQnR1bFRZGLN2jnSVsYOsmPYYnroGCIMVSvTS3y8XR3yjzy1EcTQmk6typ5pRgyIWzbjqxK6cZHEZuQ== dependencies: - "@typescript-eslint/experimental-utils" "^5.0.0" + "@typescript-eslint/utils" "^5.10.0" -eslint-plugin-prettier@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0" - integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ== +eslint-plugin-prettier@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" + integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ== dependencies: prettier-linter-helpers "^1.0.0" -eslint-plugin-react-hooks@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556" - integrity sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ== +eslint-plugin-react-hooks@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" + integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== eslint-plugin-react-native-globals@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2" integrity sha512-9aEPf1JEpiTjcFAmmyw8eiIXmcNZOqaZyHO77wgm0/dWfT/oxC1SrIq8ET38pMxHYrcB6Uew+TzUVsBeczF88g== -eslint-plugin-react-native@^3.11.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-3.11.0.tgz#c73b0886abb397867e5e6689d3a6a418682e6bac" - integrity sha512-7F3OTwrtQPfPFd+VygqKA2VZ0f2fz0M4gJmry/TRE18JBb94/OtMxwbL7Oqwu7FGyrdeIOWnXQbBAveMcSTZIA== +eslint-plugin-react-native@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-native/-/eslint-plugin-react-native-4.0.0.tgz#eec41984abe4970bdd7c6082dff7a98a5e34d0bb" + integrity sha512-kMmdxrSY7A1WgdqaGC+rY/28rh7kBGNBRsk48ovqkQmdg5j4K+DaFmegENDzMrdLkoufKGRNkKX6bgSwQTCAxQ== dependencies: "@babel/traverse" "^7.7.4" eslint-plugin-react-native-globals "^0.1.1" -eslint-plugin-react@^7.26.1: - version "7.26.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.26.1.tgz#41bcfe3e39e6a5ac040971c1af94437c80daa40e" - integrity sha512-Lug0+NOFXeOE+ORZ5pbsh6mSKjBKXDXItUD2sQoT+5Yl0eoT82DqnXeTMfUare4QVCn9QwXbfzO/dBLjLXwVjQ== +eslint-plugin-react@^7.30.1: + version "7.30.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.30.1.tgz#2be4ab23ce09b5949c6631413ba64b2810fd3e22" + integrity sha512-NbEvI9jtqO46yJA3wcRF9Mo0lF9T/jhdHqhCHXiXtD+Zcb98812wvokjWpU7Q4QH5edo6dmqrukxVvWWXHlsUg== dependencies: - array-includes "^3.1.3" - array.prototype.flatmap "^1.2.4" + array-includes "^3.1.5" + array.prototype.flatmap "^1.3.0" doctrine "^2.1.0" - estraverse "^5.2.0" + estraverse "^5.3.0" jsx-ast-utils "^2.4.1 || ^3.0.0" - minimatch "^3.0.4" - object.entries "^1.1.4" - object.fromentries "^2.0.4" - object.hasown "^1.0.0" - object.values "^1.1.4" - prop-types "^15.7.2" + minimatch "^3.1.2" + object.entries "^1.1.5" + object.fromentries "^2.0.5" + object.hasown "^1.1.1" + object.values "^1.1.5" + prop-types "^15.8.1" resolve "^2.0.0-next.3" semver "^6.3.0" - string.prototype.matchall "^4.0.5" + string.prototype.matchall "^4.0.7" -eslint-scope@^5.0.0, eslint-scope@^5.1.1: +eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -680,12 +791,13 @@ eslint-scope@^5.0.0, eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-utils@^2.0.0, eslint-utils@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" - integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== +eslint-scope@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" + integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== dependencies: - eslint-visitor-keys "^1.1.0" + esrecurse "^4.3.0" + estraverse "^5.2.0" eslint-utils@^3.0.0: version "3.0.0" @@ -694,89 +806,65 @@ eslint-utils@^3.0.0: dependencies: eslint-visitor-keys "^2.0.0" -eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" - integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== +eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint-visitor-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" - integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== - -eslint-visitor-keys@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz#eee4acea891814cda67a7d8812d9647dd0179af2" - integrity sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA== - -eslint@^7.32.0: - version "7.32.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d" - integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA== - dependencies: - "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.3" - "@humanwhocodes/config-array" "^0.5.0" +eslint-visitor-keys@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + +eslint@^8.19.0: + version "8.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.19.0.tgz#7342a3cbc4fbc5c106a1eefe0fd0b50b6b1a7d28" + integrity sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw== + dependencies: + "@eslint/eslintrc" "^1.3.0" + "@humanwhocodes/config-array" "^0.9.2" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" - debug "^4.0.1" + debug "^4.3.2" doctrine "^3.0.0" - enquirer "^2.3.5" escape-string-regexp "^4.0.0" - eslint-scope "^5.1.1" - eslint-utils "^2.1.0" - eslint-visitor-keys "^2.0.0" - espree "^7.3.1" + eslint-scope "^7.1.1" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.3.0" + espree "^9.3.2" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" - glob-parent "^5.1.2" - globals "^13.6.0" - ignore "^4.0.6" + glob-parent "^6.0.1" + globals "^13.15.0" + ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" - js-yaml "^3.13.1" + js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" - minimatch "^3.0.4" + minimatch "^3.1.2" natural-compare "^1.4.0" optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.1.0" - semver "^7.2.1" - strip-ansi "^6.0.0" + regexpp "^3.2.0" + strip-ansi "^6.0.1" strip-json-comments "^3.1.0" - table "^6.0.9" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" - integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== +espree@^9.3.2: + version "9.3.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.3.2.tgz#f58f77bd334731182801ced3380a8cc859091596" + integrity sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA== dependencies: - acorn "^7.4.0" - acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.3.0" - -espree@^7.3.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" - integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== - dependencies: - acorn "^7.4.0" - acorn-jsx "^5.3.1" - eslint-visitor-keys "^1.3.0" - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + acorn "^8.7.1" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.3.0" esquery@^1.4.0: version "1.4.0" @@ -802,17 +890,17 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== +estraverse@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= -fast-deep-equal@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" - integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== - -fast-deep-equal@^3.1.3: +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== @@ -822,17 +910,16 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== -fast-glob@^3.1.1: - version "3.2.5" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661" - integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg== +fast-glob@^3.2.9: + version "3.2.11" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" + integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.0" + glob-parent "^5.1.2" merge2 "^1.3.0" - micromatch "^4.0.2" - picomatch "^2.2.1" + micromatch "^4.0.4" fast-json-stable-stringify@^2.0.0: version "2.0.0" @@ -888,11 +975,31 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +function.prototype.name@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.0" + functions-have-names "^1.2.2" + functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +functions-have-names@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== + +gensync@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== + get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" @@ -910,13 +1017,20 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" -glob-parent@^5.1.0, glob-parent@^5.1.2: +glob-parent@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" +glob-parent@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + glob@^7.1.3: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" @@ -934,35 +1048,23 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e" integrity sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw== -globals@^13.6.0, globals@^13.9.0: - version "13.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.0.tgz#4d733760304230a0082ed96e21e5c565f898089e" - integrity sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg== +globals@^13.15.0: + version "13.16.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.16.0.tgz#9be4aca28f311aaeb974ea54978ebbb5e35ce46a" + integrity sha512-A1lrQfpNF+McdPOnnFqY3kSN0AFTy485bTi1bkLk4mVPODIUEcSfhHgRqA+QdXPksrSTTztYXx37NFV+GpGk3Q== dependencies: type-fest "^0.20.2" -globby@^11.0.1: - version "11.0.3" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.3.tgz#9b1f0cb523e171dd1ad8c7b2a9fb4b644b9593cb" - integrity sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" - slash "^3.0.0" - -globby@^11.0.4: - version "11.0.4" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" - integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: array-union "^2.1.0" dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" slash "^3.0.0" has-bigints@^1.0.1: @@ -970,6 +1072,11 @@ has-bigints@^1.0.1: resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== +has-bigints@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -980,16 +1087,23 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.0, has-symbols@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" - integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" -has-symbols@^1.0.2: +has-symbols@^1.0.1, has-symbols@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + has-tostringtag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" @@ -1004,20 +1118,10 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - -ignore@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.0.5.tgz#c663c548d6ce186fb33616a8ccb5d46e56bdbbf9" - integrity sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA== - -ignore@^5.1.4: - version "5.1.8" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" - integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +ignore@^5.0.5, ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.2.1" @@ -1069,12 +1173,7 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-callable@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" - integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== - -is-callable@^1.2.4: +is-callable@^1.1.4, is-callable@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== @@ -1096,19 +1195,7 @@ is-extglob@^2.1.1: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.0, is-glob@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-glob@^4.0.3: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -1120,6 +1207,11 @@ is-negative-zero@^2.0.1: resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== +is-negative-zero@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== + is-number-object@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.6.tgz#6a7aaf838c7f0686a50b4553f7e54a96494e89f0" @@ -1145,26 +1237,21 @@ is-shared-array-buffer@^1.0.1: resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz#97b0c85fbdacb59c9c446fe653b82cf2b5b7cfe6" integrity sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA== -is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== +is-shared-array-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" -is-string@^1.0.7: +is-string@^1.0.5, is-string@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== dependencies: has-tostringtag "^1.0.0" -is-symbol@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38" - integrity sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw== - dependencies: - has-symbols "^1.0.0" - -is-symbol@^1.0.3: +is-symbol@^1.0.2, is-symbol@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== @@ -1178,6 +1265,13 @@ is-weakref@^1.0.1: dependencies: call-bind "^1.0.0" +is-weakref@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== + dependencies: + call-bind "^1.0.2" + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -1188,13 +1282,12 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: - argparse "^1.0.7" - esprima "^4.0.0" + argparse "^2.0.1" jsesc@^2.5.1: version "2.5.2" @@ -1206,16 +1299,16 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +json5@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" + integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + "jsx-ast-utils@^2.4.1 || ^3.0.0": version "3.2.1" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.1.tgz#720b97bfe7d901b927d87c3773637ae8ea48781b" @@ -1237,16 +1330,6 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.truncate@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" - integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= - -lodash@^4.17.15, lodash@^4.17.19: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== - lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" @@ -1266,18 +1349,18 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -merge2@^1.3.0: +merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -micromatch@^4.0.2: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - braces "^3.0.1" - picomatch "^2.2.3" + braces "^3.0.2" + picomatch "^2.3.1" minimatch@^3.0.4: version "3.0.4" @@ -1286,21 +1369,28 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" +minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= +node-releases@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.5.tgz#280ed5bc3eba0d96ce44897d8aee478bfb3d9666" + integrity sha512-U9h1NLROZTq9uE1SNffn6WuPDg8icmi3ns4rEl/oTfIle4iLjTliCzgTsbaIFMq/Xn078/lfY/BL0GWZ+psK4Q== + object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -1311,6 +1401,11 @@ object-inspect@^1.11.0, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg== +object-inspect@^1.12.0: + version "1.12.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" + integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== + object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -1326,7 +1421,7 @@ object.assign@^4.1.2: has-symbols "^1.0.1" object-keys "^1.1.1" -object.entries@^1.1.4: +object.entries@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.5.tgz#e1acdd17c4de2cd96d5a08487cfb9db84d881861" integrity sha512-TyxmjUoZggd4OrrU1W66FMDG6CuqJxsFvymeyXI51+vQLN67zYfZseptRge703kKQdo4uccgAKebXFcRCzk4+g== @@ -1335,7 +1430,7 @@ object.entries@^1.1.4: define-properties "^1.1.3" es-abstract "^1.19.1" -object.fromentries@^2.0.4: +object.fromentries@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.5.tgz#7b37b205109c21e741e605727fe8b0ad5fa08251" integrity sha512-CAyG5mWQRRiBU57Re4FKoTBjXfDoNwdFVH2Y1tS9PqCsfUTymAohOkEMSG3aRNKmv4lV3O7p1et7c187q6bynw== @@ -1344,15 +1439,15 @@ object.fromentries@^2.0.4: define-properties "^1.1.3" es-abstract "^1.19.1" -object.hasown@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.0.tgz#7232ed266f34d197d15cac5880232f7a4790afe5" - integrity sha512-MhjYRfj3GBlhSkDHo6QmvgjRLXQ2zndabdf3nX0yTyZK9rPfxb6uRpAac8HXNLy1GpqWtZ81Qh4v3uOls2sRAg== +object.hasown@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.1.tgz#ad1eecc60d03f49460600430d97f23882cf592a3" + integrity sha512-LYLe4tivNQzq4JdaWW6WO3HMZZJWzkkH8fnI6EebWl0VZth2wL2Lovm74ep2/gZzlaTdV62JZHEqHQ2yVn8Q/A== dependencies: - define-properties "^1.1.3" - es-abstract "^1.19.1" + define-properties "^1.1.4" + es-abstract "^1.19.5" -object.values@^1.1.4: +object.values@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" integrity sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg== @@ -1407,10 +1502,15 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -picomatch@^2.2.1, picomatch@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.3.tgz#465547f359ccc206d3c48e46a1bcb89bf7ee619d" - integrity sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg== +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== prelude-ls@^1.2.1: version "1.2.1" @@ -1429,19 +1529,14 @@ prettier@^2.4.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - -prop-types@^15.7.2: - version "15.7.2" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" - integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== +prop-types@^15.8.1: + version "15.8.1" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" + integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== dependencies: loose-envify "^1.4.0" object-assign "^4.1.1" - react-is "^16.8.1" + react-is "^16.13.1" punycode@^2.1.0: version "2.1.1" @@ -1453,41 +1548,30 @@ queue-microtask@^1.2.2: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== -react-is@^16.8.1: - version "16.8.4" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2" - integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA== +react-is@^16.13.1: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== -regexp.prototype.flags@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz#7ef352ae8d159e758c0eadca6f8fcb4eef07be26" - integrity sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA== +regexp.prototype.flags@^1.4.1, regexp.prototype.flags@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" + integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== dependencies: call-bind "^1.0.2" define-properties "^1.1.3" + functions-have-names "^1.2.2" -regexpp@^3.0.0, regexpp@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" - integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== - -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== +regexpp@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" + integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.12.0: - version "1.15.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" - integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== - dependencies: - path-parse "^1.0.6" - resolve@^2.0.0-next.3: version "2.0.0-next.3" resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.3.tgz#d41016293d4a8586a39ca5d9b5f15cbea1f55e46" @@ -1515,20 +1599,20 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" +safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.2.1, semver@^7.3.2: - version "7.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" - integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== - -semver@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== +semver@^7.3.7: + version "7.3.7" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== dependencies: lru-cache "^6.0.0" @@ -1558,51 +1642,23 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slice-ansi@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" - integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== - dependencies: - ansi-styles "^4.0.0" - astral-regex "^2.0.0" - is-fullwidth-code-point "^3.0.0" - -source-map@^0.5.0: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= - string-natural-compare@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== -string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string.prototype.matchall@^4.0.5: - version "4.0.6" - resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.6.tgz#5abb5dabc94c7b0ea2380f65ba610b3a544b15fa" - integrity sha512-6WgDX8HmQqvEd7J+G6VtAahhsQIssiZ8zl7zKh1VDMFyL3hRTJP4FTNA3RbIp2TOQ9AYNDcc7e3fH0Qbup+DBg== +string.prototype.matchall@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz#8e6ecb0d8a1fb1fda470d81acecb2dba057a481d" + integrity sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg== dependencies: call-bind "^1.0.2" define-properties "^1.1.3" es-abstract "^1.19.1" get-intrinsic "^1.1.1" - has-symbols "^1.0.2" + has-symbols "^1.0.3" internal-slot "^1.0.3" - regexp.prototype.flags "^1.3.1" + regexp.prototype.flags "^1.4.1" side-channel "^1.0.4" string.prototype.trimend@^1.0.4: @@ -1613,6 +1669,15 @@ string.prototype.trimend@^1.0.4: call-bind "^1.0.2" define-properties "^1.1.3" +string.prototype.trimend@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz#914a65baaab25fbdd4ee291ca7dde57e869cb8d0" + integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" + string.prototype.trimstart@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" @@ -1621,12 +1686,14 @@ string.prototype.trimstart@^1.0.4: call-bind "^1.0.2" define-properties "^1.1.3" -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== +string.prototype.trimstart@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz#5466d93ba58cfa2134839f81d7f42437e8c01fef" + integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== dependencies: - ansi-regex "^5.0.0" + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.19.5" strip-ansi@^6.0.1: version "6.0.1" @@ -1654,17 +1721,6 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -table@^6.0.9: - version "6.7.3" - resolved "https://registry.yarnpkg.com/table/-/table-6.7.3.tgz#255388439715a738391bd2ee4cbca89a4d05a9b7" - integrity sha512-5DkIxeA7XERBqMwJq0aHZOdMadBx4e6eDoFRuyT5VR82J0Ycg2DwM6GfA/EQAhJ+toRTaS1lIdSQCqgrmhPnlw== - dependencies: - ajv "^8.0.1" - lodash.truncate "^4.4.2" - slice-ansi "^4.0.0" - string-width "^4.2.3" - strip-ansi "^6.0.1" - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -1687,13 +1743,6 @@ tslib@^1.8.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== -tsutils@^3.17.1: - version "3.17.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" - integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== - dependencies: - tslib "^1.8.1" - tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -1723,6 +1772,16 @@ unbox-primitive@^1.0.1: has-symbols "^1.0.2" which-boxed-primitive "^1.0.2" +unbox-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== + dependencies: + call-bind "^1.0.2" + has-bigints "^1.0.2" + has-symbols "^1.0.3" + which-boxed-primitive "^1.0.2" + uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" diff --git a/packages/eslint-plugin-react-native-community/__tests__/error-subclass-name-test.js b/packages/eslint-plugin-react-native-community/__tests__/error-subclass-name-test.js index 6a11a6f3ae5cfb..39787fb0944bbc 100644 --- a/packages/eslint-plugin-react-native-community/__tests__/error-subclass-name-test.js +++ b/packages/eslint-plugin-react-native-community/__tests__/error-subclass-name-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-react-native-community/__tests__/eslint-tester.js b/packages/eslint-plugin-react-native-community/__tests__/eslint-tester.js index ea767a705b790f..7ad39befe0bed8 100644 --- a/packages/eslint-plugin-react-native-community/__tests__/eslint-tester.js +++ b/packages/eslint-plugin-react-native-community/__tests__/eslint-tester.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,8 +12,9 @@ const ESLintTester = require('eslint').RuleTester; ESLintTester.setDefaultConfig({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), parserOptions: { + requireConfigFile: false, ecmaVersion: 6, sourceType: 'module', }, diff --git a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js index 6e3ee40f91ceaf..81df7cb6a91d63 100644 --- a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js +++ b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -22,6 +22,7 @@ eslintTester.run('../platform-colors', rule, { "const color = PlatformColor('controlAccentColor', 'controlColor');", "const color = DynamicColorIOS({light: 'black', dark: 'white'});", "const color = DynamicColorIOS({light: PlatformColor('black'), dark: PlatformColor('white')});", + "const color = DynamicColorIOS({light: PlatformColor('black'), dark: PlatformColor('white'), highContrastLight: PlatformColor('black'), highContrastDark: PlatformColor('white')});", ], invalid: [ { @@ -38,11 +39,11 @@ eslintTester.run('../platform-colors', rule, { }, { code: "const black = 'black'; const color = DynamicColorIOS({light: black, dark: 'white'});", - errors: [{message: rule.meta.messages.dynamicColorIOSLight}], + errors: [{message: rule.meta.messages.dynamicColorIOSValue}], }, { code: "const white = 'white'; const color = DynamicColorIOS({light: 'black', dark: white});", - errors: [{message: rule.meta.messages.dynamicColorIOSDark}], + errors: [{message: rule.meta.messages.dynamicColorIOSValue}], }, ], }); diff --git a/packages/eslint-plugin-react-native-community/error-subclass-name.js b/packages/eslint-plugin-react-native-community/error-subclass-name.js index 0c0c8f33f127e0..3791436ba813b1 100644 --- a/packages/eslint-plugin-react-native-community/error-subclass-name.js +++ b/packages/eslint-plugin-react-native-community/error-subclass-name.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-react-native-community/index.js b/packages/eslint-plugin-react-native-community/index.js index 22d01cce278dc2..3a1fa9896a49b4 100644 --- a/packages/eslint-plugin-react-native-community/index.js +++ b/packages/eslint-plugin-react-native-community/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-react-native-community/no-haste-imports.js b/packages/eslint-plugin-react-native-community/no-haste-imports.js index 5282c6950ec2d6..6c5c855a2ab4c6 100644 --- a/packages/eslint-plugin-react-native-community/no-haste-imports.js +++ b/packages/eslint-plugin-react-native-community/no-haste-imports.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-react-native-community/package.json b/packages/eslint-plugin-react-native-community/package.json index 947d62498461b2..29c7ddaa610262 100644 --- a/packages/eslint-plugin-react-native-community/package.json +++ b/packages/eslint-plugin-react-native-community/package.json @@ -1,6 +1,6 @@ { "name": "@react-native-community/eslint-plugin", - "version": "1.1.0", + "version": "1.2.0", "description": "ESLint rules for @react-native-community/eslint-config", "main": "index.js", "repository": { diff --git a/packages/eslint-plugin-react-native-community/platform-colors.js b/packages/eslint-plugin-react-native-community/platform-colors.js index e24e7b7aaa2744..cfbabd1a923c1b 100644 --- a/packages/eslint-plugin-react-native-community/platform-colors.js +++ b/packages/eslint-plugin-react-native-community/platform-colors.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,11 +20,9 @@ module.exports = { platformColorArgTypes: 'PlatformColor() every argument must be a literal.', dynamicColorIOSArg: - 'DynamicColorIOS() must take a single argument of type Object containing two keys: light and dark.', - dynamicColorIOSLight: - 'DynamicColorIOS() light value must be either a literal or a PlatformColor() call.', - dynamicColorIOSDark: - 'DynamicColorIOS() dark value must be either a literal or a PlatformColor() call.', + 'DynamicColorIOS() must take a single argument of type Object', + dynamicColorIOSValue: + 'DynamicColorIOS() value must be either a literal or a PlatformColor() call.', }, schema: [], }, @@ -58,48 +56,22 @@ module.exports = { return; } const properties = args[0].properties; - if ( - !( - properties[0].type === 'Property' && - properties[0].key.name === 'light' && - properties[1].type === 'Property' && - properties[1].key.name === 'dark' - ) - ) { - context.report({ - node, - messageId: 'dynamicColorIOSArg', - }); - return; - } - const light = properties[0]; - if ( - !( - light.value.type === 'Literal' || - (light.value.type === 'CallExpression' && - light.value.callee.name === 'PlatformColor') - ) - ) { - context.report({ - node, - messageId: 'dynamicColorIOSLight', - }); - return; - } - const dark = properties[1]; - if ( - !( - dark.value.type === 'Literal' || - (dark.value.type === 'CallExpression' && - dark.value.callee.name === 'PlatformColor') - ) - ) { - context.report({ - node, - messageId: 'dynamicColorIOSDark', - }); - return; - } + properties.forEach(property => { + if ( + !( + property.type === 'Property' && + (property.value.type === 'Literal' || + (property.value.type === 'CallExpression' && + property.value.callee.name === 'PlatformColor')) + ) + ) { + context.report({ + node, + messageId: 'dynamicColorIOSValue', + }); + return; + } + }); } }, }; diff --git a/packages/eslint-plugin-codegen/BUCK b/packages/eslint-plugin-specs/BUCK similarity index 100% rename from packages/eslint-plugin-codegen/BUCK rename to packages/eslint-plugin-specs/BUCK diff --git a/packages/eslint-plugin-codegen/__tests__/eslint-tester.js b/packages/eslint-plugin-specs/__tests__/eslint-tester.js similarity index 62% rename from packages/eslint-plugin-codegen/__tests__/eslint-tester.js rename to packages/eslint-plugin-specs/__tests__/eslint-tester.js index ea767a705b790f..c6937e8cd049a8 100644 --- a/packages/eslint-plugin-codegen/__tests__/eslint-tester.js +++ b/packages/eslint-plugin-specs/__tests__/eslint-tester.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,10 +12,14 @@ const ESLintTester = require('eslint').RuleTester; ESLintTester.setDefaultConfig({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), parserOptions: { + requireConfigFile: false, ecmaVersion: 6, sourceType: 'module', + babelOptions: { + presets: [require.resolve('@babel/preset-flow')], + }, }, }); diff --git a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js b/packages/eslint-plugin-specs/__tests__/react-native-modules-test.js similarity index 95% rename from packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js rename to packages/eslint-plugin-specs/__tests__/react-native-modules-test.js index 7591ffb86a8d82..afa544725c3796 100644 --- a/packages/eslint-plugin-codegen/__tests__/react-native-modules-test.js +++ b/packages/eslint-plugin-specs/__tests__/react-native-modules-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-codegen/index.js b/packages/eslint-plugin-specs/index.js similarity index 86% rename from packages/eslint-plugin-codegen/index.js rename to packages/eslint-plugin-specs/index.js index 60a5f864f7ac42..4a0b58ad557266 100644 --- a/packages/eslint-plugin-codegen/index.js +++ b/packages/eslint-plugin-specs/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/eslint-plugin-codegen/package.json b/packages/eslint-plugin-specs/package.json similarity index 62% rename from packages/eslint-plugin-codegen/package.json rename to packages/eslint-plugin-specs/package.json index f82575f74cb036..8339cd008eea5e 100644 --- a/packages/eslint-plugin-codegen/package.json +++ b/packages/eslint-plugin-specs/package.json @@ -1,19 +1,24 @@ { - "name": "@react-native/eslint-plugin-codegen", - "version": "0.0.1", + "name": "@react-native/eslint-plugin-specs", + "version": "0.0.4", "description": "ESLint rules to validate NativeModule and Component Specs", "main": "index.js", "repository": { "type": "git", "url": "git@github.com:facebook/react-native.git", - "directory": "packages/eslint-plugin-codegen" + "directory": "packages/eslint-plugin-specs" + }, + "scripts": { + "prepublish": "node prepublish.js" }, "dependencies": { "@babel/core": "^7.14.0", + "@babel/eslint-parser": "^7.18.2", "@babel/plugin-transform-flow-strip-types": "^7.0.0", + "@babel/preset-flow": "^7.17.12", "flow-parser": "^0.121.0", "make-dir": "^2.1.0", - "pirates":"^4.0.1", + "pirates": "^4.0.1", "react-native-codegen": "*", "source-map-support": "0.5.0" }, diff --git a/packages/eslint-plugin-specs/prepublish.js b/packages/eslint-plugin-specs/prepublish.js new file mode 100644 index 00000000000000..3a3c445149766b --- /dev/null +++ b/packages/eslint-plugin-specs/prepublish.js @@ -0,0 +1,44 @@ +/** + * 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. + * + * @format + */ + +const fs = require('fs'); + +/** + * script to prepare package for publish. + * + * Due to differences to how we consume internal packages, update a flag + */ + +fs.readFile('./react-native-modules.js', 'utf8', function (readError, source) { + if (readError != null) { + return console.error( + 'Failed to read react-native-modules.js for publish', + readError, + ); + } + + const result = source.replace( + 'const PACKAGE_USAGE = false;', + 'const PACKAGE_USAGE = true;', + ); + + fs.writeFile( + './react-native-modules.js', + result, + 'utf8', + function (writeError) { + if (writeError != null) { + return console.error( + 'Failed to update react-native-modules.js for publish', + writeError, + ); + } + }, + ); +}); diff --git a/packages/eslint-plugin-codegen/react-native-modules.js b/packages/eslint-plugin-specs/react-native-modules.js similarity index 75% rename from packages/eslint-plugin-codegen/react-native-modules.js rename to packages/eslint-plugin-specs/react-native-modules.js index c5f19fc0c30b87..ae0041b0484452 100644 --- a/packages/eslint-plugin-codegen/react-native-modules.js +++ b/packages/eslint-plugin-specs/react-native-modules.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -13,6 +13,8 @@ const path = require('path'); const withBabelRegister = require('./with-babel-register'); +// We run yarn prepublish before publishing package which will set this value to true +const PACKAGE_USAGE = false; const ERRORS = { misnamedHasteModule(hasteModuleName) { return `Module ${hasteModuleName}: All files using TurboModuleRegistry must start with Native.`; @@ -24,15 +26,28 @@ let RNParserUtils; function requireModuleParser() { if (RNModuleParser == null || RNParserUtils == null) { - 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/flow/utils'); - }); + // 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/flow/utils'); + }); + } else { + const config = { + 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/flow/utils'); + }); + } } return { diff --git a/packages/eslint-plugin-codegen/with-babel-register/disk-cache.js b/packages/eslint-plugin-specs/with-babel-register/disk-cache.js similarity index 95% rename from packages/eslint-plugin-codegen/with-babel-register/disk-cache.js rename to packages/eslint-plugin-specs/with-babel-register/disk-cache.js index 9d318a39bf6a39..70184943ecc0ea 100644 --- a/packages/eslint-plugin-codegen/with-babel-register/disk-cache.js +++ b/packages/eslint-plugin-specs/with-babel-register/disk-cache.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,7 +24,7 @@ const packageJson = JSON.parse( const FILENAME = path.join( os.tmpdir(), - `.eslint-plugin-codegen.${packageJson.version}.disk-cache.json`, + `.eslint-plugin-specs.${packageJson.version}.disk-cache.json`, ); let data = {}; diff --git a/packages/eslint-plugin-codegen/with-babel-register/index.js b/packages/eslint-plugin-specs/with-babel-register/index.js similarity index 97% rename from packages/eslint-plugin-codegen/with-babel-register/index.js rename to packages/eslint-plugin-specs/with-babel-register/index.js index c8b2484e5fa5ef..649954b33b5e99 100644 --- a/packages/eslint-plugin-codegen/with-babel-register/index.js +++ b/packages/eslint-plugin-specs/with-babel-register/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/normalize-color/BUCK b/packages/normalize-color/BUCK index e99164634de048..17fbdd53bd8da7 100644 --- a/packages/normalize-color/BUCK +++ b/packages/normalize-color/BUCK @@ -1,14 +1,12 @@ -load("@fbsource//tools/build_defs:js_glob.bzl", "js_glob") load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace") load("@fbsource//xplat/js:JS_DEFS.bzl", "rn_library") rn_library( name = "normalize-color", - srcs = js_glob([ - "**/*", - "package.json", - ]), - labels = ["supermodule:xplat/default/public.react_native.core"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.core", + ], skip_processors = True, visibility = ["PUBLIC"], ) diff --git a/packages/normalize-color/__tests__/normalizeColor-test.js b/packages/normalize-color/__tests__/normalizeColor-test.js index 2d19da76b8405f..257ae1db0cbcfd 100644 --- a/packages/normalize-color/__tests__/normalizeColor-test.js +++ b/packages/normalize-color/__tests__/normalizeColor-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/normalize-color/index.js b/packages/normalize-color/index.js index fb8a8bb5675e84..a20b1c3486d43f 100644 --- a/packages/normalize-color/index.js +++ b/packages/normalize-color/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/normalize-color/index.js.flow b/packages/normalize-color/index.js.flow index c6199ff6deeb26..4d24656d835e4f 100644 --- a/packages/normalize-color/index.js.flow +++ b/packages/normalize-color/index.js.flow @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/polyfills/BUCK b/packages/polyfills/BUCK index a19feef73d5986..7b9950a185c1ce 100644 --- a/packages/polyfills/BUCK +++ b/packages/polyfills/BUCK @@ -24,7 +24,10 @@ rn_library( name = "polyfills", base_path = relative_path_to_js_root() + "node_modules/@react-native/polyfills/", is_polyfill = True, - labels = ["supermodule:xplat/default/public.react_native.core"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.core", + ], node_modules_check_enabled = False, skip_processors = True, # Don't anticipate routes or fbicon here visibility = ["PUBLIC"], diff --git a/packages/polyfills/Object.es8.js b/packages/polyfills/Object.es8.js index 80bfb16623f05d..4925f6e2dee071 100644 --- a/packages/polyfills/Object.es8.js +++ b/packages/polyfills/Object.es8.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/polyfills/__tests__/Object.es8-test.js b/packages/polyfills/__tests__/Object.es8-test.js index b52771226eb16e..697b6cd1c3c451 100644 --- a/packages/polyfills/__tests__/Object.es8-test.js +++ b/packages/polyfills/__tests__/Object.es8-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/polyfills/console.js b/packages/polyfills/console.js index c2a2ed26dded22..e843f4f74caa3c 100644 --- a/packages/polyfills/console.js +++ b/packages/polyfills/console.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/polyfills/error-guard.js b/packages/polyfills/error-guard.js index d642961ba34f25..389b5a20f81477 100644 --- a/packages/polyfills/error-guard.js +++ b/packages/polyfills/error-guard.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -102,6 +102,8 @@ const ErrorUtils = { return null; } const guardName = name ?? fun.name ?? ''; + /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by + * Flow's LTI update could not be added via codemod */ function guarded(...args: TArgs): ?TOut { return ErrorUtils.applyWithGuard( fun, diff --git a/packages/polyfills/index.js b/packages/polyfills/index.js index 4b515f6a755cb1..5979051ac30132 100644 --- a/packages/polyfills/index.js +++ b/packages/polyfills/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 04c7639d8f960e..4a7708056982d5 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -39,6 +39,7 @@ rn_android_library( ["buck_tests/*.java"], ), autoglob = False, + language = "JAVA", visibility = [ "PUBLIC", ], diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index a5211ce5858ccb..834c8a9e0cdf40 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -28,34 +28,27 @@ load( "rn_apple_library", "rn_xplat_cxx_library", ) +load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace_binary") # Call this in the react-native-codegen/BUCK file def rn_codegen_cli(): if not IS_OSS_BUILD: # FB Internal Setup - fb_native.sh_binary( + yarn_workspace_binary( name = "write_to_json", - main = "src/cli/combine/combine_js_to_schema.sh", - resources = [ - "src/cli/combine/combine-js-to-schema.js", - "src/cli/combine/combine_js_to_schema.sh", + main = "src/cli/combine/combine-js-to-schema-cli.js", + root = "//xplat/js:workspace", + deps = [ ":yarn-workspace", - "//xplat/js:setup_env", ], visibility = ["PUBLIC"], ) - - fb_native.sh_binary( + yarn_workspace_binary( name = "generate_all_from_schema", - main = "src/cli/generators/generate-all.sh", - resources = native.glob( - [ - "buck_tests/**/*.js", - "src/**/*.js", - ], - ) + [ - "package.json", - "//xplat/js:setup_env", + main = "src/cli/generators/generate-all.js", + root = "//xplat/js:workspace", + deps = [ + ":yarn-workspace", ], visibility = ["PUBLIC"], ) @@ -127,7 +120,7 @@ def rn_codegen_modules( ios_assume_nonnull = ios_assume_nonnull, ), out = "codegenfiles-{}".format(name), - labels = ["codegen_rule"], + labels = ["codegen_rule", "uses_local_filesystem_abspaths"], ) ################## @@ -171,6 +164,7 @@ def rn_codegen_modules( ], autoglob = False, labels = library_labels + ["codegen_rule"], + language = "JAVA", visibility = ["PUBLIC"], deps = [ react_native_dep("third-party/java/jsr-305:jsr-305"), @@ -219,14 +213,14 @@ def rn_codegen_modules( # iOS Buck build isn't fully working in OSS, so let's skip it for OSS for now. fb_native.genrule( name = generate_module_hobjcpp_name, - cmd = "cp $(location :{})/{}.h $OUT".format(generate_fixtures_rule_name, name), + cmd = "cp $(location :{})/{}/{}.h $OUT".format(generate_fixtures_rule_name, name, name), out = "{}.h".format(name), labels = ["codegen_rule"], ) fb_native.genrule( name = generate_module_mm_name, - cmd = "cp $(location :{})/{}-generated.mm $OUT".format(generate_fixtures_rule_name, name), + cmd = "cp $(location :{})/{}/{}-generated.mm $OUT".format(generate_fixtures_rule_name, name, name), out = "{}-generated.mm".format(name), labels = ["codegen_rule"], ) @@ -282,7 +276,7 @@ def rn_codegen_components( srcs = native.glob(["src/generators/**/*.js"]), cmd = "$(exe {}) $(location {}) {} $OUT".format(react_native_root_target("packages/react-native-codegen:generate_all_from_schema"), schema_target, name), out = "codegenfiles-{}".format(name), - labels = ["codegen_rule"], + labels = ["codegen_rule", "uses_local_filesystem_abspaths"], ) fb_native.genrule( @@ -429,7 +423,7 @@ def rn_codegen_components( deps = [ "//third-party/glog:glog", "//xplat/fbsystrace:fbsystrace", - "//xplat/folly:headers_only", + "//xplat/folly:headers_only_do_not_use", "//xplat/folly:memory", "//xplat/folly:molly", YOGA_CXX_TARGET, @@ -454,7 +448,7 @@ def rn_codegen_components( compiler_flags = [ "-fexceptions", "-frtti", - "-std=c++14", + "-std=c++17", "-Wall", ], contacts = ["oncall+react_native@xmail.facebook.com"], @@ -472,20 +466,21 @@ def rn_codegen_components( # Android handling ################## if is_running_buck_project(): - rn_android_library(name = "generated_components_java-{}".format(name), autoglob = False) + rn_android_library(name = "generated_components_java-{}".format(name), autoglob = False, language = "JAVA") else: rn_android_library( name = "generated_components_java-{}".format(name), srcs = [ ":{}".format(zip_generated_java_files), ], + language = "JAVA", autoglob = False, labels = library_labels + ["codegen_rule"], visibility = ["PUBLIC"], deps = [ react_native_dep("third-party/android/androidx:annotation"), react_native_target("java/com/facebook/react/bridge:bridge"), - react_native_target("java/com/facebook/react/uimanager/interfaces:interfaces"), + react_native_target("java/com/facebook/react/uimanager:interfaces"), ], ) @@ -494,6 +489,7 @@ def rn_codegen_components( srcs = [ ":{}".format(zip_generated_cxx_files), ], + language = "JAVA", autoglob = False, labels = library_labels + ["codegen_rule"], visibility = ["PUBLIC"], @@ -508,7 +504,8 @@ def rn_codegen_components( def rn_codegen_cxx_modules( name = "", - schema_target = ""): + schema_target = "", + library_labels = []): generate_fixtures_rule_name = "generate_fixtures_cxx-{}".format(name) generate_module_h_name = "generate_module_h-{}".format(name) generate_module_cpp_name = "generate_module_cpp-{}".format(name) @@ -523,38 +520,37 @@ def rn_codegen_cxx_modules( fb_native.genrule( name = generate_module_h_name, - cmd = "cp $(location :{})/NativeModules.h $OUT".format(generate_fixtures_rule_name), - out = "NativeModules.h", + cmd = "cp $(location :{})/{}JSI.h $OUT".format(generate_fixtures_rule_name, name), + out = "{}JSI.h".format(name), labels = ["codegen_rule"], ) fb_native.genrule( name = generate_module_cpp_name, - cmd = "cp $(location :{})/NativeModules.cpp $OUT".format(generate_fixtures_rule_name), - out = "NativeModules.cpp", + cmd = "cp $(location :{})/{}JSI-generated.cpp $OUT".format(generate_fixtures_rule_name, name), + out = "{}JSI-generated.cpp".format(name), labels = ["codegen_rule"], ) if is_running_buck_project(): - rn_xplat_cxx_library(name = "generated_cxx_modules-{}".format(name)) + rn_xplat_cxx_library(name = "{}JSI".format(name), visibility = ["PUBLIC"]) else: rn_xplat_cxx_library( - name = "generated_cxx_modules-{}".format(name), + name = "{}JSI".format(name), srcs = [ ":{}".format(generate_module_cpp_name), ], headers = [ ":{}".format(generate_module_h_name), ], - header_namespace = "react/modules/{}".format(name), + header_namespace = "", exported_headers = { - "NativeModules.cpp": ":{}".format(generate_module_cpp_name), - "NativeModules.h": ":{}".format(generate_module_h_name), + "{}/{}JSI.h".format(name, name): ":{}".format(generate_module_h_name), }, fbobjc_compiler_flags = get_apple_compiler_flags(), fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), - labels = ["codegen_rule"], - platforms = (ANDROID, APPLE), + labels = library_labels + ["codegen_rule"], + platforms = (ANDROID, APPLE, CXX), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", "-DWITH_FBSYSTRACE=1", diff --git a/packages/react-native-codegen/buck_tests/emptyFile.cpp b/packages/react-native-codegen/buck_tests/emptyFile.cpp index e877243aa69fcf..624a0fdeda8591 100644 --- a/packages/react-native-codegen/buck_tests/emptyFile.cpp +++ b/packages/react-native-codegen/buck_tests/emptyFile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/emptyFile.mm b/packages/react-native-codegen/buck_tests/emptyFile.mm index b95d9380b70ee3..8dac3f61a54ff9 100644 --- a/packages/react-native-codegen/buck_tests/emptyFile.mm +++ b/packages/react-native-codegen/buck_tests/emptyFile.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java index 2811ae02b2f4a6..9a13a534a07e61 100644 --- a/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ArrayPropsNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java index 8421c641799324..102c55a43ea8fc 100644 --- a/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/BooleanPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java index 96144cd5085478..97fb8e0accd8fa 100644 --- a/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ColorPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/EdgeInsetsPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EdgeInsetsPropNativeComponentViewManager.java index 207b3f357fd753..a1d14a7025b1c3 100644 --- a/packages/react-native-codegen/buck_tests/java/EdgeInsetsPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EdgeInsetsPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java index 9b7ec1fa7b7b56..a7fd1c09b699c4 100644 --- a/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EnumPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java index 29e1d28a4f8f79..def1346b2f228c 100644 --- a/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EventNestedObjectPropsNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java index 1bba0eaef425df..96cd9ad9b5ce64 100644 --- a/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/EventPropsNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java index 3cad8d148358d4..b620fba704df3e 100644 --- a/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/FloatPropsNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java index c437963969bd7a..ec64469d725add 100644 --- a/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/ImagePropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java index 7658e141c90a68..7c24b720631284 100644 --- a/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/IntegerPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java index fcaffebed1a151..a14f8d1e7fb115 100644 --- a/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/InterfaceOnlyNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java index 6cc8bf7eeaaa9f..776213db5a564f 100644 --- a/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/MultiNativePropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java index 3f930219142bf4..2055db42662687 100644 --- a/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/NoPropsNoEventsNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/ObjectPropsNativeComponentManager.java b/packages/react-native-codegen/buck_tests/java/ObjectPropsNativeComponentManager.java index c73ed057f95def..592f9050560acb 100644 --- a/packages/react-native-codegen/buck_tests/java/ObjectPropsNativeComponentManager.java +++ b/packages/react-native-codegen/buck_tests/java/ObjectPropsNativeComponentManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java index d117a0205f7a57..63383fe8d4ece3 100644 --- a/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/PointPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java b/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java index 0ad67d3d581ba2..15e10043d54a17 100644 --- a/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java +++ b/packages/react-native-codegen/buck_tests/java/StringPropNativeComponentViewManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js index 1b3ae767521b41..fc24aadc4aeb29 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js index 289b6ff1003b2f..8a1c8ae458e5c7 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js index b8dcdaf96dbd87..a01dedbd75ecf4 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js index 921ca668a3acb4..a30e80d93419b9 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js index 72b1f5952fb636..b8f113e5df3901 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js index a12ed0ce45f7c7..50d336cb9ce7d6 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js index 8de54ec1db11b5..77193d4452e734 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js index a0a31bf3de68a4..3793ef93284d0b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js index 63b4a98a9e7d14..f90a857afd8029 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js index 1718b8877bdd79..f9cd8dadc9fef0 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js index aa33dfd4c8145f..ec192240ddeb96 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js index 675ddf1942cf00..a1a2b601d7f44c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js index d5b821db8f6aba..2beb9ecb9cd60d 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js index d39dbb5eb0f13f..8d7391970a35ac 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js index 0d450b8acd972f..ad6edbac37bc60 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js index 2da62e34fbd92c..478375d6e2df2d 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js index 291f0f6887a729..5b7d621a65570b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeArrayTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js index 4c417f55164ddb..a898b1302883e3 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeBooleanTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js index 753547d8cf4639..71bb14cf72f823 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeCallbackTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNullableTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNullableTurboModule.js index 4272eb381f0c27..e56e0346ad1d9c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNullableTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNullableTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js index 1efc1b632138e1..e47a31a2d3edeb 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeNumberTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js index ea7782d9710dda..e3b2d5df8c5a7f 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeObjectTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeOptionalObjectTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeOptionalObjectTurboModule.js index 2408df34d5d3ca..692bd52ff73c3c 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeOptionalObjectTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeOptionalObjectTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js index 34a75f6e369e78..610b3bab899aba 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativePromiseTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js index bda6ca6a9130cf..12496b4ec75d7b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleArrays.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleArrays.js index 7ee503fdce5a02..d320bd2fb338ba 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleArrays.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleArrays.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullable.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullable.js index 1c174e7f9a8e9f..2a736f08e9276e 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullable.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullable.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullableAndOptional.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullableAndOptional.js index 7863aef425698c..b8981a22ab2deb 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullableAndOptional.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleNullableAndOptional.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleOptional.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleOptional.js index 52343aebb423a6..d1b56f98938814 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleOptional.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeSampleTurboModuleOptional.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js index 684a867d695c56..b78372382b8270 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeStringTurboModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentDescriptorH-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentDescriptorH-test.js index eb79e148d3155f..d43988adbbe672 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentDescriptorH-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentDescriptorH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentHObjCpp-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentHObjCpp-test.js index 19f7ad10e3e182..9b601d20dd3f5e 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentHObjCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateComponentHObjCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterCpp-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterCpp-test.js index 6681c4f3ac2a78..09532b0f23d93c 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterH-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterH-test.js index 0d6111797de9f5..fa8da739ed4a4b 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterH-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateEventEmitterH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsCpp-test.js b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsCpp-test.js index 854d3b32a1047b..8bd33f16ca6746 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsH-test.js b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsH-test.js index 87a8058aea5e8f..950e4690e5fdfc 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsH-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaDelegate-test.js b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaDelegate-test.js index 7d64bf4755f6d2..9ffa4e7f2220f5 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaDelegate-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaDelegate-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaInterface-test.js b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaInterface-test.js index b9b0e223febdb9..54069af6be450c 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaInterface-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaInterface-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeCpp-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeCpp-test.js index 99187964cac91b..39e88c5f1c3325 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeH-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeH-test.js index 8ce360f64e7a46..330625b57b4781 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeH-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateShadowNodeH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/GenerateViewConfigJs-test.js b/packages/react-native-codegen/e2e/__tests__/components/GenerateViewConfigJs-test.js index b49b023660d2cc..116a74ef1faa8b 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/GenerateViewConfigJs-test.js +++ b/packages/react-native-codegen/e2e/__tests__/components/GenerateViewConfigJs-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 508bc6c20f7a0a..7c91b013e45500 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateComponentDescriptorH can generate for 'ArrayPropsNativeComponen Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -32,10 +32,10 @@ exports[`GenerateComponentDescriptorH can generate for 'BooleanPropNativeCompone Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -60,10 +60,10 @@ exports[`GenerateComponentDescriptorH can generate for 'ColorPropNativeComponent Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -88,10 +88,10 @@ exports[`GenerateComponentDescriptorH can generate for 'EdgeInsetsPropNativeComp Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -116,10 +116,10 @@ exports[`GenerateComponentDescriptorH can generate for 'EnumPropNativeComponent. Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -144,10 +144,10 @@ exports[`GenerateComponentDescriptorH can generate for 'EventNestedObjectPropsNa Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -172,10 +172,10 @@ exports[`GenerateComponentDescriptorH can generate for 'EventPropsNativeComponen Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -200,10 +200,10 @@ exports[`GenerateComponentDescriptorH can generate for 'FloatPropsNativeComponen Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -228,10 +228,10 @@ exports[`GenerateComponentDescriptorH can generate for 'ImagePropNativeComponent Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -256,10 +256,10 @@ exports[`GenerateComponentDescriptorH can generate for 'IntegerPropNativeCompone Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -284,10 +284,10 @@ exports[`GenerateComponentDescriptorH can generate for 'InterfaceOnlyNativeCompo Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -312,10 +312,10 @@ exports[`GenerateComponentDescriptorH can generate for 'MultiNativePropNativeCom Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -340,10 +340,10 @@ exports[`GenerateComponentDescriptorH can generate for 'NoPropsNoEventsNativeCom Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -368,10 +368,10 @@ exports[`GenerateComponentDescriptorH can generate for 'ObjectPropsNativeCompone Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -396,10 +396,10 @@ exports[`GenerateComponentDescriptorH can generate for 'PointPropNativeComponent Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -424,10 +424,10 @@ exports[`GenerateComponentDescriptorH can generate for 'StringPropNativeComponen Object { "ComponentDescriptors.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap index 29837dba416cfd..3a6cc0fb294ace 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -3,10 +3,10 @@ exports[`GenerateComponentHObjCpp can generate for 'ArrayPropsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -28,10 +28,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'BooleanPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -53,10 +53,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'ColorPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -78,10 +78,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'EdgeInsetsPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -103,10 +103,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'EnumPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -128,10 +128,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'EventNestedObjectPropsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -153,10 +153,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'EventPropsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -178,10 +178,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'FloatPropsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -203,10 +203,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'ImagePropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -228,10 +228,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'IntegerPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -253,10 +253,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'InterfaceOnlyNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -278,10 +278,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -303,10 +303,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'NoPropsNoEventsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -328,10 +328,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'ObjectPropsNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -353,10 +353,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'PointPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -378,10 +378,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate for 'StringPropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 3f5bf83f6f3a50..07ce71990ed2d3 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateEventEmitterCpp can generate for 'ArrayPropsNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -29,10 +29,10 @@ exports[`GenerateEventEmitterCpp can generate for 'BooleanPropNativeComponent.js Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -54,10 +54,10 @@ exports[`GenerateEventEmitterCpp can generate for 'ColorPropNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -79,10 +79,10 @@ exports[`GenerateEventEmitterCpp can generate for 'EdgeInsetsPropNativeComponent Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -104,10 +104,10 @@ exports[`GenerateEventEmitterCpp can generate for 'EnumPropNativeComponent.js' 1 Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -129,10 +129,10 @@ exports[`GenerateEventEmitterCpp can generate for 'EventNestedObjectPropsNativeC Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -172,10 +172,10 @@ exports[`GenerateEventEmitterCpp can generate for 'EventPropsNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -241,10 +241,10 @@ exports[`GenerateEventEmitterCpp can generate for 'FloatPropsNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -266,10 +266,10 @@ exports[`GenerateEventEmitterCpp can generate for 'ImagePropNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -291,10 +291,10 @@ exports[`GenerateEventEmitterCpp can generate for 'IntegerPropNativeComponent.js Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -316,10 +316,10 @@ exports[`GenerateEventEmitterCpp can generate for 'InterfaceOnlyNativeComponent. Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -347,10 +347,10 @@ exports[`GenerateEventEmitterCpp can generate for 'MultiNativePropNativeComponen Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -372,10 +372,10 @@ exports[`GenerateEventEmitterCpp can generate for 'NoPropsNoEventsNativeComponen Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -397,10 +397,10 @@ exports[`GenerateEventEmitterCpp can generate for 'ObjectPropsNativeComponent.js Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -422,10 +422,10 @@ exports[`GenerateEventEmitterCpp can generate for 'PointPropNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -447,10 +447,10 @@ exports[`GenerateEventEmitterCpp can generate for 'StringPropNativeComponent.js' Object { "EventEmitters.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap index 24ce2461805eed..8ea473f15a6833 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -4,16 +4,17 @@ exports[`GenerateEventEmitterH can generate for 'ArrayPropsNativeComponent.js' 1 Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -30,16 +31,17 @@ exports[`GenerateEventEmitterH can generate for 'BooleanPropNativeComponent.js' Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -56,16 +58,17 @@ exports[`GenerateEventEmitterH can generate for 'ColorPropNativeComponent.js' 1` Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -82,16 +85,17 @@ exports[`GenerateEventEmitterH can generate for 'EdgeInsetsPropNativeComponent.j Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -108,16 +112,17 @@ exports[`GenerateEventEmitterH can generate for 'EnumPropNativeComponent.js' 1`] Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -134,21 +139,22 @@ exports[`GenerateEventEmitterH can generate for 'EventNestedObjectPropsNativeCom Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class EventNestedObjectPropsNativeComponentViewEventEmitter : public ViewEventEmitter { +class JSI_EXPORT EventNestedObjectPropsNativeComponentViewEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -179,21 +185,22 @@ exports[`GenerateEventEmitterH can generate for 'EventPropsNativeComponent.js' 1 Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class EventPropsNativeComponentViewEventEmitter : public ViewEventEmitter { +class JSI_EXPORT EventPropsNativeComponentViewEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -259,16 +266,17 @@ exports[`GenerateEventEmitterH can generate for 'FloatPropsNativeComponent.js' 1 Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -285,16 +293,17 @@ exports[`GenerateEventEmitterH can generate for 'ImagePropNativeComponent.js' 1` Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -311,16 +320,17 @@ exports[`GenerateEventEmitterH can generate for 'IntegerPropNativeComponent.js' Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -337,21 +347,22 @@ exports[`GenerateEventEmitterH can generate for 'InterfaceOnlyNativeComponent.js Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class InterfaceOnlyNativeComponentViewEventEmitter : public ViewEventEmitter { +class JSI_EXPORT InterfaceOnlyNativeComponentViewEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -372,16 +383,17 @@ exports[`GenerateEventEmitterH can generate for 'MultiNativePropNativeComponent. Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -398,16 +410,17 @@ exports[`GenerateEventEmitterH can generate for 'NoPropsNoEventsNativeComponent. Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -424,16 +437,17 @@ exports[`GenerateEventEmitterH can generate for 'ObjectPropsNativeComponent.js' Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -450,16 +464,17 @@ exports[`GenerateEventEmitterH can generate for 'PointPropNativeComponent.js' 1` Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -476,16 +491,17 @@ exports[`GenerateEventEmitterH can generate for 'StringPropNativeComponent.js' 1 Object { "EventEmitters.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index 2c646d88817432..63443148619e08 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GeneratePropsCpp can generate for 'ArrayPropsNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -46,10 +46,10 @@ exports[`GeneratePropsCpp can generate for 'BooleanPropNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -80,10 +80,10 @@ exports[`GeneratePropsCpp can generate for 'ColorPropNativeComponent.js' 1`] = ` Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -113,10 +113,10 @@ exports[`GeneratePropsCpp can generate for 'EdgeInsetsPropNativeComponent.js' 1` Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -146,10 +146,10 @@ exports[`GeneratePropsCpp can generate for 'EnumPropNativeComponent.js' 1`] = ` Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -180,10 +180,10 @@ exports[`GeneratePropsCpp can generate for 'EventNestedObjectPropsNativeComponen Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -213,10 +213,10 @@ exports[`GeneratePropsCpp can generate for 'EventPropsNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -246,10 +246,10 @@ exports[`GeneratePropsCpp can generate for 'FloatPropsNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -285,10 +285,10 @@ exports[`GeneratePropsCpp can generate for 'ImagePropNativeComponent.js' 1`] = ` Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -319,10 +319,10 @@ exports[`GeneratePropsCpp can generate for 'IntegerPropNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -354,10 +354,10 @@ exports[`GeneratePropsCpp can generate for 'InterfaceOnlyNativeComponent.js' 1`] Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -387,10 +387,10 @@ exports[`GeneratePropsCpp can generate for 'MultiNativePropNativeComponent.js' 1 Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -424,10 +424,10 @@ exports[`GeneratePropsCpp can generate for 'NoPropsNoEventsNativeComponent.js' 1 Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -457,10 +457,10 @@ exports[`GeneratePropsCpp can generate for 'ObjectPropsNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -493,10 +493,10 @@ exports[`GeneratePropsCpp can generate for 'PointPropNativeComponent.js' 1`] = ` Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -526,10 +526,10 @@ exports[`GeneratePropsCpp can generate for 'StringPropNativeComponent.js' 1`] = Object { "Props.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index fb6ce03da6ae8f..ba79b2cf4149fb 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -4,16 +4,17 @@ exports[`GeneratePropsH can generate for 'ArrayPropsNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once #include +#include #include #include #include @@ -84,11 +85,11 @@ struct ArrayPropsNativeComponentViewObjectStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentViewObjectStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto prop = map.find(\\"prop\\"); - if (prop != map.end()) { - fromRawValue(context, prop->second, result.prop); + auto tmp_prop = map.find(\\"prop\\"); + if (tmp_prop != map.end()) { + fromRawValue(context, tmp_prop->second, result.prop); } } @@ -105,7 +106,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu } } -class ArrayPropsNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT ArrayPropsNativeComponentViewProps final : public ViewProps { public: ArrayPropsNativeComponentViewProps() = default; ArrayPropsNativeComponentViewProps(const PropsParserContext& context, const ArrayPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -133,22 +134,23 @@ exports[`GeneratePropsH can generate for 'BooleanPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class BooleanPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT BooleanPropNativeComponentViewProps final : public ViewProps { public: BooleanPropNativeComponentViewProps() = default; BooleanPropNativeComponentViewProps(const PropsParserContext& context, const BooleanPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -169,15 +171,16 @@ exports[`GeneratePropsH can generate for 'ColorPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -185,7 +188,7 @@ Object { namespace facebook { namespace react { -class ColorPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT ColorPropNativeComponentViewProps final : public ViewProps { public: ColorPropNativeComponentViewProps() = default; ColorPropNativeComponentViewProps(const PropsParserContext& context, const ColorPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -205,22 +208,23 @@ exports[`GeneratePropsH can generate for 'EdgeInsetsPropNativeComponent.js' 1`] Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class EdgeInsetsPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT EdgeInsetsPropNativeComponentViewProps final : public ViewProps { public: EdgeInsetsPropNativeComponentViewProps() = default; EdgeInsetsPropNativeComponentViewProps(const PropsParserContext& context, const EdgeInsetsPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -240,15 +244,16 @@ exports[`GeneratePropsH can generate for 'EnumPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include @@ -303,7 +308,7 @@ static inline std::string toString(const EnumPropNativeComponentViewIntervals &v } } -class EnumPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT EnumPropNativeComponentViewProps final : public ViewProps { public: EnumPropNativeComponentViewProps() = default; EnumPropNativeComponentViewProps(const PropsParserContext& context, const EnumPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -324,22 +329,23 @@ exports[`GeneratePropsH can generate for 'EventNestedObjectPropsNativeComponent. Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT EventNestedObjectPropsNativeComponentViewProps final : public ViewProps { public: EventNestedObjectPropsNativeComponentViewProps() = default; EventNestedObjectPropsNativeComponentViewProps(const PropsParserContext& context, const EventNestedObjectPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -359,22 +365,23 @@ exports[`GeneratePropsH can generate for 'EventPropsNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class EventPropsNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT EventPropsNativeComponentViewProps final : public ViewProps { public: EventPropsNativeComponentViewProps() = default; EventPropsNativeComponentViewProps(const PropsParserContext& context, const EventPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -394,22 +401,23 @@ exports[`GeneratePropsH can generate for 'FloatPropsNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class FloatPropsNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT FloatPropsNativeComponentViewProps final : public ViewProps { public: FloatPropsNativeComponentViewProps() = default; FloatPropsNativeComponentViewProps(const PropsParserContext& context, const FloatPropsNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -435,15 +443,16 @@ exports[`GeneratePropsH can generate for 'ImagePropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -451,7 +460,7 @@ Object { namespace facebook { namespace react { -class ImagePropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT ImagePropNativeComponentViewProps final : public ViewProps { public: ImagePropNativeComponentViewProps() = default; ImagePropNativeComponentViewProps(const PropsParserContext& context, const ImagePropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -471,22 +480,23 @@ exports[`GeneratePropsH can generate for 'IntegerPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class IntegerPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT IntegerPropNativeComponentViewProps final : public ViewProps { public: IntegerPropNativeComponentViewProps() = default; IntegerPropNativeComponentViewProps(const PropsParserContext& context, const IntegerPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -508,22 +518,23 @@ exports[`GeneratePropsH can generate for 'InterfaceOnlyNativeComponent.js' 1`] = Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class InterfaceOnlyNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT InterfaceOnlyNativeComponentViewProps final : public ViewProps { public: InterfaceOnlyNativeComponentViewProps() = default; InterfaceOnlyNativeComponentViewProps(const PropsParserContext& context, const InterfaceOnlyNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -543,15 +554,16 @@ exports[`GeneratePropsH can generate for 'MultiNativePropNativeComponent.js' 1`] Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -561,7 +573,7 @@ Object { namespace facebook { namespace react { -class MultiNativePropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT MultiNativePropNativeComponentViewProps final : public ViewProps { public: MultiNativePropNativeComponentViewProps() = default; MultiNativePropNativeComponentViewProps(const PropsParserContext& context, const MultiNativePropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -584,22 +596,23 @@ exports[`GeneratePropsH can generate for 'NoPropsNoEventsNativeComponent.js' 1`] Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class NoPropsNoEventsNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT NoPropsNoEventsNativeComponentViewProps final : public ViewProps { public: NoPropsNoEventsNativeComponentViewProps() = default; NoPropsNoEventsNativeComponentViewProps(const PropsParserContext& context, const NoPropsNoEventsNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -619,15 +632,16 @@ exports[`GeneratePropsH can generate for 'ObjectPropsNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -687,31 +701,31 @@ struct ObjectPropsNativeComponentObjectPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsNativeComponentObjectPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } - auto booleanProp = map.find(\\"booleanProp\\"); - if (booleanProp != map.end()) { - fromRawValue(context, booleanProp->second, result.booleanProp); + auto tmp_booleanProp = map.find(\\"booleanProp\\"); + if (tmp_booleanProp != map.end()) { + fromRawValue(context, tmp_booleanProp->second, result.booleanProp); } - auto floatProp = map.find(\\"floatProp\\"); - if (floatProp != map.end()) { - fromRawValue(context, floatProp->second, result.floatProp); + auto tmp_floatProp = map.find(\\"floatProp\\"); + if (tmp_floatProp != map.end()) { + fromRawValue(context, tmp_floatProp->second, result.floatProp); } - auto intProp = map.find(\\"intProp\\"); - if (intProp != map.end()) { - fromRawValue(context, intProp->second, result.intProp); + auto tmp_intProp = map.find(\\"intProp\\"); + if (tmp_intProp != map.end()) { + fromRawValue(context, tmp_intProp->second, result.intProp); } - auto stringEnumProp = map.find(\\"stringEnumProp\\"); - if (stringEnumProp != map.end()) { - fromRawValue(context, stringEnumProp->second, result.stringEnumProp); + auto tmp_stringEnumProp = map.find(\\"stringEnumProp\\"); + if (tmp_stringEnumProp != map.end()) { + fromRawValue(context, tmp_stringEnumProp->second, result.stringEnumProp); } - auto intEnumProp = map.find(\\"intEnumProp\\"); - if (intEnumProp != map.end()) { - fromRawValue(context, intEnumProp->second, result.intEnumProp); + auto tmp_intEnumProp = map.find(\\"intEnumProp\\"); + if (tmp_intEnumProp != map.end()) { + fromRawValue(context, tmp_intEnumProp->second, result.intEnumProp); } } @@ -724,11 +738,11 @@ struct ObjectPropsNativeComponentObjectArrayPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsNativeComponentObjectArrayPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto array = map.find(\\"array\\"); - if (array != map.end()) { - fromRawValue(context, array->second, result.array); + auto tmp_array = map.find(\\"array\\"); + if (tmp_array != map.end()) { + fromRawValue(context, tmp_array->second, result.array); } } @@ -743,26 +757,26 @@ struct ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto image = map.find(\\"image\\"); - if (image != map.end()) { - fromRawValue(context, image->second, result.image); + auto tmp_image = map.find(\\"image\\"); + if (tmp_image != map.end()) { + fromRawValue(context, tmp_image->second, result.image); } - auto color = map.find(\\"color\\"); - if (color != map.end()) { - fromRawValue(context, color->second, result.color); + auto tmp_color = map.find(\\"color\\"); + if (tmp_color != map.end()) { + fromRawValue(context, tmp_color->second, result.color); } - auto point = map.find(\\"point\\"); - if (point != map.end()) { - fromRawValue(context, point->second, result.point); + auto tmp_point = map.find(\\"point\\"); + if (tmp_point != map.end()) { + fromRawValue(context, tmp_point->second, result.point); } } static inline std::string toString(const ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct &value) { return \\"[Object ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct]\\"; } -class ObjectPropsNativeComponentProps final : public ViewProps { +class JSI_EXPORT ObjectPropsNativeComponentProps final : public ViewProps { public: ObjectPropsNativeComponentProps() = default; ObjectPropsNativeComponentProps(const PropsParserContext& context, const ObjectPropsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -784,15 +798,16 @@ exports[`GeneratePropsH can generate for 'PointPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -800,7 +815,7 @@ Object { namespace facebook { namespace react { -class PointPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT PointPropNativeComponentViewProps final : public ViewProps { public: PointPropNativeComponentViewProps() = default; PointPropNativeComponentViewProps(const PropsParserContext& context, const PointPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); @@ -820,22 +835,23 @@ exports[`GeneratePropsH can generate for 'StringPropNativeComponent.js' 1`] = ` Object { "Props.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class StringPropNativeComponentViewProps final : public ViewProps { +class JSI_EXPORT StringPropNativeComponentViewProps final : public ViewProps { public: StringPropNativeComponentViewProps() = default; StringPropNativeComponentViewProps(const PropsParserContext& context, const StringPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 6162300005bc61..6e97f60966f91d 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -3,10 +3,10 @@ exports[`GeneratePropsJavaDelegate can generate for 'ArrayPropsNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/ArrayPropsNativeComponentViewManagerDelegate.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -65,10 +65,10 @@ public class ArrayPropsNativeComponentViewManagerDelegate { exports[`GeneratePropsJavaInterface can generate for 'BooleanPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/BooleanPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -59,10 +59,10 @@ public interface BooleanPropNativeComponentViewManagerInterface exports[`GeneratePropsJavaInterface can generate for 'ColorPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/ColorPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -82,10 +82,10 @@ public interface ColorPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'EdgeInsetsPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/EdgeInsetsPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -104,10 +104,10 @@ public interface EdgeInsetsPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'EventNestedObjectPropsNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/EventNestedObjectPropsNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -150,10 +150,10 @@ public interface EventNestedObjectPropsNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'FloatPropsNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/FloatPropsNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -201,10 +201,10 @@ public interface FloatPropsNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'ImagePropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/ImagePropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -225,10 +225,10 @@ public interface ImagePropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'IntegerPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/IntegerPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -249,10 +249,10 @@ public interface IntegerPropNativeComponentViewManagerInterface exports[`GeneratePropsJavaInterface can generate for 'InterfaceOnlyNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/InterfaceOnlyNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -272,10 +272,10 @@ public interface InterfaceOnlyNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'PointPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/PointPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -371,10 +371,10 @@ public interface PointPropNativeComponentViewManagerInterface { exports[`GeneratePropsJavaInterface can generate for 'StringPropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/StringPropNativeComponentViewManagerInterface.java": "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap index abde8a19e92e38..a37b7ccaf3772d 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateShadowNodeCpp can generate for 'ArrayPropsNativeComponent.js' 1 Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -29,10 +29,10 @@ exports[`GenerateShadowNodeCpp can generate for 'BooleanPropNativeComponent.js' Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -54,10 +54,10 @@ exports[`GenerateShadowNodeCpp can generate for 'ColorPropNativeComponent.js' 1` Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -79,10 +79,10 @@ exports[`GenerateShadowNodeCpp can generate for 'EdgeInsetsPropNativeComponent.j Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -104,10 +104,10 @@ exports[`GenerateShadowNodeCpp can generate for 'EnumPropNativeComponent.js' 1`] Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -129,10 +129,10 @@ exports[`GenerateShadowNodeCpp can generate for 'EventNestedObjectPropsNativeCom Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -154,10 +154,10 @@ exports[`GenerateShadowNodeCpp can generate for 'EventPropsNativeComponent.js' 1 Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -179,10 +179,10 @@ exports[`GenerateShadowNodeCpp can generate for 'FloatPropsNativeComponent.js' 1 Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -204,10 +204,10 @@ exports[`GenerateShadowNodeCpp can generate for 'ImagePropNativeComponent.js' 1` Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -229,10 +229,10 @@ exports[`GenerateShadowNodeCpp can generate for 'IntegerPropNativeComponent.js' Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -254,10 +254,10 @@ exports[`GenerateShadowNodeCpp can generate for 'InterfaceOnlyNativeComponent.js Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -279,10 +279,10 @@ exports[`GenerateShadowNodeCpp can generate for 'MultiNativePropNativeComponent. Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -304,10 +304,10 @@ exports[`GenerateShadowNodeCpp can generate for 'NoPropsNoEventsNativeComponent. Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -329,10 +329,10 @@ exports[`GenerateShadowNodeCpp can generate for 'ObjectPropsNativeComponent.js' Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -354,10 +354,10 @@ exports[`GenerateShadowNodeCpp can generate for 'PointPropNativeComponent.js' 1` Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -379,10 +379,10 @@ exports[`GenerateShadowNodeCpp can generate for 'StringPropNativeComponent.js' 1 Object { "ShadowNodes.cpp": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap index 3a31acb7f0913b..84724fbf4bd807 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateShadowNodeH can generate for 'ArrayPropsNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -16,11 +16,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char ArrayPropsNativeComponentViewComponentName[]; +JSI_EXPORT extern const char ArrayPropsNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -39,10 +40,10 @@ exports[`GenerateShadowNodeH can generate for 'BooleanPropNativeComponent.js' 1` Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -51,11 +52,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char BooleanPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char BooleanPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -74,10 +76,10 @@ exports[`GenerateShadowNodeH can generate for 'ColorPropNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -86,11 +88,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char ColorPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char ColorPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -109,10 +112,10 @@ exports[`GenerateShadowNodeH can generate for 'EdgeInsetsPropNativeComponent.js' Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -121,11 +124,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char EdgeInsetsPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char EdgeInsetsPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -144,10 +148,10 @@ exports[`GenerateShadowNodeH can generate for 'EnumPropNativeComponent.js' 1`] = Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -156,11 +160,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char EnumPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char EnumPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -179,10 +184,10 @@ exports[`GenerateShadowNodeH can generate for 'EventNestedObjectPropsNativeCompo Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -192,11 +197,12 @@ Object { #include #include #include +#include namespace facebook { namespace react { -extern const char EventNestedObjectPropsNativeComponentViewComponentName[]; +JSI_EXPORT extern const char EventNestedObjectPropsNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -216,10 +222,10 @@ exports[`GenerateShadowNodeH can generate for 'EventPropsNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -229,11 +235,12 @@ Object { #include #include #include +#include namespace facebook { namespace react { -extern const char EventPropsNativeComponentViewComponentName[]; +JSI_EXPORT extern const char EventPropsNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -253,10 +260,10 @@ exports[`GenerateShadowNodeH can generate for 'FloatPropsNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -265,11 +272,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char FloatPropsNativeComponentViewComponentName[]; +JSI_EXPORT extern const char FloatPropsNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -288,10 +296,10 @@ exports[`GenerateShadowNodeH can generate for 'ImagePropNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -300,11 +308,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char ImagePropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char ImagePropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -323,10 +332,10 @@ exports[`GenerateShadowNodeH can generate for 'IntegerPropNativeComponent.js' 1` Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -335,11 +344,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char IntegerPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char IntegerPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -358,10 +368,10 @@ exports[`GenerateShadowNodeH can generate for 'InterfaceOnlyNativeComponent.js' Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -370,6 +380,7 @@ Object { #include #include +#include namespace facebook { namespace react { @@ -386,10 +397,10 @@ exports[`GenerateShadowNodeH can generate for 'MultiNativePropNativeComponent.js Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -398,11 +409,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char MultiNativePropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char MultiNativePropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -421,10 +433,10 @@ exports[`GenerateShadowNodeH can generate for 'NoPropsNoEventsNativeComponent.js Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -433,11 +445,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char NoPropsNoEventsNativeComponentViewComponentName[]; +JSI_EXPORT extern const char NoPropsNoEventsNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -456,10 +469,10 @@ exports[`GenerateShadowNodeH can generate for 'ObjectPropsNativeComponent.js' 1` Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -468,11 +481,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char ObjectPropsNativeComponentComponentName[]; +JSI_EXPORT extern const char ObjectPropsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -491,10 +505,10 @@ exports[`GenerateShadowNodeH can generate for 'PointPropNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -503,11 +517,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char PointPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char PointPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. @@ -526,10 +541,10 @@ exports[`GenerateShadowNodeH can generate for 'StringPropNativeComponent.js' 1`] Object { "ShadowNodes.h": " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -538,11 +553,12 @@ Object { #include #include +#include namespace facebook { namespace react { -extern const char StringPropNativeComponentViewComponentName[]; +JSI_EXPORT extern const char StringPropNativeComponentViewComponentName[]; /* * \`ShadowNode\` for component. diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap index 71132f212a3f80..12fa79b3d4f46b 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateViewConfigJs can generate for 'ArrayPropsNativeComponent.js' 1` Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -20,7 +20,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ArrayPropsNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ArrayPropsNativeComponentView', validAttributes: { @@ -38,7 +39,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ sizes: true, object: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -47,10 +50,10 @@ exports[`GenerateViewConfigJs can generate for 'BooleanPropNativeComponent.js' 1 Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -63,14 +66,17 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'BooleanPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'BooleanPropNativeComponentView', validAttributes: { disabled: true, disabledNullable: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -79,10 +85,10 @@ exports[`GenerateViewConfigJs can generate for 'ColorPropNativeComponent.js' 1`] Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -95,7 +101,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ColorPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ColorPropNativeComponentView', validAttributes: { @@ -103,7 +110,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ process: require('react-native/Libraries/StyleSheet/processColor'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -112,10 +121,10 @@ exports[`GenerateViewConfigJs can generate for 'EdgeInsetsPropNativeComponent.js Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -128,10 +137,13 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'EdgeInsetsPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EdgeInsetsPropNativeComponentView', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -140,10 +152,10 @@ exports[`GenerateViewConfigJs can generate for 'EnumPropNativeComponent.js' 1`] Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -156,14 +168,17 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'EnumPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EnumPropNativeComponentView', validAttributes: { alignment: true, intervals: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -172,10 +187,10 @@ exports[`GenerateViewConfigJs can generate for 'EventNestedObjectPropsNativeComp Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -185,10 +200,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'EventNestedObjectPropsNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EventNestedObjectPropsNativeComponentView', bubblingEventTypes: { @@ -202,9 +219,14 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ validAttributes: { disabled: true, - onChange: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -213,10 +235,10 @@ exports[`GenerateViewConfigJs can generate for 'EventPropsNativeComponent.js' 1` Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -226,10 +248,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'EventPropsNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EventPropsNativeComponentView', bubblingEventTypes: { @@ -240,13 +264,6 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ }, }, - topChange: { - phasedRegistrationNames: { - captured: 'onChangeCapture', - bubbled: 'onChange', - }, - }, - topEnd: { phasedRegistrationNames: { captured: 'onEndCapture', @@ -260,13 +277,6 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ bubbled: 'onEventBubblingWithPaperName', }, }, - - topEventBubblingWithPaperName: { - phasedRegistrationNames: { - captured: 'onEventBubblingWithPaperNameCapture', - bubbled: 'onEventBubblingWithPaperName', - }, - }, }, directEventTypes: { @@ -278,29 +288,26 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ registrationName: 'onEventDirectWithPaperName', }, - topEventDirectWithPaperName: { - registrationName: 'onEventDirectWithPaperName', - }, - paperBubblingName: { registrationName: 'onOrientationChange', }, - - topOrientationChange: { - registrationName: 'onOrientationChange', - }, }, validAttributes: { disabled: true, - onChange: true, - onEventDirect: true, - onEventDirectWithPaperName: true, - onOrientationChange: true, - onEnd: true, - onEventBubblingWithPaperName: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + onEventDirect: true, + onEventDirectWithPaperName: true, + onOrientationChange: true, + onEnd: true, + onEventBubblingWithPaperName: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -309,10 +316,10 @@ exports[`GenerateViewConfigJs can generate for 'FloatPropsNativeComponent.js' 1` Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -325,7 +332,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'FloatPropsNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'FloatPropsNativeComponentView', validAttributes: { @@ -337,7 +345,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ blurRadius6: true, blurRadiusNullable: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -346,10 +356,10 @@ exports[`GenerateViewConfigJs can generate for 'ImagePropNativeComponent.js' 1`] Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -362,7 +372,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ImagePropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ImagePropNativeComponentView', validAttributes: { @@ -370,7 +381,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ process: require('react-native/Libraries/Image/resolveAssetSource'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -379,10 +392,10 @@ exports[`GenerateViewConfigJs can generate for 'IntegerPropNativeComponent.js' 1 Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -395,7 +408,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'IntegerPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'IntegerPropNativeComponentView', validAttributes: { @@ -403,7 +417,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ progress2: true, progress3: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -412,10 +428,10 @@ exports[`GenerateViewConfigJs can generate for 'InterfaceOnlyNativeComponent.js' Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -425,10 +441,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'RCTInterfaceOnlyComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'RCTInterfaceOnlyComponent', bubblingEventTypes: { @@ -442,9 +460,14 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ validAttributes: { title: true, - onChange: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -453,10 +476,10 @@ exports[`GenerateViewConfigJs can generate for 'MultiNativePropNativeComponent.j Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -469,7 +492,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'MultiNativePropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'MultiNativePropNativeComponentView', validAttributes: { @@ -489,7 +513,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ diff: require('react-native/Libraries/Utilities/differ/pointsDiffer'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -498,10 +524,10 @@ exports[`GenerateViewConfigJs can generate for 'NoPropsNoEventsNativeComponent.j Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -514,10 +540,13 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'NoPropsNoEventsNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'NoPropsNoEventsNativeComponentView', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -526,10 +555,10 @@ exports[`GenerateViewConfigJs can generate for 'ObjectPropsNativeComponent.js' 1 Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -542,7 +571,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ObjectPropsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ObjectPropsNativeComponent', validAttributes: { @@ -550,7 +580,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ objectArrayProp: true, objectPrimitiveRequiredProp: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -559,10 +591,10 @@ exports[`GenerateViewConfigJs can generate for 'PointPropNativeComponent.js' 1`] Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -575,7 +607,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'PointPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'PointPropNativeComponentView', validAttributes: { @@ -583,7 +616,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ diff: require('react-native/Libraries/Utilities/differ/pointsDiffer'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -592,10 +627,10 @@ exports[`GenerateViewConfigJs can generate for 'StringPropNativeComponent.js' 1` Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -608,14 +643,17 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'StringPropNativeComponentView'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'StringPropNativeComponentView', validAttributes: { placeholder: true, defaultValue: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; diff --git a/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js b/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js index 62f923d9581d23..69ba5f7205ee84 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js +++ b/packages/react-native-codegen/e2e/__tests__/modules/GenerateModuleObjCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap index 72435804ab9543..13d1139ab9c54b 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap @@ -2,10 +2,10 @@ exports[`GenerateModuleObjCpp can generate a header file NativeModule specs 1`] = ` "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -25,7 +25,7 @@ exports[`GenerateModuleObjCpp can generate a header file NativeModule specs 1`] #import #import #import -#import +#import #import @@ -302,8 +302,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -331,8 +331,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -360,8 +360,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -389,9 +389,9 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; + std::optional D; id _Nullable A; - folly::Optional E; + std::optional E; NSString *F; }; @@ -580,7 +580,7 @@ namespace JS { RCTRequired> const1; RCTRequired> const2; RCTRequired> const3; - folly::Optional>> id_; + std::optional>> id_; }; /** Initialize with a set of values */ @@ -637,7 +637,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleNullable { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -670,8 +670,8 @@ namespace JS { struct Builder { struct Input { - RCTRequired> const1; - RCTRequired> const2; + RCTRequired> const1; + RCTRequired> const2; RCTRequired const3; }; @@ -729,7 +729,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleNullableAndOptional { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -762,8 +762,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional const1; - folly::Optional const2; + std::optional const1; + std::optional const2; NSString *const3; }; @@ -821,7 +821,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleOptional { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -854,8 +854,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional const1; - folly::Optional const2; + std::optional const1; + std::optional const2; NSString *const3; }; @@ -1018,9 +1018,9 @@ inline JS::NativeObjectTurboModule::Constants::Builder::Builder(Constants i) : _ inline JS::NativeOptionalObjectTurboModule::ConstantsEEE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? @((double)E.value()) : nil; + d[@\\"E\\"] = E.has_value() ? @((double)E.value()) : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -1031,9 +1031,9 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsEEE::Builder::Builder(Const inline JS::NativeOptionalObjectTurboModule::ConstantsEE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -1044,9 +1044,9 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsEE::Builder::Builder(Consta inline JS::NativeOptionalObjectTurboModule::ConstantsE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -1057,11 +1057,11 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsE::Builder::Builder(Constan inline JS::NativeOptionalObjectTurboModule::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto A = i.A; d[@\\"A\\"] = A; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -1111,13 +1111,13 @@ inline JS::NativeSampleTurboModuleArrays::Constants::Builder::Builder(const Inpu auto const3 = i.const3.get(); d[@\\"const3\\"] = RCTConvertVecToArray(const3, ^id(NSString * el_) { return el_; }); auto id_ = i.id_; - d[@\\"id\\"] = RCTConvertOptionalVecToArray(id_, ^id(folly::Optional el_) { return el_.hasValue() ? el_.value().buildUnsafeRawValue() : nil; }); + d[@\\"id\\"] = RCTConvertOptionalVecToArray(id_, ^id(std::optional el_) { return el_.has_value() ? el_.value().buildUnsafeRawValue() : nil; }); return d; }) {} inline JS::NativeSampleTurboModuleArrays::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleNullable::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleNullable::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -1130,9 +1130,9 @@ inline NSString *JS::NativeSampleTurboModuleNullable::Animal::name() const inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1.get(); - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2.get(); - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3.get(); d[@\\"const3\\"] = const3; return d; @@ -1140,7 +1140,7 @@ inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(const In inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleNullableAndOptional::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleNullableAndOptional::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -1153,9 +1153,9 @@ inline NSString *JS::NativeSampleTurboModuleNullableAndOptional::Animal::name() inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1; - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2; - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3; d[@\\"const3\\"] = const3; return d; @@ -1163,7 +1163,7 @@ inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Build inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleOptional::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleOptional::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -1176,9 +1176,9 @@ inline NSString *JS::NativeSampleTurboModuleOptional::Animal::name() const inline JS::NativeSampleTurboModuleOptional::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1; - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2; - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3; d[@\\"const3\\"] = const3; return d; @@ -1192,10 +1192,10 @@ inline JS::NativeSampleTurboModuleOptional::Constants::Builder::Builder(Constant exports[`GenerateModuleObjCpp can generate a header file NativeModule specs with assume nonnull enabled 1`] = ` "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -1215,7 +1215,7 @@ exports[`GenerateModuleObjCpp can generate a header file NativeModule specs with #import #import #import -#import +#import #import @@ -1494,8 +1494,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -1523,8 +1523,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -1552,8 +1552,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; - folly::Optional E; + std::optional D; + std::optional E; NSString *F; }; @@ -1581,9 +1581,9 @@ namespace JS { struct Builder { struct Input { - folly::Optional D; + std::optional D; id _Nullable A; - folly::Optional E; + std::optional E; NSString *F; }; @@ -1772,7 +1772,7 @@ namespace JS { RCTRequired> const1; RCTRequired> const2; RCTRequired> const3; - folly::Optional>> id_; + std::optional>> id_; }; /** Initialize with a set of values */ @@ -1829,7 +1829,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleNullable { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -1862,8 +1862,8 @@ namespace JS { struct Builder { struct Input { - RCTRequired> const1; - RCTRequired> const2; + RCTRequired> const1; + RCTRequired> const2; RCTRequired const3; }; @@ -1921,7 +1921,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleNullableAndOptional { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -1954,8 +1954,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional const1; - folly::Optional const2; + std::optional const1; + std::optional const2; NSString *const3; }; @@ -2013,7 +2013,7 @@ namespace facebook { namespace JS { namespace NativeSampleTurboModuleOptional { struct SpecGetObjectShapeArg { - folly::Optional prop() const; + std::optional prop() const; SpecGetObjectShapeArg(NSDictionary *const v) : _v(v) {} private: @@ -2046,8 +2046,8 @@ namespace JS { struct Builder { struct Input { - folly::Optional const1; - folly::Optional const2; + std::optional const1; + std::optional const2; NSString *const3; }; @@ -2210,9 +2210,9 @@ inline JS::NativeObjectTurboModule::Constants::Builder::Builder(Constants i) : _ inline JS::NativeOptionalObjectTurboModule::ConstantsEEE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? @((double)E.value()) : nil; + d[@\\"E\\"] = E.has_value() ? @((double)E.value()) : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -2223,9 +2223,9 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsEEE::Builder::Builder(Const inline JS::NativeOptionalObjectTurboModule::ConstantsEE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -2236,9 +2236,9 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsEE::Builder::Builder(Consta inline JS::NativeOptionalObjectTurboModule::ConstantsE::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -2249,11 +2249,11 @@ inline JS::NativeOptionalObjectTurboModule::ConstantsE::Builder::Builder(Constan inline JS::NativeOptionalObjectTurboModule::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto D = i.D; - d[@\\"D\\"] = D.hasValue() ? @((BOOL)D.value()) : nil; + d[@\\"D\\"] = D.has_value() ? @((BOOL)D.value()) : nil; auto A = i.A; d[@\\"A\\"] = A; auto E = i.E; - d[@\\"E\\"] = E.hasValue() ? E.value().buildUnsafeRawValue() : nil; + d[@\\"E\\"] = E.has_value() ? E.value().buildUnsafeRawValue() : nil; auto F = i.F; d[@\\"F\\"] = F; return d; @@ -2303,13 +2303,13 @@ inline JS::NativeSampleTurboModuleArrays::Constants::Builder::Builder(const Inpu auto const3 = i.const3.get(); d[@\\"const3\\"] = RCTConvertVecToArray(const3, ^id(NSString * el_) { return el_; }); auto id_ = i.id_; - d[@\\"id\\"] = RCTConvertOptionalVecToArray(id_, ^id(folly::Optional el_) { return el_.hasValue() ? el_.value().buildUnsafeRawValue() : nil; }); + d[@\\"id\\"] = RCTConvertOptionalVecToArray(id_, ^id(std::optional el_) { return el_.has_value() ? el_.value().buildUnsafeRawValue() : nil; }); return d; }) {} inline JS::NativeSampleTurboModuleArrays::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleNullable::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleNullable::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -2322,9 +2322,9 @@ inline NSString *JS::NativeSampleTurboModuleNullable::Animal::name() const inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1.get(); - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2.get(); - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3.get(); d[@\\"const3\\"] = const3; return d; @@ -2332,7 +2332,7 @@ inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(const In inline JS::NativeSampleTurboModuleNullable::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleNullableAndOptional::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleNullableAndOptional::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -2345,9 +2345,9 @@ inline NSString *JS::NativeSampleTurboModuleNullableAndOptional::Animal::name() inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1; - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2; - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3; d[@\\"const3\\"] = const3; return d; @@ -2355,7 +2355,7 @@ inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Build inline JS::NativeSampleTurboModuleNullableAndOptional::Constants::Builder::Builder(Constants i) : _factory(^{ return i.unsafeRawValue(); }) {} -inline folly::Optional JS::NativeSampleTurboModuleOptional::SpecGetObjectShapeArg::prop() const +inline std::optional JS::NativeSampleTurboModuleOptional::SpecGetObjectShapeArg::prop() const { id const p = _v[@\\"prop\\"]; return RCTBridgingToOptionalDouble(p); @@ -2368,9 +2368,9 @@ inline NSString *JS::NativeSampleTurboModuleOptional::Animal::name() const inline JS::NativeSampleTurboModuleOptional::Constants::Builder::Builder(const Input i) : _factory(^{ NSMutableDictionary *d = [NSMutableDictionary new]; auto const1 = i.const1; - d[@\\"const1\\"] = const1.hasValue() ? @((BOOL)const1.value()) : nil; + d[@\\"const1\\"] = const1.has_value() ? @((BOOL)const1.value()) : nil; auto const2 = i.const2; - d[@\\"const2\\"] = const2.hasValue() ? @((double)const2.value()) : nil; + d[@\\"const2\\"] = const2.has_value() ? @((double)const2.value()) : nil; auto const3 = i.const3; d[@\\"const3\\"] = const3; return d; @@ -2385,10 +2385,10 @@ NS_ASSUME_NONNULL_END exports[`GenerateModuleObjCpp can generate an implementation file NativeModule specs 1`] = ` "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * diff --git a/packages/react-native-codegen/package.json b/packages/react-native-codegen/package.json index 140d14281ffe94..bcc2c3922db903 100644 --- a/packages/react-native-codegen/package.json +++ b/packages/react-native-codegen/package.json @@ -1,6 +1,6 @@ { "name": "react-native-codegen", - "version": "0.0.11", + "version": "0.70.3", "description": "⚛️ Code generation tools for React Native", "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen", "repository": { @@ -11,15 +11,16 @@ "scripts": { "build": "yarn clean && node scripts/build.js --verbose", "clean": "rm -rf lib", - "prepublish": "yarn run build" + "prepare": "yarn run build" }, "license": "MIT", "files": [ "lib" ], "dependencies": { + "@babel/parser": "^7.14.0", "flow-parser": "^0.121.0", - "jscodeshift": "^0.11.0", + "jscodeshift": "^0.13.1", "nullthrows": "^1.1.1" }, "devDependencies": { @@ -35,7 +36,7 @@ "chalk": "^4.0.0", "glob": "^7.1.1", "invariant": "^2.2.4", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "mkdirp": "^0.5.1", "prettier": "^2.4.1" } diff --git a/packages/react-native-codegen/scripts/buck-oss/combine_js_to_schema.sh b/packages/react-native-codegen/scripts/buck-oss/combine_js_to_schema.sh index 85bfb85a981528..6c837aa334d6a9 100755 --- a/packages/react-native-codegen/scripts/buck-oss/combine_js_to_schema.sh +++ b/packages/react-native-codegen/scripts/buck-oss/combine_js_to_schema.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/packages/react-native-codegen/scripts/buck-oss/generate-all.sh b/packages/react-native-codegen/scripts/buck-oss/generate-all.sh index a60d6f40fe86c2..9391bf80f25488 100755 --- a/packages/react-native-codegen/scripts/buck-oss/generate-all.sh +++ b/packages/react-native-codegen/scripts/buck-oss/generate-all.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. diff --git a/packages/react-native-codegen/scripts/build.js b/packages/react-native-codegen/scripts/build.js index 5dc4d208e6e6b9..a8a34a61fbaff9 100644 --- a/packages/react-native-codegen/scripts/build.js +++ b/packages/react-native-codegen/scripts/build.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index b5913f9f1d6a1e..5822ffb7cf3b06 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -1,12 +1,12 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. # This script assumes yarn is already installed. -THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) set -e set -u diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 241017d53c0309..8776caaa9232a9 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -295,6 +295,10 @@ export type NativeModulePromiseTypeAnnotation = $ReadOnly<{ type: 'PromiseTypeAnnotation', }>; +export type NativeModuleMixedTypeAnnotation = $ReadOnly<{ + type: 'MixedTypeAnnotation', +}>; + export type NativeModuleBaseTypeAnnotation = | NativeModuleStringTypeAnnotation | NativeModuleNumberTypeAnnotation @@ -306,7 +310,8 @@ export type NativeModuleBaseTypeAnnotation = | ReservedTypeAnnotation | NativeModuleTypeAliasTypeAnnotation | NativeModuleArrayTypeAnnotation> - | NativeModuleObjectTypeAnnotation; + | NativeModuleObjectTypeAnnotation + | NativeModuleMixedTypeAnnotation; export type NativeModuleParamTypeAnnotation = | NativeModuleBaseTypeAnnotation diff --git a/packages/react-native-codegen/src/SchemaValidator.js b/packages/react-native-codegen/src/SchemaValidator.js index 4905b9a7fa8118..887c6eb60a9ccd 100644 --- a/packages/react-native-codegen/src/SchemaValidator.js +++ b/packages/react-native-codegen/src/SchemaValidator.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/__tests__/SchemaValidator-test.js b/packages/react-native-codegen/src/__tests__/SchemaValidator-test.js index 76781b67e9ab8d..1a5896a7b1588c 100644 --- a/packages/react-native-codegen/src/__tests__/SchemaValidator-test.js +++ b/packages/react-native-codegen/src/__tests__/SchemaValidator-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js index 0e7dccfaa4f07e..1c8fc7bc2f437e 100644 --- a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js +++ b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,7 +35,7 @@ const allFiles = []; fileList.forEach(file => { if (fs.lstatSync(file).isDirectory()) { const dirFiles = glob - .sync(`${file}/**/*.js`, { + .sync(`${file}/**/*.{js,ts,tsx}`, { nodir: true, }) .filter(filterJSFile); diff --git a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema.js b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema.js index cf2da06ef64e79..71550527915e37 100644 --- a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema.js +++ b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -12,18 +12,26 @@ import type {SchemaType} from '../../CodegenSchema.js'; const FlowParser = require('../../parsers/flow'); +const TypeScriptParser = require('../../parsers/typescript'); const fs = require('fs'); +const path = require('path'); function combineSchemas(files: Array): SchemaType { return files.reduce( (merged, filename) => { const contents = fs.readFileSync(filename, 'utf8'); + if ( contents && (/export\s+default\s+\(?codegenNativeComponent/dev/null - "$INSTALL_NODE_MODULES" -popd >/dev/null - -exec "$FLOW_NODE_BINARY" "$THIS_DIR/combine-js-to-schema-cli.js" "$@" diff --git a/packages/react-native-codegen/src/cli/generators/generate-all.js b/packages/react-native-codegen/src/cli/generators/generate-all.js index 202c13eff9e43c..6ceeedc9eb9b39 100644 --- a/packages/react-native-codegen/src/cli/generators/generate-all.js +++ b/packages/react-native-codegen/src/cli/generators/generate-all.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/cli/generators/generate-all.sh b/packages/react-native-codegen/src/cli/generators/generate-all.sh deleted file mode 100755 index c17f3a36bbfe0a..00000000000000 --- a/packages/react-native-codegen/src/cli/generators/generate-all.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -e -set -u - -THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) - -# shellcheck source=xplat/js/env-utils/setup_env_vars.sh -source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh" - -pushd "$JS_DIR" >/dev/null - "$INSTALL_NODE_MODULES" -popd >/dev/null - -exec "$FLOW_NODE_BINARY" "$THIS_DIR/generate-all.js" "$@" diff --git a/packages/react-native-codegen/src/cli/parser/parser-cli.js b/packages/react-native-codegen/src/cli/parser/parser-cli.js index b81c0853521199..f6edb7da44bb8c 100644 --- a/packages/react-native-codegen/src/cli/parser/parser-cli.js +++ b/packages/react-native-codegen/src/cli/parser/parser-cli.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/cli/parser/parser.js b/packages/react-native-codegen/src/cli/parser/parser.js index a54bd28c4dc3c6..af0dbb17f78332 100644 --- a/packages/react-native-codegen/src/cli/parser/parser.js +++ b/packages/react-native-codegen/src/cli/parser/parser.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,13 +10,24 @@ 'use strict'; +const path = require('path'); const FlowParser = require('../../parsers/flow'); +const TypeScriptParser = require('../../parsers/typescript'); function parseFiles(files: Array) { files.forEach(filename => { + const isTypeScript = + path.extname(filename) === '.ts' || path.extname(filename) === '.tsx'; + console.log( filename, - JSON.stringify(FlowParser.parseFile(filename), null, 2), + JSON.stringify( + isTypeScript + ? TypeScriptParser.parseFile(filename) + : FlowParser.parseFile(filename), + null, + 2, + ), ); }); } diff --git a/packages/react-native-codegen/src/cli/parser/parser.sh b/packages/react-native-codegen/src/cli/parser/parser.sh index 7d7352abb4cc82..8d130f250017be 100755 --- a/packages/react-native-codegen/src/cli/parser/parser.sh +++ b/packages/react-native-codegen/src/cli/parser/parser.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -7,7 +7,7 @@ set -e set -u -THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) # shellcheck source=xplat/js/env-utils/setup_env_vars.sh source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh" diff --git a/packages/react-native-codegen/src/generators/RNCodegen.js b/packages/react-native-codegen/src/generators/RNCodegen.js index b033d13e4ebad7..78004999db3a0b 100644 --- a/packages/react-native-codegen/src/generators/RNCodegen.js +++ b/packages/react-native-codegen/src/generators/RNCodegen.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -134,36 +134,39 @@ const SCHEMAS_GENERATORS = { ], }; -function writeMapToFiles(map: Map, outputDir: string) { +type CodeGenFile = { + name: string, + content: string, + outputDir: string, +}; + +function writeMapToFiles(map: Array) { let success = true; - map.forEach((contents: string, fileName: string) => { + map.forEach(file => { try { - const location = path.join(outputDir, fileName); + const location = path.join(file.outputDir, file.name); const dirName = path.dirname(location); if (!fs.existsSync(dirName)) { fs.mkdirSync(dirName, {recursive: true}); } - fs.writeFileSync(location, contents); + fs.writeFileSync(location, file.content); } catch (error) { success = false; - console.error(`Failed to write ${fileName} to ${outputDir}`, error); + console.error(`Failed to write ${file.name} to ${file.outputDir}`, error); } }); return success; } -function checkFilesForChanges( - map: Map, - outputDir: string, -): boolean { +function checkFilesForChanges(generated: Array): boolean { let hasChanged = false; - map.forEach((contents: string, fileName: string) => { - const location = path.join(outputDir, fileName); + generated.forEach(file => { + const location = path.join(file.outputDir, file.name); const currentContents = fs.readFileSync(location, 'utf8'); - if (currentContents !== contents) { - console.error(`- ${fileName} has changed`); + if (currentContents !== file.content) { + console.error(`- ${file.name} has changed`); hasChanged = true; } @@ -172,6 +175,16 @@ function checkFilesForChanges( return !hasChanged; } +function checkOrWriteFiles( + generatedFiles: Array, + test: void | boolean, +): boolean { + if (test === true) { + return checkFilesForChanges(generatedFiles); + } + return writeMapToFiles(generatedFiles); +} + module.exports = { generate( { @@ -185,22 +198,42 @@ module.exports = { ): boolean { schemaValidator.validate(schema); - const generatedFiles = []; + function composePath(intermediate: string) { + return path.join(outputDirectory, intermediate, libraryName); + } + + const componentIOSOutput = composePath('react/renderer/components/'); + const modulesIOSOutput = composePath('./'); + + const outputFoldersForGenerators = { + componentsIOS: componentIOSOutput, + modulesIOS: modulesIOSOutput, + descriptors: outputDirectory, + events: outputDirectory, + props: outputDirectory, + componentsAndroid: outputDirectory, + modulesAndroid: outputDirectory, + modulesCxx: outputDirectory, + tests: outputDirectory, + 'shadow-nodes': outputDirectory, + }; + + const generatedFiles: Array = []; + for (const name of generators) { for (const generator of LIBRARY_GENERATORS[name]) { - generatedFiles.push( - ...generator(libraryName, schema, packageName, assumeNonnull), + generator(libraryName, schema, packageName, assumeNonnull).forEach( + (contents: string, fileName: string) => { + generatedFiles.push({ + name: fileName, + content: contents, + outputDir: outputFoldersForGenerators[name], + }); + }, ); } } - - const filesToUpdate = new Map([...generatedFiles]); - - if (test === true) { - return checkFilesForChanges(filesToUpdate, outputDirectory); - } - - return writeMapToFiles(filesToUpdate, outputDirectory); + return checkOrWriteFiles(generatedFiles, test); }, generateFromSchemas( {schemas, outputDirectory}: SchemasOptions, @@ -210,20 +243,20 @@ module.exports = { schemaValidator.validate(schemas[libraryName]), ); - const generatedFiles = []; + const generatedFiles: Array = []; + for (const name of generators) { for (const generator of SCHEMAS_GENERATORS[name]) { - generatedFiles.push(...generator(schemas)); + generator(schemas).forEach((contents: string, fileName: string) => { + generatedFiles.push({ + name: fileName, + content: contents, + outputDir: outputDirectory, + }); + }); } } - - const filesToUpdate = new Map([...generatedFiles]); - - if (test === true) { - return checkFilesForChanges(filesToUpdate, outputDirectory); - } - - return writeMapToFiles(filesToUpdate, outputDirectory); + return checkOrWriteFiles(generatedFiles, test); }, generateViewConfig({libraryName, schema}: LibraryOptions): string { schemaValidator.validate(schema); diff --git a/packages/react-native-codegen/src/generators/Utils.js b/packages/react-native-codegen/src/generators/Utils.js index 68c128360e15e7..e5d1e1b5f68f86 100644 --- a/packages/react-native-codegen/src/generators/Utils.js +++ b/packages/react-native-codegen/src/generators/Utils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,6 +14,20 @@ function capitalize(string: string): string { return string.charAt(0).toUpperCase() + string.slice(1); } +function indent(nice: string, spaces: number): string { + return nice + .split('\n') + .map((line, index) => { + if (line.length === 0 || index === 0) { + return line; + } + const emptySpaces = new Array(spaces + 1).join(' '); + return emptySpaces + line; + }) + .join('\n'); +} + module.exports = { capitalize, + indent, }; diff --git a/packages/react-native-codegen/src/generators/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/__test_fixtures__/fixtures.js new file mode 100644 index 00000000000000..b8659768393350 --- /dev/null +++ b/packages/react-native-codegen/src/generators/__test_fixtures__/fixtures.js @@ -0,0 +1,82 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type {SchemaType} from '../../CodegenSchema.js'; + +const SCHEMA_WITH_TM_AND_FC: SchemaType = { + modules: { + ColoredView: { + type: 'Component', + components: { + ColoredView: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [ + { + name: 'color', + optional: false, + typeAnnotation: { + type: 'StringTypeAnnotation', + default: null, + }, + }, + ], + commands: [], + }, + }, + }, + NativeCalculator: { + type: 'NativeModule', + aliases: {}, + spec: { + properties: [ + { + name: 'add', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'PromiseTypeAnnotation', + }, + params: [ + { + name: 'a', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + { + name: 'b', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + ], + }, + }, + ], + }, + moduleNames: ['Calculator'], + }, + }, +}; + +module.exports = { + all: SCHEMA_WITH_TM_AND_FC, +}; diff --git a/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js b/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js new file mode 100644 index 00000000000000..4cc51277d1d03d --- /dev/null +++ b/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js @@ -0,0 +1,74 @@ +/** + * 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. + * + * @emails oncall+react_native + * @flow strict-local + * @format + */ + +'use strict'; + +const rnCodegen = require('../RNCodegen.js'); +const fixture = require('../__test_fixtures__/fixtures.js'); +const path = require('path'); + +const outputDirectory = 'tmp/out/'; +const packageName = 'na'; + +describe('RNCodegen.generate', () => { + beforeEach(() => { + jest.resetModules(); + }); + it('when type `all`, with default paths', () => { + const componentsOutputDir = 'react/renderer/components/library'; + const modulesOutputDir = 'library'; + + const expectedPaths = { + 'library.h': modulesOutputDir, + 'library-generated.mm': modulesOutputDir, + 'ShadowNodes.h': componentsOutputDir, + 'ShadowNodes.cpp': componentsOutputDir, + 'Props.h': componentsOutputDir, + 'Props.cpp': componentsOutputDir, + 'RCTComponentViewHelpers.h': componentsOutputDir, + 'EventEmitters.h': componentsOutputDir, + 'EventEmitters.cpp': componentsOutputDir, + 'ComponentDescriptors.h': componentsOutputDir, + }; + + jest.mock('fs', () => ({ + existsSync: location => { + return true; + }, + writeFileSync: (location, content) => { + let receivedDir = path.dirname(location); + let receivedBasename = path.basename(location); + + let expectedPath = path.join( + outputDirectory, + expectedPaths[receivedBasename], + ); + expect(receivedDir).toEqual(expectedPath); + }, + })); + + const res = rnCodegen.generate( + { + libraryName: 'library', + schema: fixture.all, + outputDirectory: outputDirectory, + packageName: packageName, + assumeNonnull: true, + }, + { + generators: ['componentsIOS', 'modulesIOS'], + test: false, + }, + ); + + expect(res).toBeTruthy(); + }); +}); diff --git a/packages/react-native-codegen/src/generators/components/CppHelpers.js b/packages/react-native-codegen/src/generators/components/CppHelpers.js index 2b42636dc73482..608fd6d98127a5 100644 --- a/packages/react-native-codegen/src/generators/components/CppHelpers.js +++ b/packages/react-native-codegen/src/generators/components/CppHelpers.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -57,7 +57,13 @@ function getImports( ): Set { const imports: Set = new Set(); - function addImportsForNativeName(name) { + function addImportsForNativeName( + name: + | 'ColorPrimitive' + | 'EdgeInsetsPrimitive' + | 'ImageSourcePrimitive' + | 'PointPrimitive', + ) { switch (name) { case 'ColorPrimitive': return; diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js index 0ae2fb069fc0cd..a7c795622f9082 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentDescriptorH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -23,10 +23,10 @@ const FileTemplate = ({ libraryName: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateComponentDescriptorH.js */ diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 4c0c311923886d..ee619f4617f769 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -128,10 +128,10 @@ RCT_EXTERN inline void RCT${componentName}HandleCommand( const FileTemplate = ({componentContent}: {componentContent: string}) => ` /** -* ${'C'}opyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * ${'@'}generated by codegen project: GenerateComponentHObjCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index a747240c19cb03..cb82e3903b0663 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ */ 'use strict'; +import type {EventTypeShape} from '../../CodegenSchema'; const {generateEventStructName} = require('./CppHelpers.js'); @@ -35,10 +36,10 @@ const FileTemplate = ({ libraryName: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateEventEmitterCpp.js */ @@ -90,7 +91,11 @@ void ${className}EventEmitter::${eventName}() const { } `.trim(); -function generateSetter(variableName, propertyName, propertyParts) { +function generateSetter( + variableName: string, + propertyName: string, + propertyParts: $ReadOnlyArray, +) { const trailingPeriod = propertyParts.length === 0 ? '' : '.'; const eventChain = `event.${propertyParts.join( '.', @@ -99,7 +104,11 @@ function generateSetter(variableName, propertyName, propertyParts) { return `${variableName}.setProperty(runtime, "${propertyName}", ${eventChain}`; } -function generateEnumSetter(variableName, propertyName, propertyParts) { +function generateEnumSetter( + variableName: string, + propertyName: string, + propertyParts: $ReadOnlyArray, +) { const trailingPeriod = propertyParts.length === 0 ? '' : '.'; const eventChain = `event.${propertyParts.join( '.', @@ -177,7 +186,7 @@ function generateSetters( return propSetters; } -function generateEvent(componentName: string, event): string { +function generateEvent(componentName: string, event: EventTypeShape): string { // This is a gross hack necessary because native code is sending // events named things like topChange to JS which is then converted back to // call the onChange prop. We should be consistent throughout the system. diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index e61f103ae5a338..269567575c02f0 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -16,7 +16,8 @@ const { getCppTypeForAnnotation, toSafeCppString, generateEventStructName, -} = require('./CppHelpers.js'); +} = require('./CppHelpers'); +const {indent} = require('../Utils'); import type { ComponentShape, @@ -37,16 +38,17 @@ type ComponentCollection = $ReadOnly<{ const FileTemplate = ({componentEmitters}: {componentEmitters: string}) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -67,7 +69,7 @@ const ComponentTemplate = ({ events: string, }) => ` -class ${className}EventEmitter : public ViewEventEmitter { +class JSI_EXPORT ${className}EventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -110,19 +112,6 @@ static char const *toString(const ${enumName} value) { } `.trim(); -function indent(nice: string, spaces: number) { - return nice - .split('\n') - .map((line, index) => { - if (line.length === 0 || index === 0) { - return line; - } - const emptySpaces = new Array(spaces + 1).join(' '); - return emptySpaces + line; - }) - .join('\n'); -} - function getNativeTypeFromAnnotation( componentName: string, eventProperty: NamedShape, @@ -146,7 +135,11 @@ function getNativeTypeFromAnnotation( throw new Error(`Received invalid event property type ${type}`); } } -function generateEnum(structs, options, nameParts) { +function generateEnum( + structs: StructsMap, + options: $ReadOnlyArray, + nameParts: Array, +) { const structName = generateEventStructName(nameParts); const fields = options .map((option, index) => `${toSafeCppString(option)}`) @@ -229,7 +222,10 @@ function generateStruct( ); } -function generateStructs(componentName: string, component): string { +function generateStructs( + componentName: string, + component: ComponentShape, +): string { const structs: StructsMap = new Map(); component.events.forEach(event => { @@ -255,7 +251,10 @@ function generateEvent(componentName: string, event: EventTypeShape): string { return `void ${event.name}() const;`; } -function generateEvents(componentName: string, component): string { +function generateEvents( + componentName: string, + component: ComponentShape, +): string { return component.events .map(event => generateEvent(componentName, event)) .join('\n\n' + ' '); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index be65aedca7bc89..ad9d6aac61f45a 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -26,10 +26,10 @@ const FileTemplate = ({ componentClasses: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GeneratePropsCpp.js */ @@ -74,7 +74,7 @@ function generatePropsString(componentName: string, component: ComponentShape) { .join(',\n' + ' '); } -function getClassExtendString(component): string { +function getClassExtendString(component: ComponentShape): string { const extendString = ' ' + component.extendsProps @@ -126,13 +126,6 @@ module.exports = { } return Object.keys(components) - .filter(componentName => { - const component = components[componentName]; - return !( - component.excludedPlatforms && - component.excludedPlatforms.includes('iOS') - ); - }) .map(componentName => { const component = components[componentName]; const newName = `${componentName}Props`; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index ad4760c1f2d9c5..26521b0cbb1936 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,16 @@ */ 'use strict'; +import type { + StringTypeAnnotation, + ReservedPropTypeAnnotation, + ObjectTypeAnnotation, + Int32TypeAnnotation, + FloatTypeAnnotation, + DoubleTypeAnnotation, + ComponentShape, + BooleanTypeAnnotation, +} from '../../CodegenSchema'; const { convertDefaultTypeToString, @@ -40,10 +50,10 @@ const FileTemplate = ({ componentClasses: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GeneratePropsH.js */ @@ -76,7 +86,7 @@ const ClassTemplate = ({ ` ${enums} ${structs} -class ${className} final${extendClasses} { +class JSI_EXPORT ${className} final${extendClasses} { public: ${className}() = default; ${className}(const PropsParserContext& context, const ${className} &sourceProps, const RawProps &rawProps); @@ -157,7 +167,7 @@ const StructTemplate = ({ }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ${structName} &result) { - auto map = (better::map)value; + auto map = (butter::map)value; ${fromCases} } @@ -257,7 +267,7 @@ static inline std::string toString(const ${enumMask} &value) { } `.trim(); -function getClassExtendString(component): string { +function getClassExtendString(component: ComponentShape): string { if (component.extendsProps.length === 0) { throw new Error('Invalid: component.extendsProps is empty'); } @@ -286,7 +296,29 @@ function getClassExtendString(component): string { function getNativeTypeFromAnnotation( componentName: string, - prop, + prop: + | NamedShape + | { + name: string, + typeAnnotation: + | $FlowFixMe + | DoubleTypeAnnotation + | FloatTypeAnnotation + | BooleanTypeAnnotation + | Int32TypeAnnotation + | StringTypeAnnotation + | ObjectTypeAnnotation + | ReservedPropTypeAnnotation + | { + +default: string, + +options: $ReadOnlyArray, + +type: 'StringEnumTypeAnnotation', + } + | { + +elementType: ObjectTypeAnnotation, + +type: 'ArrayTypeAnnotation', + }, + }, nameParts: $ReadOnlyArray, ): string { const typeAnnotation = prop.typeAnnotation; @@ -400,7 +432,10 @@ function generateArrayEnumString( }); } -function generateStringEnum(componentName, prop) { +function generateStringEnum( + componentName: string, + prop: NamedShape, +) { const typeAnnotation = prop.typeAnnotation; if (typeAnnotation.type === 'StringEnumTypeAnnotation') { const values: $ReadOnlyArray = typeAnnotation.options; @@ -435,7 +470,10 @@ function generateStringEnum(componentName, prop) { return ''; } -function generateIntEnum(componentName, prop) { +function generateIntEnum( + componentName: string, + prop: NamedShape, +) { const typeAnnotation = prop.typeAnnotation; if (typeAnnotation.type === 'Int32EnumTypeAnnotation') { const values: $ReadOnlyArray = typeAnnotation.options; @@ -476,7 +514,10 @@ function generateIntEnum(componentName, prop) { return ''; } -function generateEnumString(componentName: string, component): string { +function generateEnumString( + componentName: string, + component: ComponentShape, +): string { return component.props .map(prop => { if ( @@ -538,6 +579,7 @@ function getExtendsImports( const imports: Set = new Set(); imports.add('#include '); + imports.add('#include '); extendsProps.forEach(extendProps => { switch (extendProps.type) { @@ -566,7 +608,13 @@ function getLocalImports( ): Set { const imports: Set = new Set(); - function addImportsForNativeName(name) { + function addImportsForNativeName( + name: + | 'ColorPrimitive' + | 'EdgeInsetsPrimitive' + | 'ImageSourcePrimitive' + | 'PointPrimitive', + ) { switch (name) { case 'ColorPrimitive': imports.add('#include '); @@ -634,7 +682,10 @@ function getLocalImports( return imports; } -function generateStructsForComponent(componentName: string, component): string { +function generateStructsForComponent( + componentName: string, + component: ComponentShape, +): string { const structs = generateStructs(componentName, component.props, []); const structArray = Array.from(structs.values()); if (structArray.length < 1) { @@ -645,8 +696,8 @@ function generateStructsForComponent(componentName: string, component): string { function generateStructs( componentName: string, - properties, - nameParts, + properties: $ReadOnlyArray>, + nameParts: Array, ): StructsMap { const structs: StructsMap = new Map(); properties.forEach(prop => { @@ -817,10 +868,10 @@ function generateStruct( const fromCases = properties .map(property => { - const variable = property.name; + const variable = 'tmp_' + property.name; return `auto ${variable} = map.find("${property.name}"); if (${variable} != map.end()) { - fromRawValue(context, ${variable}->second, result.${variable}); + fromRawValue(context, ${variable}->second, result.${property.name}); }`; }) .join('\n '); @@ -860,13 +911,6 @@ module.exports = { } return Object.keys(components) - .filter(componentName => { - const component = components[componentName]; - return !( - component.excludedPlatforms && - component.excludedPlatforms.includes('iOS') - ); - }) .map(componentName => { const component = components[componentName]; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index b01eeac4be29f8..f39fe2a51d9055 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ */ 'use strict'; +import type {CommandParamTypeAnnotation} from '../../CodegenSchema'; import type { NamedShape, @@ -42,10 +43,10 @@ const FileTemplate = ({ interfaceClassName: string, methods: string, }) => `/** -* ${'C'}opyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * ${'@'}generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -170,7 +171,10 @@ function generatePropCasesString( }`; } -function getCommandArgJavaType(param, index) { +function getCommandArgJavaType( + param: NamedShape, + index: number, +) { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -229,7 +233,7 @@ function generateCommandCasesString( return commandMethods; } -function getClassExtendString(component): string { +function getClassExtendString(component: ComponentShape): string { const extendString = component.extendsProps .map(extendProps => { switch (extendProps.type) { @@ -251,7 +255,7 @@ function getClassExtendString(component): string { return extendString; } -function getDelegateImports(component) { +function getDelegateImports(component: ComponentShape) { const imports = getImports(component, 'delegate'); // The delegate needs ReadableArray for commands always. // The interface doesn't always need it @@ -265,7 +269,10 @@ function getDelegateImports(component) { return imports; } -function generateMethods(propsString, commandsString): string { +function generateMethods( + propsString: string, + commandsString: null | string, +): string { return [ PropSetterTemplate({propCases: propsString}), commandsString != null diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index d1fbdfb9a24799..5afeeb6e51db10 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ */ 'use strict'; +import type {CommandParamTypeAnnotation} from '../../CodegenSchema'; import type { NamedShape, @@ -39,10 +40,10 @@ const FileTemplate = ({ extendClasses: string, methods: string, }) => `/** -* ${'C'}opyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * ${'@'}generated by codegen project: GeneratePropsJavaInterface.js */ @@ -56,13 +57,13 @@ public interface ${className} { } `; -function addNullable(imports) { +function addNullable(imports: Set) { imports.add('import androidx.annotation.Nullable;'); } function getJavaValueForProp( prop: NamedShape, - imports, + imports: Set, ): string { const typeAnnotation = prop.typeAnnotation; @@ -126,7 +127,7 @@ function getJavaValueForProp( } } -function generatePropsString(component: ComponentShape, imports) { +function generatePropsString(component: ComponentShape, imports: Set) { if (component.props.length === 0) { return '// No props'; } @@ -140,7 +141,7 @@ function generatePropsString(component: ComponentShape, imports) { .join('\n' + ' '); } -function getCommandArgJavaType(param) { +function getCommandArgJavaType(param: NamedShape) { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -198,7 +199,7 @@ function generateCommandsString( .join('\n' + ' '); } -function getClassExtendString(component): string { +function getClassExtendString(component: ComponentShape): string { const extendString = component.extendsProps .map(extendProps => { switch (extendProps.type) { diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js index f80ad58863f7c3..eb7b1091dc7784 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js index f5fa8c77f01f17..66b11f26c8c3e8 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js index 72829ec3dd5d6e..3e3e2ad532dd59 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -264,7 +264,7 @@ function serializePojo(pojo: Pojo, basePackageName: string): string { .join('\n'); return `/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. diff --git a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js index 5c0f3e2a524237..82cb8ffd5ab559 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -23,10 +23,10 @@ const FileTemplate = ({ componentNames: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateShadowNodeCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js index d5aa2531bfa7da..5159bd6168568a 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateShadowNodeH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -25,10 +25,10 @@ const FileTemplate = ({ componentClasses: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateShadowNodeH.js */ @@ -37,6 +37,7 @@ const FileTemplate = ({ ${imports}#include #include +#include namespace facebook { namespace react { @@ -55,7 +56,7 @@ const ComponentTemplate = ({ eventEmitter: string, }) => ` -extern const char ${className}ComponentName[]; +JSI_EXPORT extern const char ${className}ComponentName[]; /* * \`ShadowNode\` for <${className}> component. diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index d3f65ea3522b8a..cfefaa318bd946 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ */ 'use strict'; +import type {PropTypeAnnotation, ComponentShape} from '../../CodegenSchema'; import type {SchemaType} from '../../CodegenSchema'; const {getImports, toSafeCppString} = require('./CppHelpers'); @@ -34,10 +35,10 @@ const FileTemplate = ({ }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateTests.js * */ @@ -76,7 +77,10 @@ TEST(${componentName}_${testName}, etc) { } `; -function getTestCasesForProp(propName, typeAnnotation) { +function getTestCasesForProp( + propName: string, + typeAnnotation: PropTypeAnnotation, +) { const cases = []; if (typeAnnotation.type === 'StringEnumTypeAnnotation') { typeAnnotation.options.forEach(option => @@ -134,7 +138,7 @@ function getTestCasesForProp(propName, typeAnnotation) { return cases; } -function generateTestsString(name, component) { +function generateTestsString(name: string, component: ComponentShape) { function createTest({testName, propName, propValue, raw = false}: TestCase) { const value = !raw && typeof propValue === 'string' ? `"${propValue}"` : propValue; diff --git a/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js b/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js index 5b74e0b231d8d0..cddb1302d754a4 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,10 +17,10 @@ type FilesOutput = Map; const FileTemplate = ({lookupFuncs}: {lookupFuncs: string}) => ` /* - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by GenerateRCTThirdPartyFabricComponentsProviderH */ @@ -86,11 +86,6 @@ module.exports = { ); }) .map(componentName => { - const component = components[componentName]; - if (component.interfaceOnly === true) { - return; - } - return LookupFuncTemplate({ className: componentName, libraryName, diff --git a/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js index 93de10dd241a32..549633cd160428 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,10 +17,10 @@ type FilesOutput = Map; const FileTemplate = ({lookupMap}: {lookupMap: string}) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by GenerateRCTThirdPartyFabricComponentsProviderCpp */ @@ -84,9 +84,6 @@ module.exports = { ); }) .map(componentName => { - if (components[componentName].interfaceOnly === true) { - return; - } const replacedTemplate = LookupMapTemplate({ className: componentName, libraryName, diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index b68b5919c78a74..49e1a9208d74e5 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,11 @@ */ 'use strict'; +import type { + PropTypeAnnotation, + EventTypeShape, + ComponentShape, +} from '../../CodegenSchema'; const j = require('jscodeshift'); @@ -25,10 +30,10 @@ const FileTemplate = ({ componentConfig: string, }) => ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -46,7 +51,7 @@ ${componentConfig} // this multiple times. const UIMANAGER_IMPORT = 'const {UIManager} = require("react-native")'; -function getReactDiffProcessValue(typeAnnotation) { +function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) { switch (typeAnnotation.type) { case 'BooleanTypeAnnotation': case 'StringTypeAnnotation': @@ -123,10 +128,16 @@ ${ }) : '' } -export default NativeComponentRegistry.get(nativeComponentName, () => VIEW_CONFIG); + +export const __INTERNAL_VIEW_CONFIG = VIEW_CONFIG; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); `.trim(); }; +// Check whether the native component exists in the app binary. +// Old getViewManagerConfig() checks for the existance of the native Paper view manager. Not available in Bridgeless. +// New hasViewManagerConfig() queries Fabric’s native component registry directly. const DeprecatedComponentNameCheckTemplate = ({ componentName, paperComponentNameDeprecated, @@ -135,9 +146,9 @@ const DeprecatedComponentNameCheckTemplate = ({ paperComponentNameDeprecated: string, }) => ` -if (UIManager.getViewManagerConfig('${componentName}')) { +if (UIManager.hasViewManagerConfig('${componentName}')) { nativeComponentName = '${componentName}'; -} else if (UIManager.getViewManagerConfig('${paperComponentNameDeprecated}')) { +} else if (UIManager.hasViewManagerConfig('${paperComponentNameDeprecated}')) { nativeComponentName = '${paperComponentNameDeprecated}'; } else { throw new Error('Failed to find native component for either "${componentName}" or "${paperComponentNameDeprecated}"'); @@ -145,7 +156,7 @@ if (UIManager.getViewManagerConfig('${componentName}')) { `.trim(); // Replicates the behavior of RCTNormalizeInputEventName in RCTEventDispatcher.m -function normalizeInputEventName(name) { +function normalizeInputEventName(name: string) { if (name.startsWith('on')) { return name.replace(/^on/, 'top'); } else if (!name.startsWith('top')) { @@ -156,13 +167,29 @@ function normalizeInputEventName(name) { } // Replicates the behavior of viewConfig in RCTComponentData.m -function getValidAttributesForEvents(events) { - return events.map(eventType => { - return j.property('init', j.identifier(eventType.name), j.literal(true)); - }); +function getValidAttributesForEvents( + events: $ReadOnlyArray, + imports: Set, +) { + imports.add( + "const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');", + ); + + const validAttributes = j.objectExpression( + events.map(eventType => { + return j.property('init', j.identifier(eventType.name), j.literal(true)); + }), + ); + + return j.callExpression(j.identifier('ConditionallyIgnoredEventHandlers'), [ + validAttributes, + ]); } -function generateBubblingEventInfo(event, nameOveride) { +function generateBubblingEventInfo( + event: EventTypeShape, + nameOveride: void | string, +) { return j.property( 'init', j.identifier(nameOveride || normalizeInputEventName(event.name)), @@ -183,7 +210,10 @@ function generateBubblingEventInfo(event, nameOveride) { ); } -function generateDirectEventInfo(event, nameOveride) { +function generateDirectEventInfo( + event: EventTypeShape, + nameOveride: void | string, +) { return j.property( 'init', j.identifier(nameOveride || normalizeInputEventName(event.name)), @@ -200,8 +230,8 @@ function generateDirectEventInfo(event, nameOveride) { function buildViewConfig( schema: SchemaType, componentName: string, - component, - imports, + component: ComponentShape, + imports: Set, ) { const componentProps = component.props; const componentEvents = component.events; @@ -234,7 +264,13 @@ function buildViewConfig( getReactDiffProcessValue(schemaProp.typeAnnotation), ); }), - ...getValidAttributesForEvents(componentEvents), + ...(componentEvents.length > 0 + ? [ + j.spreadProperty( + getValidAttributesForEvents(componentEvents, imports), + ), + ] + : []), ]); const bubblingEventNames = component.events @@ -247,8 +283,9 @@ function buildViewConfig( bubblingEvents.push( generateBubblingEventInfo(event, event.paperTopLevelNameDeprecated), ); + } else { + bubblingEvents.push(generateBubblingEventInfo(event)); } - bubblingEvents.push(generateBubblingEventInfo(event)); return bubblingEvents; }, []); @@ -271,8 +308,9 @@ function buildViewConfig( directEvents.push( generateDirectEventInfo(event, event.paperTopLevelNameDeprecated), ); + } else { + directEvents.push(generateDirectEventInfo(event)); } - directEvents.push(generateDirectEventInfo(event)); return directEvents; }, []); @@ -302,8 +340,8 @@ function buildViewConfig( function buildCommands( schema: SchemaType, componentName: string, - component, - imports, + component: ComponentShape, + imports: Set, ) { const commands = component.commands; diff --git a/packages/react-native-codegen/src/generators/components/JavaHelpers.js b/packages/react-native-codegen/src/generators/components/JavaHelpers.js index 9a6e02c81dcfe7..421ed3e5851315 100644 --- a/packages/react-native-codegen/src/generators/components/JavaHelpers.js +++ b/packages/react-native-codegen/src/generators/components/JavaHelpers.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index 69529644cc4298..1498da71273884 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js index 02133c76f90539..2336631431037e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js index 52b638973aae82..8e3d0caf63c118 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentHObjCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js index 14ac106e959b4d..e6028d81705c30 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js index 2b6a26422aa306..73d4dacc9c160a 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateEventEmitterH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js index f9b9332a1259ca..e808259e18dba6 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js index 77305fc2c4a077..5fd7d66f2aa095 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js index 36f1f9e8a5ca1a..7901c9f58a4549 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaDelegate-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js index cc1eadab41ab78..6849a80f9f75ad 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaInterface-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js index 80b2df4dd042b9..5de44fa4cb216d 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeCpp-test.js index b3cc7efdcab26c..90d194c0ea2194 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js index ea704d4773d614..e21cd6a9caf0d8 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateShadowNodeH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js index 6961d0b1754ee1..df9215da4dca08 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateTests-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js index c3f67d8604c54a..5c2a06332487b9 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js index aa70282c0a3602..06badb829aed16 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateViewConfigJs-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateViewConfigJs-test.js index dbb69c01457055..da1136da5cdc89 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateViewConfigJs-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateViewConfigJs-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 34b1f425bc4174..20ab6f69ffd131 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -32,10 +32,10 @@ exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS_WITH_NEST Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -60,10 +60,10 @@ exports[`GenerateComponentDescriptorH can generate fixture BOOLEAN_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -88,10 +88,10 @@ exports[`GenerateComponentDescriptorH can generate fixture COLOR_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -116,10 +116,10 @@ exports[`GenerateComponentDescriptorH can generate fixture COMMANDS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -144,10 +144,10 @@ exports[`GenerateComponentDescriptorH can generate fixture COMMANDS_AND_PROPS 1` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -172,10 +172,10 @@ exports[`GenerateComponentDescriptorH can generate fixture DOUBLE_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -200,10 +200,10 @@ exports[`GenerateComponentDescriptorH can generate fixture EVENT_NESTED_OBJECT_P Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -228,10 +228,10 @@ exports[`GenerateComponentDescriptorH can generate fixture EVENT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -256,10 +256,10 @@ exports[`GenerateComponentDescriptorH can generate fixture EVENTS_WITH_PAPER_NAM Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -284,10 +284,10 @@ exports[`GenerateComponentDescriptorH can generate fixture EXCLUDE_ANDROID 1`] = Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -312,10 +312,10 @@ exports[`GenerateComponentDescriptorH can generate fixture EXCLUDE_ANDROID_IOS 1 Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -340,10 +340,10 @@ exports[`GenerateComponentDescriptorH can generate fixture FLOAT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -368,10 +368,10 @@ exports[`GenerateComponentDescriptorH can generate fixture IMAGE_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -396,10 +396,10 @@ exports[`GenerateComponentDescriptorH can generate fixture INSETS_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -424,10 +424,10 @@ exports[`GenerateComponentDescriptorH can generate fixture INT32_ENUM_PROP 1`] = Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -452,10 +452,10 @@ exports[`GenerateComponentDescriptorH can generate fixture INTEGER_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -480,10 +480,10 @@ exports[`GenerateComponentDescriptorH can generate fixture INTERFACE_ONLY 1`] = Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -508,10 +508,10 @@ exports[`GenerateComponentDescriptorH can generate fixture MULTI_NATIVE_PROP 1`] Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -536,10 +536,10 @@ exports[`GenerateComponentDescriptorH can generate fixture NO_PROPS_NO_EVENTS 1` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -564,10 +564,10 @@ exports[`GenerateComponentDescriptorH can generate fixture OBJECT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -592,10 +592,10 @@ exports[`GenerateComponentDescriptorH can generate fixture POINT_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -620,10 +620,10 @@ exports[`GenerateComponentDescriptorH can generate fixture STRING_ENUM_PROP 1`] Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -648,10 +648,10 @@ exports[`GenerateComponentDescriptorH can generate fixture STRING_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -676,10 +676,10 @@ exports[`GenerateComponentDescriptorH can generate fixture TWO_COMPONENTS_DIFFER Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ @@ -705,10 +705,10 @@ exports[`GenerateComponentDescriptorH can generate fixture TWO_COMPONENTS_SAME_F Map { "ComponentDescriptors.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateComponentDescriptorH.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap index 68e1b8f98344ee..d21fa8930f0bcc 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -3,10 +3,10 @@ exports[`GenerateComponentHObjCpp can generate fixture ARRAY_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -28,10 +28,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -53,10 +53,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture BOOLEAN_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -78,10 +78,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture COLOR_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -103,10 +103,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture COMMANDS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -205,10 +205,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -289,10 +289,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -314,10 +314,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -339,10 +339,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture EVENT_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -364,10 +364,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -389,10 +389,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -414,10 +414,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -437,10 +437,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture FLOAT_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -462,10 +462,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture IMAGE_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -487,10 +487,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture INSETS_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -512,10 +512,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture INT32_ENUM_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -537,10 +537,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -562,10 +562,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture INTERFACE_ONLY 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -587,10 +587,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -612,10 +612,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -637,10 +637,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture OBJECT_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -662,10 +662,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture POINT_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -687,10 +687,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture STRING_ENUM_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -712,10 +712,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture STRING_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -737,10 +737,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ @@ -766,10 +766,10 @@ NS_ASSUME_NONNULL_END", exports[`GenerateComponentHObjCpp can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GenerateComponentHObjCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 04c08736f743ec..8d0858dc93bf99 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateEventEmitterCpp can generate fixture ARRAY_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -29,10 +29,10 @@ exports[`GenerateEventEmitterCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OB Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -54,10 +54,10 @@ exports[`GenerateEventEmitterCpp can generate fixture BOOLEAN_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -79,10 +79,10 @@ exports[`GenerateEventEmitterCpp can generate fixture COLOR_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -104,10 +104,10 @@ exports[`GenerateEventEmitterCpp can generate fixture COMMANDS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -129,10 +129,10 @@ exports[`GenerateEventEmitterCpp can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -154,10 +154,10 @@ exports[`GenerateEventEmitterCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -179,10 +179,10 @@ exports[`GenerateEventEmitterCpp can generate fixture EVENT_NESTED_OBJECT_PROPS Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -222,10 +222,10 @@ exports[`GenerateEventEmitterCpp can generate fixture EVENT_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -273,10 +273,10 @@ exports[`GenerateEventEmitterCpp can generate fixture EVENTS_WITH_PAPER_NAME 1`] Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -311,10 +311,10 @@ exports[`GenerateEventEmitterCpp can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -336,10 +336,10 @@ exports[`GenerateEventEmitterCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -361,10 +361,10 @@ exports[`GenerateEventEmitterCpp can generate fixture FLOAT_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -386,10 +386,10 @@ exports[`GenerateEventEmitterCpp can generate fixture IMAGE_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -411,10 +411,10 @@ exports[`GenerateEventEmitterCpp can generate fixture INSETS_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -436,10 +436,10 @@ exports[`GenerateEventEmitterCpp can generate fixture INT32_ENUM_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -461,10 +461,10 @@ exports[`GenerateEventEmitterCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -486,10 +486,10 @@ exports[`GenerateEventEmitterCpp can generate fixture INTERFACE_ONLY 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -517,10 +517,10 @@ exports[`GenerateEventEmitterCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -542,10 +542,10 @@ exports[`GenerateEventEmitterCpp can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -567,10 +567,10 @@ exports[`GenerateEventEmitterCpp can generate fixture OBJECT_PROPS 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -592,10 +592,10 @@ exports[`GenerateEventEmitterCpp can generate fixture POINT_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -617,10 +617,10 @@ exports[`GenerateEventEmitterCpp can generate fixture STRING_ENUM_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -642,10 +642,10 @@ exports[`GenerateEventEmitterCpp can generate fixture STRING_PROP 1`] = ` Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -667,10 +667,10 @@ exports[`GenerateEventEmitterCpp can generate fixture TWO_COMPONENTS_DIFFERENT_F Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ @@ -693,10 +693,10 @@ exports[`GenerateEventEmitterCpp can generate fixture TWO_COMPONENTS_SAME_FILE 1 Map { "EventEmitters.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap index 18e1a2ce0d489a..942ca4c88eadae 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -4,16 +4,17 @@ exports[`GenerateEventEmitterH can generate fixture ARRAY_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -30,16 +31,17 @@ exports[`GenerateEventEmitterH can generate fixture ARRAY_PROPS_WITH_NESTED_OBJE Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -56,16 +58,17 @@ exports[`GenerateEventEmitterH can generate fixture BOOLEAN_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -82,16 +85,17 @@ exports[`GenerateEventEmitterH can generate fixture COLOR_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -108,16 +112,17 @@ exports[`GenerateEventEmitterH can generate fixture COMMANDS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -134,16 +139,17 @@ exports[`GenerateEventEmitterH can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -160,16 +166,17 @@ exports[`GenerateEventEmitterH can generate fixture DOUBLE_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -186,21 +193,22 @@ exports[`GenerateEventEmitterH can generate fixture EVENT_NESTED_OBJECT_PROPS 1` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class EventsNestedObjectNativeComponentEventEmitter : public ViewEventEmitter { +class JSI_EXPORT EventsNestedObjectNativeComponentEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -231,21 +239,22 @@ exports[`GenerateEventEmitterH can generate fixture EVENT_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class EventsNativeComponentEventEmitter : public ViewEventEmitter { +class JSI_EXPORT EventsNativeComponentEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -295,21 +304,22 @@ exports[`GenerateEventEmitterH can generate fixture EVENTS_WITH_PAPER_NAME 1`] = Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class InterfaceOnlyComponentEventEmitter : public ViewEventEmitter { +class JSI_EXPORT InterfaceOnlyComponentEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -336,16 +346,17 @@ exports[`GenerateEventEmitterH can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -362,16 +373,17 @@ exports[`GenerateEventEmitterH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -388,16 +400,17 @@ exports[`GenerateEventEmitterH can generate fixture FLOAT_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -414,16 +427,17 @@ exports[`GenerateEventEmitterH can generate fixture IMAGE_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -440,16 +454,17 @@ exports[`GenerateEventEmitterH can generate fixture INSETS_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -466,16 +481,17 @@ exports[`GenerateEventEmitterH can generate fixture INT32_ENUM_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -492,16 +508,17 @@ exports[`GenerateEventEmitterH can generate fixture INTEGER_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -518,21 +535,22 @@ exports[`GenerateEventEmitterH can generate fixture INTERFACE_ONLY 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { -class InterfaceOnlyComponentEventEmitter : public ViewEventEmitter { +class JSI_EXPORT InterfaceOnlyComponentEventEmitter : public ViewEventEmitter { public: using ViewEventEmitter::ViewEventEmitter; @@ -553,16 +571,17 @@ exports[`GenerateEventEmitterH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -579,16 +598,17 @@ exports[`GenerateEventEmitterH can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -605,16 +625,17 @@ exports[`GenerateEventEmitterH can generate fixture OBJECT_PROPS 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -631,16 +652,17 @@ exports[`GenerateEventEmitterH can generate fixture POINT_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -657,16 +679,17 @@ exports[`GenerateEventEmitterH can generate fixture STRING_ENUM_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -683,16 +706,17 @@ exports[`GenerateEventEmitterH can generate fixture STRING_PROP 1`] = ` Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -709,16 +733,17 @@ exports[`GenerateEventEmitterH can generate fixture TWO_COMPONENTS_DIFFERENT_FIL Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { @@ -735,16 +760,17 @@ exports[`GenerateEventEmitterH can generate fixture TWO_COMPONENTS_SAME_FILE 1`] Map { "EventEmitters.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateEventEmitterH.js */ #pragma once #include +#include namespace facebook { namespace react { diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index 3e5a5b031f972f..ceae8252ed004e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GeneratePropsCpp can generate fixture ARRAY_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -48,10 +48,10 @@ exports[`GeneratePropsCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -81,10 +81,10 @@ exports[`GeneratePropsCpp can generate fixture BOOLEAN_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -114,10 +114,10 @@ exports[`GeneratePropsCpp can generate fixture COLOR_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -147,10 +147,10 @@ exports[`GeneratePropsCpp can generate fixture COMMANDS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -180,10 +180,10 @@ exports[`GeneratePropsCpp can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -213,10 +213,10 @@ exports[`GeneratePropsCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -251,10 +251,10 @@ exports[`GeneratePropsCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -284,10 +284,10 @@ exports[`GeneratePropsCpp can generate fixture EVENT_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -317,10 +317,10 @@ exports[`GeneratePropsCpp can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -350,10 +350,10 @@ exports[`GeneratePropsCpp can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -383,10 +383,10 @@ exports[`GeneratePropsCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -398,7 +398,13 @@ Map { namespace facebook { namespace react { +ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps( + const PropsParserContext &context, + const ExcludedAndroidIosComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps) + + {} } // namespace react } // namespace facebook @@ -410,10 +416,10 @@ exports[`GeneratePropsCpp can generate fixture FLOAT_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -448,10 +454,10 @@ exports[`GeneratePropsCpp can generate fixture IMAGE_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -482,10 +488,10 @@ exports[`GeneratePropsCpp can generate fixture INSETS_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -515,10 +521,10 @@ exports[`GeneratePropsCpp can generate fixture INT32_ENUM_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -548,10 +554,10 @@ exports[`GeneratePropsCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -583,10 +589,10 @@ exports[`GeneratePropsCpp can generate fixture INTERFACE_ONLY 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -616,10 +622,10 @@ exports[`GeneratePropsCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -653,10 +659,10 @@ exports[`GeneratePropsCpp can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -686,10 +692,10 @@ exports[`GeneratePropsCpp can generate fixture OBJECT_PROPS 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -720,10 +726,10 @@ exports[`GeneratePropsCpp can generate fixture POINT_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -753,10 +759,10 @@ exports[`GeneratePropsCpp can generate fixture STRING_ENUM_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -786,10 +792,10 @@ exports[`GeneratePropsCpp can generate fixture STRING_PROP 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -820,10 +826,10 @@ exports[`GeneratePropsCpp can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ @@ -860,10 +866,10 @@ exports[`GeneratePropsCpp can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "Props.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index 707ce40d932b44..bdede2c33e8793 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -4,16 +4,17 @@ exports[`GeneratePropsH can generate fixture ARRAY_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once #include +#include #include #include #include @@ -84,11 +85,11 @@ struct ArrayPropsNativeComponentObjectStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentObjectStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } } @@ -111,11 +112,11 @@ struct ArrayPropsNativeComponentArrayObjectStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayObjectStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } } @@ -138,11 +139,11 @@ struct ArrayPropsNativeComponentArrayStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto object = map.find(\\"object\\"); - if (object != map.end()) { - fromRawValue(context, object->second, result.object); + auto tmp_object = map.find(\\"object\\"); + if (tmp_object != map.end()) { + fromRawValue(context, tmp_object->second, result.object); } } @@ -165,11 +166,11 @@ struct ArrayPropsNativeComponentArrayOfArrayOfObjectStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentArrayOfArrayOfObjectStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } } @@ -190,7 +191,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu } } -class ArrayPropsNativeComponentProps final : public ViewProps { +class JSI_EXPORT ArrayPropsNativeComponentProps final : public ViewProps { public: ArrayPropsNativeComponentProps() = default; ArrayPropsNativeComponentProps(const PropsParserContext& context, const ArrayPropsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -220,15 +221,16 @@ exports[`GeneratePropsH can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -247,19 +249,19 @@ struct ArrayPropsNativeComponentNativePrimitivesStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ArrayPropsNativeComponentNativePrimitivesStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto colors = map.find(\\"colors\\"); - if (colors != map.end()) { - fromRawValue(context, colors->second, result.colors); + auto tmp_colors = map.find(\\"colors\\"); + if (tmp_colors != map.end()) { + fromRawValue(context, tmp_colors->second, result.colors); } - auto srcs = map.find(\\"srcs\\"); - if (srcs != map.end()) { - fromRawValue(context, srcs->second, result.srcs); + auto tmp_srcs = map.find(\\"srcs\\"); + if (tmp_srcs != map.end()) { + fromRawValue(context, tmp_srcs->second, result.srcs); } - auto points = map.find(\\"points\\"); - if (points != map.end()) { - fromRawValue(context, points->second, result.points); + auto tmp_points = map.find(\\"points\\"); + if (tmp_points != map.end()) { + fromRawValue(context, tmp_points->second, result.points); } } @@ -276,7 +278,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu } } -class ArrayPropsNativeComponentProps final : public ViewProps { +class JSI_EXPORT ArrayPropsNativeComponentProps final : public ViewProps { public: ArrayPropsNativeComponentProps() = default; ArrayPropsNativeComponentProps(const PropsParserContext& context, const ArrayPropsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -296,22 +298,23 @@ exports[`GeneratePropsH can generate fixture BOOLEAN_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class BooleanPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT BooleanPropNativeComponentProps final : public ViewProps { public: BooleanPropNativeComponentProps() = default; BooleanPropNativeComponentProps(const PropsParserContext& context, const BooleanPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -331,15 +334,16 @@ exports[`GeneratePropsH can generate fixture COLOR_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -347,7 +351,7 @@ Map { namespace facebook { namespace react { -class ColorPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT ColorPropNativeComponentProps final : public ViewProps { public: ColorPropNativeComponentProps() = default; ColorPropNativeComponentProps(const PropsParserContext& context, const ColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -367,22 +371,23 @@ exports[`GeneratePropsH can generate fixture COMMANDS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class CommandNativeComponentProps final : public ViewProps { +class JSI_EXPORT CommandNativeComponentProps final : public ViewProps { public: CommandNativeComponentProps() = default; CommandNativeComponentProps(const PropsParserContext& context, const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -402,22 +407,23 @@ exports[`GeneratePropsH can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class CommandNativeComponentProps final : public ViewProps { +class JSI_EXPORT CommandNativeComponentProps final : public ViewProps { public: CommandNativeComponentProps() = default; CommandNativeComponentProps(const PropsParserContext& context, const CommandNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -437,22 +443,23 @@ exports[`GeneratePropsH can generate fixture DOUBLE_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class DoublePropNativeComponentProps final : public ViewProps { +class JSI_EXPORT DoublePropNativeComponentProps final : public ViewProps { public: DoublePropNativeComponentProps() = default; DoublePropNativeComponentProps(const PropsParserContext& context, const DoublePropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -477,22 +484,23 @@ exports[`GeneratePropsH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class EventsNestedObjectNativeComponentProps final : public ViewProps { +class JSI_EXPORT EventsNestedObjectNativeComponentProps final : public ViewProps { public: EventsNestedObjectNativeComponentProps() = default; EventsNestedObjectNativeComponentProps(const PropsParserContext& context, const EventsNestedObjectNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -512,22 +520,23 @@ exports[`GeneratePropsH can generate fixture EVENT_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class EventsNativeComponentProps final : public ViewProps { +class JSI_EXPORT EventsNativeComponentProps final : public ViewProps { public: EventsNativeComponentProps() = default; EventsNativeComponentProps(const PropsParserContext& context, const EventsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -547,22 +556,23 @@ exports[`GeneratePropsH can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class InterfaceOnlyComponentProps final : public ViewProps { +class JSI_EXPORT InterfaceOnlyComponentProps final : public ViewProps { public: InterfaceOnlyComponentProps() = default; InterfaceOnlyComponentProps(const PropsParserContext& context, const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); @@ -582,22 +592,23 @@ exports[`GeneratePropsH can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class ExcludedAndroidComponentProps final : public ViewProps { +class JSI_EXPORT ExcludedAndroidComponentProps final : public ViewProps { public: ExcludedAndroidComponentProps() = default; ExcludedAndroidComponentProps(const PropsParserContext& context, const ExcludedAndroidComponentProps &sourceProps, const RawProps &rawProps); @@ -617,21 +628,31 @@ exports[`GeneratePropsH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once - +#include +#include +#include namespace facebook { namespace react { +class JSI_EXPORT ExcludedAndroidIosComponentProps final : public ViewProps { + public: + ExcludedAndroidIosComponentProps() = default; + ExcludedAndroidIosComponentProps(const PropsParserContext& context, const ExcludedAndroidIosComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + +}; } // namespace react } // namespace facebook @@ -643,22 +664,23 @@ exports[`GeneratePropsH can generate fixture FLOAT_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class FloatPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT FloatPropNativeComponentProps final : public ViewProps { public: FloatPropNativeComponentProps() = default; FloatPropNativeComponentProps(const PropsParserContext& context, const FloatPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -683,15 +705,16 @@ exports[`GeneratePropsH can generate fixture IMAGE_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -699,7 +722,7 @@ Map { namespace facebook { namespace react { -class ImagePropNativeComponentProps final : public ViewProps { +class JSI_EXPORT ImagePropNativeComponentProps final : public ViewProps { public: ImagePropNativeComponentProps() = default; ImagePropNativeComponentProps(const PropsParserContext& context, const ImagePropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -719,15 +742,16 @@ exports[`GeneratePropsH can generate fixture INSETS_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -735,7 +759,7 @@ Map { namespace facebook { namespace react { -class InsetsPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT InsetsPropNativeComponentProps final : public ViewProps { public: InsetsPropNativeComponentProps() = default; InsetsPropNativeComponentProps(const PropsParserContext& context, const InsetsPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -755,15 +779,16 @@ exports[`GeneratePropsH can generate fixture INT32_ENUM_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include @@ -797,7 +822,7 @@ static inline std::string toString(const Int32EnumPropsNativeComponentMaxInterva } } -class Int32EnumPropsNativeComponentProps final : public ViewProps { +class JSI_EXPORT Int32EnumPropsNativeComponentProps final : public ViewProps { public: Int32EnumPropsNativeComponentProps() = default; Int32EnumPropsNativeComponentProps(const PropsParserContext& context, const Int32EnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -817,22 +842,23 @@ exports[`GeneratePropsH can generate fixture INTEGER_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class IntegerPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT IntegerPropNativeComponentProps final : public ViewProps { public: IntegerPropNativeComponentProps() = default; IntegerPropNativeComponentProps(const PropsParserContext& context, const IntegerPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -854,22 +880,23 @@ exports[`GeneratePropsH can generate fixture INTERFACE_ONLY 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class InterfaceOnlyComponentProps final : public ViewProps { +class JSI_EXPORT InterfaceOnlyComponentProps final : public ViewProps { public: InterfaceOnlyComponentProps() = default; InterfaceOnlyComponentProps(const PropsParserContext& context, const InterfaceOnlyComponentProps &sourceProps, const RawProps &rawProps); @@ -889,15 +916,16 @@ exports[`GeneratePropsH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -907,7 +935,7 @@ Map { namespace facebook { namespace react { -class ImageColorPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT ImageColorPropNativeComponentProps final : public ViewProps { public: ImageColorPropNativeComponentProps() = default; ImageColorPropNativeComponentProps(const PropsParserContext& context, const ImageColorPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -930,22 +958,23 @@ exports[`GeneratePropsH can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class NoPropsNoEventsComponentProps final : public ViewProps { +class JSI_EXPORT NoPropsNoEventsComponentProps final : public ViewProps { public: NoPropsNoEventsComponentProps() = default; NoPropsNoEventsComponentProps(const PropsParserContext& context, const NoPropsNoEventsComponentProps &sourceProps, const RawProps &rawProps); @@ -965,15 +994,16 @@ exports[`GeneratePropsH can generate fixture OBJECT_PROPS 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -1022,11 +1052,11 @@ struct ObjectPropsObjectPropObjectArrayPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropObjectArrayPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto array = map.find(\\"array\\"); - if (array != map.end()) { - fromRawValue(context, array->second, result.array); + auto tmp_array = map.find(\\"array\\"); + if (tmp_array != map.end()) { + fromRawValue(context, tmp_array->second, result.array); } } @@ -1041,19 +1071,19 @@ struct ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto image = map.find(\\"image\\"); - if (image != map.end()) { - fromRawValue(context, image->second, result.image); + auto tmp_image = map.find(\\"image\\"); + if (tmp_image != map.end()) { + fromRawValue(context, tmp_image->second, result.image); } - auto color = map.find(\\"color\\"); - if (color != map.end()) { - fromRawValue(context, color->second, result.color); + auto tmp_color = map.find(\\"color\\"); + if (tmp_color != map.end()) { + fromRawValue(context, tmp_color->second, result.color); } - auto point = map.find(\\"point\\"); - if (point != map.end()) { - fromRawValue(context, point->second, result.point); + auto tmp_point = map.find(\\"point\\"); + if (tmp_point != map.end()) { + fromRawValue(context, tmp_point->second, result.point); } } @@ -1066,11 +1096,11 @@ struct ObjectPropsObjectPropNestedPropANestedPropBStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedPropANestedPropBStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto nestedPropC = map.find(\\"nestedPropC\\"); - if (nestedPropC != map.end()) { - fromRawValue(context, nestedPropC->second, result.nestedPropC); + auto tmp_nestedPropC = map.find(\\"nestedPropC\\"); + if (tmp_nestedPropC != map.end()) { + fromRawValue(context, tmp_nestedPropC->second, result.nestedPropC); } } @@ -1083,11 +1113,11 @@ struct ObjectPropsObjectPropNestedPropAStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedPropAStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto nestedPropB = map.find(\\"nestedPropB\\"); - if (nestedPropB != map.end()) { - fromRawValue(context, nestedPropB->second, result.nestedPropB); + auto tmp_nestedPropB = map.find(\\"nestedPropB\\"); + if (tmp_nestedPropB != map.end()) { + fromRawValue(context, tmp_nestedPropB->second, result.nestedPropB); } } @@ -1100,11 +1130,11 @@ struct ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } } @@ -1127,11 +1157,11 @@ struct ObjectPropsObjectPropNestedArrayAsPropertyStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto arrayProp = map.find(\\"arrayProp\\"); - if (arrayProp != map.end()) { - fromRawValue(context, arrayProp->second, result.arrayProp); + auto tmp_arrayProp = map.find(\\"arrayProp\\"); + if (tmp_arrayProp != map.end()) { + fromRawValue(context, tmp_arrayProp->second, result.arrayProp); } } @@ -1153,54 +1183,54 @@ struct ObjectPropsObjectPropStruct { }; static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ObjectPropsObjectPropStruct &result) { - auto map = (better::map)value; + auto map = (butter::map)value; - auto stringProp = map.find(\\"stringProp\\"); - if (stringProp != map.end()) { - fromRawValue(context, stringProp->second, result.stringProp); + auto tmp_stringProp = map.find(\\"stringProp\\"); + if (tmp_stringProp != map.end()) { + fromRawValue(context, tmp_stringProp->second, result.stringProp); } - auto booleanProp = map.find(\\"booleanProp\\"); - if (booleanProp != map.end()) { - fromRawValue(context, booleanProp->second, result.booleanProp); + auto tmp_booleanProp = map.find(\\"booleanProp\\"); + if (tmp_booleanProp != map.end()) { + fromRawValue(context, tmp_booleanProp->second, result.booleanProp); } - auto floatProp = map.find(\\"floatProp\\"); - if (floatProp != map.end()) { - fromRawValue(context, floatProp->second, result.floatProp); + auto tmp_floatProp = map.find(\\"floatProp\\"); + if (tmp_floatProp != map.end()) { + fromRawValue(context, tmp_floatProp->second, result.floatProp); } - auto intProp = map.find(\\"intProp\\"); - if (intProp != map.end()) { - fromRawValue(context, intProp->second, result.intProp); + auto tmp_intProp = map.find(\\"intProp\\"); + if (tmp_intProp != map.end()) { + fromRawValue(context, tmp_intProp->second, result.intProp); } - auto stringEnumProp = map.find(\\"stringEnumProp\\"); - if (stringEnumProp != map.end()) { - fromRawValue(context, stringEnumProp->second, result.stringEnumProp); + auto tmp_stringEnumProp = map.find(\\"stringEnumProp\\"); + if (tmp_stringEnumProp != map.end()) { + fromRawValue(context, tmp_stringEnumProp->second, result.stringEnumProp); } - auto intEnumProp = map.find(\\"intEnumProp\\"); - if (intEnumProp != map.end()) { - fromRawValue(context, intEnumProp->second, result.intEnumProp); + auto tmp_intEnumProp = map.find(\\"intEnumProp\\"); + if (tmp_intEnumProp != map.end()) { + fromRawValue(context, tmp_intEnumProp->second, result.intEnumProp); } - auto objectArrayProp = map.find(\\"objectArrayProp\\"); - if (objectArrayProp != map.end()) { - fromRawValue(context, objectArrayProp->second, result.objectArrayProp); + auto tmp_objectArrayProp = map.find(\\"objectArrayProp\\"); + if (tmp_objectArrayProp != map.end()) { + fromRawValue(context, tmp_objectArrayProp->second, result.objectArrayProp); } - auto objectPrimitiveRequiredProp = map.find(\\"objectPrimitiveRequiredProp\\"); - if (objectPrimitiveRequiredProp != map.end()) { - fromRawValue(context, objectPrimitiveRequiredProp->second, result.objectPrimitiveRequiredProp); + auto tmp_objectPrimitiveRequiredProp = map.find(\\"objectPrimitiveRequiredProp\\"); + if (tmp_objectPrimitiveRequiredProp != map.end()) { + fromRawValue(context, tmp_objectPrimitiveRequiredProp->second, result.objectPrimitiveRequiredProp); } - auto nestedPropA = map.find(\\"nestedPropA\\"); - if (nestedPropA != map.end()) { - fromRawValue(context, nestedPropA->second, result.nestedPropA); + auto tmp_nestedPropA = map.find(\\"nestedPropA\\"); + if (tmp_nestedPropA != map.end()) { + fromRawValue(context, tmp_nestedPropA->second, result.nestedPropA); } - auto nestedArrayAsProperty = map.find(\\"nestedArrayAsProperty\\"); - if (nestedArrayAsProperty != map.end()) { - fromRawValue(context, nestedArrayAsProperty->second, result.nestedArrayAsProperty); + auto tmp_nestedArrayAsProperty = map.find(\\"nestedArrayAsProperty\\"); + if (tmp_nestedArrayAsProperty != map.end()) { + fromRawValue(context, tmp_nestedArrayAsProperty->second, result.nestedArrayAsProperty); } } static inline std::string toString(const ObjectPropsObjectPropStruct &value) { return \\"[Object ObjectPropsObjectPropStruct]\\"; } -class ObjectPropsProps final : public ViewProps { +class JSI_EXPORT ObjectPropsProps final : public ViewProps { public: ObjectPropsProps() = default; ObjectPropsProps(const PropsParserContext& context, const ObjectPropsProps &sourceProps, const RawProps &rawProps); @@ -1220,15 +1250,16 @@ exports[`GeneratePropsH can generate fixture POINT_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include #include @@ -1236,7 +1267,7 @@ Map { namespace facebook { namespace react { -class PointPropNativeComponentProps final : public ViewProps { +class JSI_EXPORT PointPropNativeComponentProps final : public ViewProps { public: PointPropNativeComponentProps() = default; PointPropNativeComponentProps(const PropsParserContext& context, const PointPropNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -1256,15 +1287,16 @@ exports[`GeneratePropsH can generate fixture STRING_ENUM_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include @@ -1289,7 +1321,7 @@ static inline std::string toString(const StringEnumPropsNativeComponentAlignment } } -class StringEnumPropsNativeComponentProps final : public ViewProps { +class JSI_EXPORT StringEnumPropsNativeComponentProps final : public ViewProps { public: StringEnumPropsNativeComponentProps() = default; StringEnumPropsNativeComponentProps(const PropsParserContext& context, const StringEnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); @@ -1309,22 +1341,23 @@ exports[`GeneratePropsH can generate fixture STRING_PROP 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class StringPropComponentProps final : public ViewProps { +class JSI_EXPORT StringPropComponentProps final : public ViewProps { public: StringPropComponentProps() = default; StringPropComponentProps(const PropsParserContext& context, const StringPropComponentProps &sourceProps, const RawProps &rawProps); @@ -1345,22 +1378,23 @@ exports[`GeneratePropsH can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class MultiFile1NativeComponentProps final : public ViewProps { +class JSI_EXPORT MultiFile1NativeComponentProps final : public ViewProps { public: MultiFile1NativeComponentProps() = default; MultiFile1NativeComponentProps(const PropsParserContext& context, const MultiFile1NativeComponentProps &sourceProps, const RawProps &rawProps); @@ -1370,7 +1404,7 @@ class MultiFile1NativeComponentProps final : public ViewProps { bool disabled{false}; }; -class MultiFile2NativeComponentProps final : public ViewProps { +class JSI_EXPORT MultiFile2NativeComponentProps final : public ViewProps { public: MultiFile2NativeComponentProps() = default; MultiFile2NativeComponentProps(const PropsParserContext& context, const MultiFile2NativeComponentProps &sourceProps, const RawProps &rawProps); @@ -1390,22 +1424,23 @@ exports[`GeneratePropsH can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "Props.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GeneratePropsH.js */ #pragma once +#include #include #include namespace facebook { namespace react { -class MultiComponent1NativeComponentProps final : public ViewProps { +class JSI_EXPORT MultiComponent1NativeComponentProps final : public ViewProps { public: MultiComponent1NativeComponentProps() = default; MultiComponent1NativeComponentProps(const PropsParserContext& context, const MultiComponent1NativeComponentProps &sourceProps, const RawProps &rawProps); @@ -1415,7 +1450,7 @@ class MultiComponent1NativeComponentProps final : public ViewProps { bool disabled{false}; }; -class MultiComponent2NativeComponentProps final : public ViewProps { +class JSI_EXPORT MultiComponent2NativeComponentProps final : public ViewProps { public: MultiComponent2NativeComponentProps() = default; MultiComponent2NativeComponentProps(const PropsParserContext& context, const MultiComponent2NativeComponentProps &sourceProps, const RawProps &rawProps); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 2b062c4f906bc0..9cd5fb54c8afbc 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -3,10 +3,10 @@ exports[`GeneratePropsJavaDelegate can generate fixture ARRAY_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/ArrayPropsNativeComponentManagerDelegate.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -71,10 +71,10 @@ public class ArrayPropsNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -109,10 +109,10 @@ public class ArrayPropsNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -146,10 +146,10 @@ public class BooleanPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -184,10 +184,10 @@ public class ColorPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -228,10 +228,10 @@ public class CommandNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -278,10 +278,10 @@ public class CommandNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -330,10 +330,10 @@ public class DoublePropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -367,10 +367,10 @@ public class EventsNestedObjectNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -404,10 +404,10 @@ public class EventsNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -439,10 +439,10 @@ exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_ANDROID_IOS 1`] exports[`GeneratePropsJavaDelegate can generate fixture FLOAT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerDelegate.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -491,10 +491,10 @@ public class FloatPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -529,10 +529,10 @@ public class ImagePropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -567,10 +567,10 @@ public class InsetsPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -604,10 +604,10 @@ public class Int32EnumPropsNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -647,10 +647,10 @@ public class IntegerPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -684,10 +684,10 @@ public class InterfaceOnlyComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -732,10 +732,10 @@ public class ImageColorPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -763,10 +763,10 @@ public class NoPropsNoEventsComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -801,10 +801,10 @@ public class ObjectPropsManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -839,10 +839,10 @@ public class PointPropNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -876,10 +876,10 @@ public class StringEnumPropsNativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -916,10 +916,10 @@ public class StringPropComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -948,10 +948,10 @@ public class MultiFile1NativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -985,10 +985,10 @@ public class MultiFile2NativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ @@ -1017,10 +1017,10 @@ public class MultiComponent1NativeComponentManagerDelegate "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaDelegate.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 2add98876ce447..550da64c73b085 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -3,10 +3,10 @@ exports[`GeneratePropsJavaInterface can generate fixture ARRAY_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/ArrayPropsNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -37,10 +37,10 @@ public interface ArrayPropsNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` Map { "java/com/facebook/react/viewmanagers/ArrayPropsNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -61,10 +61,10 @@ public interface ArrayPropsNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture BOOLEAN_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/BooleanPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -83,10 +83,10 @@ public interface BooleanPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture COLOR_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ColorPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -106,10 +106,10 @@ public interface ColorPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture COMMANDS 1`] = ` Map { "java/com/facebook/react/viewmanagers/CommandNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -130,10 +130,10 @@ public interface CommandNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/CommandNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -155,10 +155,10 @@ public interface CommandNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture DOUBLE_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/DoublePropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -182,10 +182,10 @@ public interface DoublePropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/EventsNestedObjectNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -204,10 +204,10 @@ public interface EventsNestedObjectNativeComponentManagerInterface "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -226,10 +226,10 @@ public interface EventsNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "java/com/facebook/react/viewmanagers/InterfaceOnlyComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -252,10 +252,10 @@ exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID_IOS 1`] exports[`GeneratePropsJavaInterface can generate fixture FLOAT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -279,10 +279,10 @@ public interface FloatPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture IMAGE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ImagePropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -303,10 +303,10 @@ public interface ImagePropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture INSETS_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/InsetsPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -327,10 +327,10 @@ public interface InsetsPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture INT32_ENUM_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Int32EnumPropsNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -350,10 +350,10 @@ public interface Int32EnumPropsNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture INTEGER_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/IntegerPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -374,10 +374,10 @@ public interface IntegerPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture INTERFACE_ONLY 1`] = ` Map { "java/com/facebook/react/viewmanagers/InterfaceOnlyComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -397,10 +397,10 @@ public interface InterfaceOnlyComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ImageColorPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -424,10 +424,10 @@ public interface ImageColorPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "java/com/facebook/react/viewmanagers/NoPropsNoEventsComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -446,10 +446,10 @@ public interface NoPropsNoEventsComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture OBJECT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/ObjectPropsManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -470,10 +470,10 @@ public interface ObjectPropsManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture POINT_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/PointPropNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -494,10 +494,10 @@ public interface PointPropNativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture STRING_ENUM_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/StringEnumPropsNativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -517,10 +517,10 @@ public interface StringEnumPropsNativeComponentManagerInterface exports[`GeneratePropsJavaInterface can generate fixture STRING_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/StringPropComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -541,10 +541,10 @@ public interface StringPropComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { "java/com/facebook/react/viewmanagers/MultiFile1NativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -558,10 +558,10 @@ public interface MultiFile1NativeComponentManagerInterface { } ", "java/com/facebook/react/viewmanagers/MultiFile2NativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -580,10 +580,10 @@ public interface MultiFile2NativeComponentManagerInterface { exports[`GeneratePropsJavaInterface can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "java/com/facebook/react/viewmanagers/MultiComponent1NativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ @@ -597,10 +597,10 @@ public interface MultiComponent1NativeComponentManagerInterface } ", "java/com/facebook/react/viewmanagers/MultiComponent2NativeComponentManagerInterface.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. * * @generated by codegen project: GeneratePropsJavaInterface.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap index bc6b90358a268a..25f4abc590c274 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap @@ -3,7 +3,7 @@ exports[`GeneratePropsJavaPojo can generate fixture ARRAY_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsObjectElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -26,7 +26,7 @@ public class ArrayPropsNativeComponentPropsObjectElement { } ", "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayElementObjectElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -49,7 +49,7 @@ public class ArrayPropsNativeComponentPropsArrayElementObjectElement { } ", "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -72,7 +72,7 @@ public class ArrayPropsNativeComponentPropsArrayElement { } ", "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayOfArrayOfObjectElementElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -95,7 +95,7 @@ public class ArrayPropsNativeComponentPropsArrayOfArrayOfObjectElementElement { } ", "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -174,7 +174,7 @@ public class ArrayPropsNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` Map { "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsNativePrimitivesElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -208,7 +208,7 @@ public class ArrayPropsNativeComponentPropsNativePrimitivesElement { } ", "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -236,7 +236,7 @@ public class ArrayPropsNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture BOOLEAN_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/BooleanPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -263,7 +263,7 @@ public class BooleanPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture COLOR_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/ColorPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -291,7 +291,7 @@ public class ColorPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture COMMANDS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/CommandNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -315,7 +315,7 @@ public class CommandNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/CommandNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -343,7 +343,7 @@ public class CommandNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture DOUBLE_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/DoublePropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -395,7 +395,7 @@ public class DoublePropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/EventsNestedObjectNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -422,7 +422,7 @@ public class EventsNestedObjectNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture EVENT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/EventsNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -449,7 +449,7 @@ public class EventsNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/InterfaceOnlyComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -477,7 +477,7 @@ exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID_IOS 1`] = `M exports[`GeneratePropsJavaPojo can generate fixture FLOAT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/FloatPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -529,7 +529,7 @@ public class FloatPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture IMAGE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Slider/ImagePropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -558,7 +558,7 @@ public class ImagePropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture INSETS_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ScrollView/InsetsPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -587,7 +587,7 @@ public class InsetsPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture INT32_ENUM_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/Int32EnumPropsNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -615,7 +615,7 @@ public class Int32EnumPropsNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture INTEGER_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/IntegerPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -652,7 +652,7 @@ public class IntegerPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture INTERFACE_ONLY 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/InterfaceOnlyComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -680,7 +680,7 @@ public class InterfaceOnlyComponentProps { exports[`GeneratePropsJavaPojo can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Slider/ImageColorPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -724,7 +724,7 @@ public class ImageColorPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "java/com/facebook/react/viewmanagers/NoPropsNoEvents/NoPropsNoEventsComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -748,7 +748,7 @@ public class NoPropsNoEventsComponentProps { exports[`GeneratePropsJavaPojo can generate fixture OBJECT_PROPS 1`] = ` Map { "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropObjectArrayProp.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -771,7 +771,7 @@ public class ObjectPropsPropsObjectPropObjectArrayProp { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -805,7 +805,7 @@ public class ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedPropANestedPropB.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -828,7 +828,7 @@ public class ObjectPropsPropsObjectPropNestedPropANestedPropB { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedPropA.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -850,7 +850,7 @@ public class ObjectPropsPropsObjectPropNestedPropA { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedArrayAsPropertyArrayPropElement.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -873,7 +873,7 @@ public class ObjectPropsPropsObjectPropNestedArrayAsPropertyArrayPropElement { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedArrayAsProperty.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -896,7 +896,7 @@ public class ObjectPropsPropsObjectPropNestedArrayAsProperty { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectProp.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -964,7 +964,7 @@ public class ObjectPropsPropsObjectProp { } ", "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -991,7 +991,7 @@ public class ObjectPropsProps { exports[`GeneratePropsJavaPojo can generate fixture POINT_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/PointPropNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1020,7 +1020,7 @@ public class PointPropNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture STRING_ENUM_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/StringEnumPropsNativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1048,7 +1048,7 @@ public class StringEnumPropsNativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture STRING_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Switch/StringPropComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1081,7 +1081,7 @@ public class StringPropComponentProps { exports[`GeneratePropsJavaPojo can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { "java/com/facebook/react/viewmanagers/ComponentFile1/MultiFile1NativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1103,7 +1103,7 @@ public class MultiFile1NativeComponentProps { } ", "java/com/facebook/react/viewmanagers/ComponentFile2/MultiFile2NativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1130,7 +1130,7 @@ public class MultiFile2NativeComponentProps { exports[`GeneratePropsJavaPojo can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "java/com/facebook/react/viewmanagers/MyComponents/MultiComponent1NativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. @@ -1152,7 +1152,7 @@ public class MultiComponent1NativeComponentProps { } ", "java/com/facebook/react/viewmanagers/MyComponents/MultiComponent2NativeComponentProps.java" => "/** -* Copyright (c) Facebook, Inc. and its affiliates. +* 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. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap index f953c291ba49a7..028d4fcbde9517 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateShadowNodeCpp can generate fixture ARRAY_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -29,10 +29,10 @@ exports[`GenerateShadowNodeCpp can generate fixture ARRAY_PROPS_WITH_NESTED_OBJE Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -54,10 +54,10 @@ exports[`GenerateShadowNodeCpp can generate fixture BOOLEAN_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -79,10 +79,10 @@ exports[`GenerateShadowNodeCpp can generate fixture COLOR_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -104,10 +104,10 @@ exports[`GenerateShadowNodeCpp can generate fixture COMMANDS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -129,10 +129,10 @@ exports[`GenerateShadowNodeCpp can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -154,10 +154,10 @@ exports[`GenerateShadowNodeCpp can generate fixture DOUBLE_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -179,10 +179,10 @@ exports[`GenerateShadowNodeCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -204,10 +204,10 @@ exports[`GenerateShadowNodeCpp can generate fixture EVENT_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -229,10 +229,10 @@ exports[`GenerateShadowNodeCpp can generate fixture EVENTS_WITH_PAPER_NAME 1`] = Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -254,10 +254,10 @@ exports[`GenerateShadowNodeCpp can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -279,10 +279,10 @@ exports[`GenerateShadowNodeCpp can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -304,10 +304,10 @@ exports[`GenerateShadowNodeCpp can generate fixture FLOAT_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -329,10 +329,10 @@ exports[`GenerateShadowNodeCpp can generate fixture IMAGE_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -354,10 +354,10 @@ exports[`GenerateShadowNodeCpp can generate fixture INSETS_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -379,10 +379,10 @@ exports[`GenerateShadowNodeCpp can generate fixture INT32_ENUM_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -404,10 +404,10 @@ exports[`GenerateShadowNodeCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -429,10 +429,10 @@ exports[`GenerateShadowNodeCpp can generate fixture INTERFACE_ONLY 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -454,10 +454,10 @@ exports[`GenerateShadowNodeCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -479,10 +479,10 @@ exports[`GenerateShadowNodeCpp can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -504,10 +504,10 @@ exports[`GenerateShadowNodeCpp can generate fixture OBJECT_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -529,10 +529,10 @@ exports[`GenerateShadowNodeCpp can generate fixture POINT_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -554,10 +554,10 @@ exports[`GenerateShadowNodeCpp can generate fixture STRING_ENUM_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -579,10 +579,10 @@ exports[`GenerateShadowNodeCpp can generate fixture STRING_PROP 1`] = ` Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -604,10 +604,10 @@ exports[`GenerateShadowNodeCpp can generate fixture TWO_COMPONENTS_DIFFERENT_FIL Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ @@ -630,10 +630,10 @@ exports[`GenerateShadowNodeCpp can generate fixture TWO_COMPONENTS_SAME_FILE 1`] Map { "ShadowNodes.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeCpp.js */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap index bb34cfbab42793..25deb9ca84275e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateShadowNodeH can generate fixture ARRAY_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -16,11 +16,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ArrayPropsNativeComponentComponentName[]; +JSI_EXPORT extern const char ArrayPropsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -39,10 +40,10 @@ exports[`GenerateShadowNodeH can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -51,11 +52,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ArrayPropsNativeComponentComponentName[]; +JSI_EXPORT extern const char ArrayPropsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -74,10 +76,10 @@ exports[`GenerateShadowNodeH can generate fixture BOOLEAN_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -86,11 +88,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char BooleanPropNativeComponentComponentName[]; +JSI_EXPORT extern const char BooleanPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -109,10 +112,10 @@ exports[`GenerateShadowNodeH can generate fixture COLOR_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -121,11 +124,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ColorPropNativeComponentComponentName[]; +JSI_EXPORT extern const char ColorPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -144,10 +148,10 @@ exports[`GenerateShadowNodeH can generate fixture COMMANDS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -156,11 +160,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char CommandNativeComponentComponentName[]; +JSI_EXPORT extern const char CommandNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -179,10 +184,10 @@ exports[`GenerateShadowNodeH can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -191,11 +196,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char CommandNativeComponentComponentName[]; +JSI_EXPORT extern const char CommandNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -214,10 +220,10 @@ exports[`GenerateShadowNodeH can generate fixture DOUBLE_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -226,11 +232,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char DoublePropNativeComponentComponentName[]; +JSI_EXPORT extern const char DoublePropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -249,10 +256,10 @@ exports[`GenerateShadowNodeH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -262,11 +269,12 @@ Map { #include #include #include +#include namespace facebook { namespace react { -extern const char EventsNestedObjectNativeComponentComponentName[]; +JSI_EXPORT extern const char EventsNestedObjectNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -286,10 +294,10 @@ exports[`GenerateShadowNodeH can generate fixture EVENT_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -299,11 +307,12 @@ Map { #include #include #include +#include namespace facebook { namespace react { -extern const char EventsNativeComponentComponentName[]; +JSI_EXPORT extern const char EventsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -323,10 +332,10 @@ exports[`GenerateShadowNodeH can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -335,6 +344,7 @@ Map { #include #include +#include namespace facebook { namespace react { @@ -351,10 +361,10 @@ exports[`GenerateShadowNodeH can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -363,11 +373,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ExcludedAndroidComponentComponentName[]; +JSI_EXPORT extern const char ExcludedAndroidComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -386,10 +397,10 @@ exports[`GenerateShadowNodeH can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -398,11 +409,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ExcludedAndroidIosComponentComponentName[]; +JSI_EXPORT extern const char ExcludedAndroidIosComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -421,10 +433,10 @@ exports[`GenerateShadowNodeH can generate fixture FLOAT_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -433,11 +445,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char FloatPropNativeComponentComponentName[]; +JSI_EXPORT extern const char FloatPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -456,10 +469,10 @@ exports[`GenerateShadowNodeH can generate fixture IMAGE_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -468,11 +481,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ImagePropNativeComponentComponentName[]; +JSI_EXPORT extern const char ImagePropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -491,10 +505,10 @@ exports[`GenerateShadowNodeH can generate fixture INSETS_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -503,11 +517,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char InsetsPropNativeComponentComponentName[]; +JSI_EXPORT extern const char InsetsPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -526,10 +541,10 @@ exports[`GenerateShadowNodeH can generate fixture INT32_ENUM_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -538,11 +553,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char Int32EnumPropsNativeComponentComponentName[]; +JSI_EXPORT extern const char Int32EnumPropsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -561,10 +577,10 @@ exports[`GenerateShadowNodeH can generate fixture INTEGER_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -573,11 +589,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char IntegerPropNativeComponentComponentName[]; +JSI_EXPORT extern const char IntegerPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -596,10 +613,10 @@ exports[`GenerateShadowNodeH can generate fixture INTERFACE_ONLY 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -608,6 +625,7 @@ Map { #include #include +#include namespace facebook { namespace react { @@ -624,10 +642,10 @@ exports[`GenerateShadowNodeH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -636,11 +654,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ImageColorPropNativeComponentComponentName[]; +JSI_EXPORT extern const char ImageColorPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -659,10 +678,10 @@ exports[`GenerateShadowNodeH can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -671,11 +690,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char NoPropsNoEventsComponentComponentName[]; +JSI_EXPORT extern const char NoPropsNoEventsComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -694,10 +714,10 @@ exports[`GenerateShadowNodeH can generate fixture OBJECT_PROPS 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -706,11 +726,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char ObjectPropsComponentName[]; +JSI_EXPORT extern const char ObjectPropsComponentName[]; /* * \`ShadowNode\` for component. @@ -729,10 +750,10 @@ exports[`GenerateShadowNodeH can generate fixture POINT_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -741,11 +762,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char PointPropNativeComponentComponentName[]; +JSI_EXPORT extern const char PointPropNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -764,10 +786,10 @@ exports[`GenerateShadowNodeH can generate fixture STRING_ENUM_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -776,11 +798,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char StringEnumPropsNativeComponentComponentName[]; +JSI_EXPORT extern const char StringEnumPropsNativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -799,10 +822,10 @@ exports[`GenerateShadowNodeH can generate fixture STRING_PROP 1`] = ` Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -811,11 +834,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char StringPropComponentComponentName[]; +JSI_EXPORT extern const char StringPropComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -834,10 +858,10 @@ exports[`GenerateShadowNodeH can generate fixture TWO_COMPONENTS_DIFFERENT_FILES Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -846,11 +870,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char MultiFile1NativeComponentComponentName[]; +JSI_EXPORT extern const char MultiFile1NativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -859,7 +884,7 @@ using MultiFile1NativeComponentShadowNode = ConcreteViewShadowNode< MultiFile1NativeComponentComponentName, MultiFile1NativeComponentProps>; -extern const char MultiFile2NativeComponentComponentName[]; +JSI_EXPORT extern const char MultiFile2NativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -878,10 +903,10 @@ exports[`GenerateShadowNodeH can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = Map { "ShadowNodes.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateShadowNodeH.js */ @@ -890,11 +915,12 @@ Map { #include #include +#include namespace facebook { namespace react { -extern const char MultiComponent1NativeComponentComponentName[]; +JSI_EXPORT extern const char MultiComponent1NativeComponentComponentName[]; /* * \`ShadowNode\` for component. @@ -903,7 +929,7 @@ using MultiComponent1NativeComponentShadowNode = ConcreteViewShadowNode< MultiComponent1NativeComponentComponentName, MultiComponent1NativeComponentProps>; -extern const char MultiComponent2NativeComponentComponentName[]; +JSI_EXPORT extern const char MultiComponent2NativeComponentComponentName[]; /* * \`ShadowNode\` for component. diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index a7981270dcde24..14a07e9534c015 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -3,10 +3,10 @@ exports[`GenerateTests can generate fixture ARRAY_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -39,10 +39,10 @@ TEST(ArrayPropsNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -74,10 +74,10 @@ TEST(ArrayPropsNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture BOOLEAN_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -122,10 +122,10 @@ TEST(BooleanPropNativeComponentProps_disabled, etc) { exports[`GenerateTests can generate fixture COLOR_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -170,10 +170,10 @@ TEST(ColorPropNativeComponentProps_tintColor, etc) { exports[`GenerateTests can generate fixture COMMANDS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -205,10 +205,10 @@ TEST(CommandNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -253,10 +253,10 @@ TEST(CommandNativeComponentProps_accessibilityHint, etc) { exports[`GenerateTests can generate fixture DOUBLE_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -288,10 +288,10 @@ TEST(DoublePropNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -336,10 +336,10 @@ TEST(EventsNestedObjectNativeComponentProps_disabled, etc) { exports[`GenerateTests can generate fixture EVENT_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -384,10 +384,10 @@ TEST(EventsNativeComponentProps_disabled, etc) { exports[`GenerateTests can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -419,10 +419,10 @@ TEST(InterfaceOnlyComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -454,10 +454,10 @@ TEST(ExcludedAndroidComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -489,10 +489,10 @@ TEST(ExcludedAndroidIosComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture FLOAT_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -602,10 +602,10 @@ TEST(FloatPropNativeComponentProps_blurRadius6, etc) { exports[`GenerateTests can generate fixture IMAGE_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -651,10 +651,10 @@ TEST(ImagePropNativeComponentProps_thumbImage, etc) { exports[`GenerateTests can generate fixture INSETS_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -686,10 +686,10 @@ TEST(InsetsPropNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture INT32_ENUM_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -721,10 +721,10 @@ TEST(Int32EnumPropsNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture INTEGER_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -756,10 +756,10 @@ TEST(IntegerPropNativeComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture INTERFACE_ONLY 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -804,10 +804,10 @@ TEST(InterfaceOnlyComponentProps_accessibilityHint, etc) { exports[`GenerateTests can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -892,10 +892,10 @@ TEST(ImageColorPropNativeComponentProps_point, etc) { exports[`GenerateTests can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -927,10 +927,10 @@ TEST(NoPropsNoEventsComponentProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture OBJECT_PROPS 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -963,10 +963,10 @@ TEST(ObjectPropsProps_DoesNotDie, etc) { exports[`GenerateTests can generate fixture POINT_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -1011,10 +1011,10 @@ TEST(PointPropNativeComponentProps_startPoint, etc) { exports[`GenerateTests can generate fixture STRING_ENUM_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -1085,10 +1085,10 @@ TEST(StringEnumPropsNativeComponentProps_alignment_BottomRight, etc) { exports[`GenerateTests can generate fixture STRING_PROP 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -1146,10 +1146,10 @@ TEST(StringPropComponentProps_accessibilityRole, etc) { exports[`GenerateTests can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ @@ -1220,10 +1220,10 @@ TEST(MultiFile2NativeComponentProps_disabled, etc) { exports[`GenerateTests can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "Tests.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateTests.js * */ diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap index 223fb9f34cb3ff..46ad5bcb81a667 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateThirdPartyFabricComponentsProviderH can generate fixtures 1`] = Map { "RCTThirdPartyFabricComponentsProvider.h" => " /* - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by GenerateRCTThirdPartyFabricComponentsProviderH */ @@ -24,7 +24,7 @@ extern \\"C\\" { Class RCTThirdPartyFabricComponentsProvider(const char *name); Class NoPropsNoEventsComponentCls(void) __attribute__((used)); // NO_PROPS_NO_EVENTS - +Class InterfaceOnlyComponentCls(void) __attribute__((used)); // INTERFACE_ONLY Class BooleanPropNativeComponentCls(void) __attribute__((used)); // BOOLEAN_PROP Class StringPropComponentCls(void) __attribute__((used)); // STRING_PROP Class IntegerPropNativeComponentCls(void) __attribute__((used)); // INTEGER_PROPS @@ -41,7 +41,7 @@ Class ImageColorPropNativeComponentCls(void) __attribu Class StringEnumPropsNativeComponentCls(void) __attribute__((used)); // STRING_ENUM_PROP Class Int32EnumPropsNativeComponentCls(void) __attribute__((used)); // INT32_ENUM_PROP Class EventsNativeComponentCls(void) __attribute__((used)); // EVENT_PROPS - +Class InterfaceOnlyComponentCls(void) __attribute__((used)); // EVENTS_WITH_PAPER_NAME Class EventsNestedObjectNativeComponentCls(void) __attribute__((used)); // EVENT_NESTED_OBJECT_PROPS Class MultiComponent1NativeComponentCls(void) __attribute__((used)); // TWO_COMPONENTS_SAME_FILE Class MultiComponent2NativeComponentCls(void) __attribute__((used)); // TWO_COMPONENTS_SAME_FILE diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap index bd0191208ac480..fd1ed66715440d 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateThirdPartyFabricComponentsProviderObjCpp can generate fixtures Map { "RCTThirdPartyFabricComponentsProvider.mm" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by GenerateRCTThirdPartyFabricComponentsProviderCpp */ @@ -24,6 +24,7 @@ Class RCTThirdPartyFabricComponentsProvider(const char {\\"NoPropsNoEventsComponent\\", NoPropsNoEventsComponentCls}, // NO_PROPS_NO_EVENTS + {\\"InterfaceOnlyComponent\\", InterfaceOnlyComponentCls}, // INTERFACE_ONLY {\\"BooleanPropNativeComponent\\", BooleanPropNativeComponentCls}, // BOOLEAN_PROP @@ -57,6 +58,7 @@ Class RCTThirdPartyFabricComponentsProvider(const char {\\"EventsNativeComponent\\", EventsNativeComponentCls}, // EVENT_PROPS + {\\"InterfaceOnlyComponent\\", InterfaceOnlyComponentCls}, // EVENTS_WITH_PAPER_NAME {\\"EventsNestedObjectNativeComponent\\", EventsNestedObjectNativeComponentCls}, // EVENT_NESTED_OBJECT_PROPS diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index 2bb735544c8835..f4c068dcb2802e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -4,10 +4,10 @@ exports[`GenerateViewConfigJs can generate fixture ARRAY_PROPS 1`] = ` Map { "ARRAY_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -20,7 +20,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ArrayPropsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ArrayPropsNativeComponent', validAttributes: { @@ -40,7 +41,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ array: true, arrayOfArrayOfObject: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -49,10 +52,10 @@ exports[`GenerateViewConfigJs can generate fixture ARRAY_PROPS_WITH_NESTED_OBJEC Map { "ARRAY_PROPS_WITH_NESTED_OBJECTNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -65,13 +68,16 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ArrayPropsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ArrayPropsNativeComponent', validAttributes: { nativePrimitives: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -80,10 +86,10 @@ exports[`GenerateViewConfigJs can generate fixture BOOLEAN_PROP 1`] = ` Map { "BOOLEAN_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -96,13 +102,16 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'BooleanPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'BooleanPropNativeComponent', validAttributes: { disabled: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -111,10 +120,10 @@ exports[`GenerateViewConfigJs can generate fixture COLOR_PROP 1`] = ` Map { "COLOR_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -127,7 +136,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ColorPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ColorPropNativeComponent', validAttributes: { @@ -135,7 +145,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ process: require('react-native/Libraries/StyleSheet/processColor'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -144,10 +156,10 @@ exports[`GenerateViewConfigJs can generate fixture COMMANDS 1`] = ` Map { "COMMANDSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -161,10 +173,13 @@ const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/React let nativeComponentName = 'CommandNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'CommandNativeComponent', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); export const Commands = { flashScrollIndicators(ref) { @@ -183,10 +198,10 @@ exports[`GenerateViewConfigJs can generate fixture COMMANDS_AND_PROPS 1`] = ` Map { "COMMANDS_AND_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -200,13 +215,16 @@ const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/React let nativeComponentName = 'CommandNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'CommandNativeComponent', validAttributes: { accessibilityHint: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); export const Commands = { handleRootTag(ref, rootTag) { @@ -225,10 +243,10 @@ exports[`GenerateViewConfigJs can generate fixture DOUBLE_PROPS 1`] = ` Map { "DOUBLE_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -241,7 +259,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'DoublePropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'DoublePropNativeComponent', validAttributes: { @@ -252,7 +271,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ blurRadius5: true, blurRadius6: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -261,10 +282,10 @@ exports[`GenerateViewConfigJs can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] Map { "EVENT_NESTED_OBJECT_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -274,10 +295,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'EventsNestedObjectNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EventsNestedObjectNativeComponent', bubblingEventTypes: { @@ -291,9 +314,14 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ validAttributes: { disabled: true, - onChange: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -302,10 +330,10 @@ exports[`GenerateViewConfigJs can generate fixture EVENT_PROPS 1`] = ` Map { "EVENT_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -315,10 +343,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'EventsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'EventsNativeComponent', bubblingEventTypes: { @@ -349,12 +379,17 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ validAttributes: { disabled: true, - onChange: true, - onEventDirect: true, - onOrientationChange: true, - onEnd: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + onEventDirect: true, + onOrientationChange: true, + onEnd: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -363,10 +398,10 @@ exports[`GenerateViewConfigJs can generate fixture EVENTS_WITH_PAPER_NAME 1`] = Map { "EVENTS_WITH_PAPER_NAMENativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -376,10 +411,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'RCTInterfaceOnlyComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'RCTInterfaceOnlyComponent', bubblingEventTypes: { @@ -389,30 +426,23 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ bubbled: 'onChange', }, }, - - topChange: { - phasedRegistrationNames: { - captured: 'onChangeCapture', - bubbled: 'onChange', - }, - }, }, directEventTypes: { paperDirectChange: { registrationName: 'onDire tChange', }, - - topDire tChange: { - registrationName: 'onDire tChange', - }, }, validAttributes: { - onChange: true, - onDire tChange: true, + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + onDire tChange: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -421,10 +451,10 @@ exports[`GenerateViewConfigJs can generate fixture EXCLUDE_ANDROID 1`] = ` Map { "EXCLUDE_ANDROIDNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -437,10 +467,13 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ExcludedAndroidComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ExcludedAndroidComponent', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -449,10 +482,10 @@ exports[`GenerateViewConfigJs can generate fixture EXCLUDE_ANDROID_IOS 1`] = ` Map { "EXCLUDE_ANDROID_IOSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -465,10 +498,13 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ExcludedAndroidIosComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ExcludedAndroidIosComponent', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -477,10 +513,10 @@ exports[`GenerateViewConfigJs can generate fixture FLOAT_PROPS 1`] = ` Map { "FLOAT_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -493,7 +529,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'FloatPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'FloatPropNativeComponent', validAttributes: { @@ -504,7 +541,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ blurRadius5: true, blurRadius6: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -513,10 +552,10 @@ exports[`GenerateViewConfigJs can generate fixture IMAGE_PROP 1`] = ` Map { "IMAGE_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -529,7 +568,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ImagePropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ImagePropNativeComponent', validAttributes: { @@ -537,7 +577,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ process: require('react-native/Libraries/Image/resolveAssetSource'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -546,10 +588,10 @@ exports[`GenerateViewConfigJs can generate fixture INSETS_PROP 1`] = ` Map { "INSETS_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -562,7 +604,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'InsetsPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'InsetsPropNativeComponent', validAttributes: { @@ -570,7 +613,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ diff: require('react-native/Libraries/Utilities/differ/insetsDiffer'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -579,10 +624,10 @@ exports[`GenerateViewConfigJs can generate fixture INT32_ENUM_PROP 1`] = ` Map { "INT32_ENUM_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -595,13 +640,16 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'Int32EnumPropsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'Int32EnumPropsNativeComponent', validAttributes: { maxInterval: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -610,10 +658,10 @@ exports[`GenerateViewConfigJs can generate fixture INTEGER_PROPS 1`] = ` Map { "INTEGER_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -626,7 +674,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'IntegerPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'IntegerPropNativeComponent', validAttributes: { @@ -634,7 +683,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ progress2: true, progress3: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -643,10 +694,10 @@ exports[`GenerateViewConfigJs can generate fixture INTERFACE_ONLY 1`] = ` Map { "INTERFACE_ONLYNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -656,10 +707,12 @@ Map { 'use strict'; const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); +const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore'); let nativeComponentName = 'RCTInterfaceOnlyComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'RCTInterfaceOnlyComponent', bubblingEventTypes: { @@ -673,9 +726,14 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ validAttributes: { accessibilityHint: true, - onChange: true, + + ...ConditionallyIgnoredEventHandlers({ + onChange: true, + }), }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -684,10 +742,10 @@ exports[`GenerateViewConfigJs can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "MULTI_NATIVE_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -700,7 +758,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ImageColorPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ImageColorPropNativeComponent', validAttributes: { @@ -720,7 +779,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ diff: require('react-native/Libraries/Utilities/differ/pointsDiffer'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -729,10 +790,10 @@ exports[`GenerateViewConfigJs can generate fixture NO_PROPS_NO_EVENTS 1`] = ` Map { "NO_PROPS_NO_EVENTSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -745,10 +806,13 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'NoPropsNoEventsComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'NoPropsNoEventsComponent', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -757,10 +821,10 @@ exports[`GenerateViewConfigJs can generate fixture OBJECT_PROPS 1`] = ` Map { "OBJECT_PROPSNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -773,13 +837,16 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'ObjectProps'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'ObjectProps', validAttributes: { objectProp: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -788,10 +855,10 @@ exports[`GenerateViewConfigJs can generate fixture POINT_PROP 1`] = ` Map { "POINT_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -804,7 +871,8 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'PointPropNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'PointPropNativeComponent', validAttributes: { @@ -812,7 +880,9 @@ export default NativeComponentRegistry.get(nativeComponentName, () => ({ diff: require('react-native/Libraries/Utilities/differ/pointsDiffer'), }, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -821,10 +891,10 @@ exports[`GenerateViewConfigJs can generate fixture STRING_ENUM_PROP 1`] = ` Map { "STRING_ENUM_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -837,13 +907,16 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'StringEnumPropsNativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'StringEnumPropsNativeComponent', validAttributes: { alignment: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -852,10 +925,10 @@ exports[`GenerateViewConfigJs can generate fixture STRING_PROP 1`] = ` Map { "STRING_PROPNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -868,14 +941,17 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'StringPropComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'StringPropComponent', validAttributes: { accessibilityHint: true, accessibilityRole: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -884,10 +960,10 @@ exports[`GenerateViewConfigJs can generate fixture TWO_COMPONENTS_DIFFERENT_FILE Map { "TWO_COMPONENTS_DIFFERENT_FILESNativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -900,23 +976,29 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'MultiFile1NativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'MultiFile1NativeComponent', validAttributes: { disabled: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); let nativeComponentName = 'MultiFile2NativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'MultiFile2NativeComponent', validAttributes: { disabled: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -925,10 +1007,10 @@ exports[`GenerateViewConfigJs can generate fixture TWO_COMPONENTS_SAME_FILE 1`] Map { "TWO_COMPONENTS_SAME_FILENativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -941,23 +1023,29 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ let nativeComponentName = 'MultiComponent1NativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'MultiComponent1NativeComponent', validAttributes: { disabled: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); let nativeComponentName = 'MultiComponent2NativeComponent'; -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'MultiComponent2NativeComponent', validAttributes: { disabled: true, }, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; @@ -966,10 +1054,10 @@ exports[`GenerateViewConfigJs can generate fixture with a deprecated view config Map { "DEPRECATED_VIEW_CONFIG_NAMENativeViewConfig.js" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @flow * @@ -982,17 +1070,20 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/ const {UIManager} = require(\\"react-native\\") let nativeComponentName = 'NativeComponentName'; -if (UIManager.getViewManagerConfig('NativeComponentName')) { +if (UIManager.hasViewManagerConfig('NativeComponentName')) { nativeComponentName = 'NativeComponentName'; -} else if (UIManager.getViewManagerConfig('DeprecatedNativeComponentName')) { +} else if (UIManager.hasViewManagerConfig('DeprecatedNativeComponentName')) { nativeComponentName = 'DeprecatedNativeComponentName'; } else { throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\"'); } -export default NativeComponentRegistry.get(nativeComponentName, () => ({ + +export const __INTERNAL_VIEW_CONFIG = { uiViewClassName: 'NativeComponentName', validAttributes: {}, -})); +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); ", } `; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index 908c88ee2a412a..046e86b1c65e0a 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,6 +17,7 @@ import type { NativeModulePropertyShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, + NativeModuleTypeAnnotation, } from '../../CodegenSchema'; import type {AliasResolver} from './Utils'; @@ -28,21 +29,33 @@ type FilesOutput = Map; const HostFunctionTemplate = ({ hasteModuleName, methodName, - isVoid, + returnTypeAnnotation, args, }: $ReadOnly<{ hasteModuleName: string, methodName: string, - isVoid: boolean, + returnTypeAnnotation: Nullable, args: Array, }>) => { + const isNullable = returnTypeAnnotation.type === 'NullableTypeAnnotation'; + const isVoid = returnTypeAnnotation.type === 'VoidTypeAnnotation'; const methodCallArgs = ['rt', ...args].join(', '); - const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(${methodCallArgs});`; + const methodCall = `static_cast<${hasteModuleName}CxxSpecJSI *>(&turboModule)->${methodName}(${methodCallArgs})`; return `static jsi::Value __hostFunction_${hasteModuleName}CxxSpecJSI_${methodName}(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {${ - isVoid ? `\n ${methodCall}` : '' + isVoid + ? `\n ${methodCall};` + : isNullable + ? `\n auto result = ${methodCall};` + : '' } - return ${isVoid ? 'jsi::Value::undefined();' : methodCall} + return ${ + isVoid + ? 'jsi::Value::undefined()' + : isNullable + ? 'result ? jsi::Value(std::move(*result)) : jsi::Value::null()' + : methodCall + }; }`; }; @@ -77,15 +90,15 @@ const FileTemplate = ({ modules: string, }>) => { return `/** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleH.js */ -#include +#include "${libraryName}JSI.h" namespace facebook { namespace react { @@ -105,24 +118,31 @@ function serializeArg( index: number, resolveAlias: AliasResolver, ): string { - function wrap(suffix) { - return `args[${index}]${suffix}`; - } const {typeAnnotation: nullableTypeAnnotation} = arg; - const [typeAnnotation] = unwrapNullable( - nullableTypeAnnotation, - ); + const [typeAnnotation, nullable] = + unwrapNullable(nullableTypeAnnotation); let realTypeAnnotation = typeAnnotation; if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') { realTypeAnnotation = resolveAlias(realTypeAnnotation.name); } + function wrap(callback: (val: string) => string) { + const val = `args[${index}]`; + const expression = callback(val); + + if (nullable) { + return `${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`; + } + + return expression; + } + switch (realTypeAnnotation.type) { case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': - return wrap('.getNumber()'); + return wrap(val => `${val}.getNumber()`); default: (realTypeAnnotation.name: empty); throw new Error( @@ -130,25 +150,27 @@ function serializeArg( ); } case 'StringTypeAnnotation': - return wrap('.getString(rt)'); + return wrap(val => `${val}.asString(rt)`); case 'BooleanTypeAnnotation': - return wrap('.getBool()'); + return wrap(val => `${val}.asBool()`); case 'NumberTypeAnnotation': - return wrap('.getNumber()'); + return wrap(val => `${val}.asNumber()`); case 'FloatTypeAnnotation': - return wrap('.getNumber()'); + return wrap(val => `${val}.asNumber()`); case 'DoubleTypeAnnotation': - return wrap('.getNumber()'); + return wrap(val => `${val}.asNumber()`); case 'Int32TypeAnnotation': - return wrap('.getNumber()'); + return wrap(val => `${val}.asNumber()`); case 'ArrayTypeAnnotation': - return wrap('.getObject(rt).getArray(rt)'); + return wrap(val => `${val}.asObject(rt).asArray(rt)`); case 'FunctionTypeAnnotation': - return `std::move(${wrap('.getObject(rt).getFunction(rt)')})`; + return wrap(val => `${val}.asObject(rt).asFunction(rt)`); case 'GenericObjectTypeAnnotation': - return wrap('.getObject(rt)'); + return wrap(val => `${val}.asObject(rt)`); case 'ObjectTypeAnnotation': - return wrap('.getObject(rt)'); + return wrap(val => `${val}.asObject(rt)`); + case 'MixedTypeAnnotation': + return wrap(val => `jsi::Value(rt, ${val})`); default: (realTypeAnnotation.type: empty); throw new Error( @@ -164,13 +186,11 @@ function serializePropertyIntoHostFunction( ): string { const [propertyTypeAnnotation] = unwrapNullable(property.typeAnnotation); - const isVoid = - propertyTypeAnnotation.returnTypeAnnotation.type === 'VoidTypeAnnotation'; return HostFunctionTemplate({ hasteModuleName, methodName: property.name, - isVoid, + returnTypeAnnotation: propertyTypeAnnotation.returnTypeAnnotation, args: propertyTypeAnnotation.params.map((p, i) => serializeArg(p, i, resolveAlias), ), @@ -221,7 +241,7 @@ module.exports = { }) .join('\n'); - const fileName = 'NativeModules.cpp'; + const fileName = `${libraryName}JSI-generated.cpp`; const replacedTemplate = FileTemplate({ modules, libraryName, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index 21da201a7c7d49..1f518d3f47e0f9 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,10 +15,12 @@ import type { SchemaType, NativeModuleTypeAnnotation, NativeModuleFunctionTypeAnnotation, + NativeModulePropertyShape, } from '../../CodegenSchema'; import type {AliasResolver} from './Utils'; const {createAliasResolver, getModules} = require('./Utils'); +const {indent} = require('../Utils'); const {unwrapNullable} = require('../../parsers/flow/modules/utils'); type FilesOutput = Map; @@ -26,27 +28,64 @@ type FilesOutput = Map; const ModuleClassDeclarationTemplate = ({ hasteModuleName, moduleProperties, -}: $ReadOnly<{hasteModuleName: string, moduleProperties: string}>) => { +}: $ReadOnly<{hasteModuleName: string, moduleProperties: string[]}>) => { return `class JSI_EXPORT ${hasteModuleName}CxxSpecJSI : public TurboModule { protected: ${hasteModuleName}CxxSpecJSI(std::shared_ptr jsInvoker); public: -${moduleProperties} + ${indent(moduleProperties.join('\n'), 2)} };`; }; +const ModuleSpecClassDeclarationTemplate = ({ + hasteModuleName, + moduleName, + moduleProperties, +}: $ReadOnly<{ + hasteModuleName: string, + moduleName: string, + moduleProperties: string[], +}>) => { + return `template +class JSI_EXPORT ${hasteModuleName}CxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + ${hasteModuleName}CxxSpec(std::shared_ptr jsInvoker) + : TurboModule("${moduleName}", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public ${hasteModuleName}CxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + ${hasteModuleName}CxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + ${indent(moduleProperties.join('\n'), 4)} + + private: + T *instance_; + }; + + Delegate delegate_; +};`; +}; + const FileTemplate = ({ modules, }: $ReadOnly<{ - modules: string, + modules: string[], }>) => { return `/** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleH.js */ @@ -54,10 +93,12 @@ const FileTemplate = ({ #pragma once #include +#include namespace facebook { namespace react { -${modules} + +${modules.join('\n\n')} } // namespace react } // namespace facebook @@ -69,19 +110,24 @@ function translatePrimitiveJSTypeToCpp( createErrorMessage: (typeName: string) => string, resolveAlias: AliasResolver, ) { - const [typeAnnotation] = unwrapNullable( + const [typeAnnotation, nullable] = unwrapNullable( nullableTypeAnnotation, ); + let realTypeAnnotation = typeAnnotation; if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') { realTypeAnnotation = resolveAlias(realTypeAnnotation.name); } + function wrap(type: string) { + return nullable ? `std::optional<${type}>` : type; + } + switch (realTypeAnnotation.type) { case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': - return 'double'; + return wrap('double'); default: (realTypeAnnotation.name: empty); throw new Error(createErrorMessage(realTypeAnnotation.name)); @@ -89,35 +135,81 @@ function translatePrimitiveJSTypeToCpp( case 'VoidTypeAnnotation': return 'void'; case 'StringTypeAnnotation': - return 'jsi::String'; + return wrap('jsi::String'); case 'NumberTypeAnnotation': - return 'double'; + return wrap('double'); case 'DoubleTypeAnnotation': - return 'double'; + return wrap('double'); case 'FloatTypeAnnotation': - return 'double'; + return wrap('double'); case 'Int32TypeAnnotation': - return 'int'; + return wrap('int'); case 'BooleanTypeAnnotation': - return 'bool'; + return wrap('bool'); case 'GenericObjectTypeAnnotation': - return 'jsi::Object'; + return wrap('jsi::Object'); case 'ObjectTypeAnnotation': - return 'jsi::Object'; + return wrap('jsi::Object'); case 'ArrayTypeAnnotation': - return 'jsi::Array'; + return wrap('jsi::Array'); case 'FunctionTypeAnnotation': - return 'jsi::Function'; + return wrap('jsi::Function'); case 'PromiseTypeAnnotation': - return 'jsi::Value'; + return wrap('jsi::Value'); + case 'MixedTypeAnnotation': + return wrap('jsi::Value'); default: (realTypeAnnotation.type: empty); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } -const propertyTemplate = - 'virtual ::_RETURN_VALUE_:: ::_PROPERTY_NAME_::(jsi::Runtime &rt::_ARGS_::) = 0;'; +function translatePropertyToCpp( + prop: NativeModulePropertyShape, + resolveAlias: AliasResolver, + abstract: boolean = false, +) { + const [propTypeAnnotation] = + unwrapNullable(prop.typeAnnotation); + + const params = propTypeAnnotation.params.map( + param => `std::move(${param.name})`, + ); + + const paramTypes = propTypeAnnotation.params.map(param => { + const translatedParam = translatePrimitiveJSTypeToCpp( + param.typeAnnotation, + typeName => + `Unsupported type for param "${param.name}" in ${prop.name}. Found: ${typeName}`, + resolveAlias, + ); + return `${translatedParam} ${param.name}`; + }); + + const returnType = translatePrimitiveJSTypeToCpp( + propTypeAnnotation.returnTypeAnnotation, + typeName => `Unsupported return type for ${prop.name}. Found: ${typeName}`, + resolveAlias, + ); + + // The first param will always be the runtime reference. + paramTypes.unshift('jsi::Runtime &rt'); + + const method = `${returnType} ${prop.name}(${paramTypes.join(', ')})`; + + if (abstract) { + return `virtual ${method} = 0;`; + } + + return `${method} override { + static_assert( + bridging::getParameterCount(&T::${prop.name}) == ${paramTypes.length}, + "Expected ${prop.name}(...) to have ${paramTypes.length} parameters"); + + return bridging::callFromJs<${returnType}>( + rt, &T::${prop.name}, jsInvoker_, ${['instance_', ...params].join(', ')}); +}`; +} module.exports = { generate( @@ -128,62 +220,32 @@ module.exports = { ): FilesOutput { const nativeModules = getModules(schema); - const modules = Object.keys(nativeModules) - .map(hasteModuleName => { - const { - aliases, - spec: {properties}, - } = nativeModules[hasteModuleName]; - const resolveAlias = createAliasResolver(aliases); - - const traversedProperties = properties - .map(prop => { - const [propTypeAnnotation] = - unwrapNullable( - prop.typeAnnotation, - ); - const traversedArgs = propTypeAnnotation.params - .map(param => { - const translatedParam = translatePrimitiveJSTypeToCpp( - param.typeAnnotation, - typeName => - `Unsupported type for param "${param.name}" in ${prop.name}. Found: ${typeName}`, - resolveAlias, - ); - const isObject = translatedParam.startsWith('jsi::'); - return ( - (isObject - ? 'const ' + translatedParam + ' &' - : translatedParam + ' ') + param.name - ); - }) - .join(', '); - return propertyTemplate - .replace('::_PROPERTY_NAME_::', prop.name) - .replace( - '::_RETURN_VALUE_::', - translatePrimitiveJSTypeToCpp( - propTypeAnnotation.returnTypeAnnotation, - typeName => - `Unsupported return type for ${prop.name}. Found: ${typeName}`, - resolveAlias, - ), - ) - .replace( - '::_ARGS_::', - traversedArgs === '' ? '' : ', ' + traversedArgs, - ); - }) - .join('\n'); - - return ModuleClassDeclarationTemplate({ - hasteModuleName, - moduleProperties: traversedProperties, - }); - }) - .join('\n'); + const modules = Object.keys(nativeModules).flatMap(hasteModuleName => { + const { + aliases, + spec: {properties}, + moduleNames: [moduleName], + } = nativeModules[hasteModuleName]; + const resolveAlias = createAliasResolver(aliases); - const fileName = 'NativeModules.h'; + return [ + ModuleClassDeclarationTemplate({ + hasteModuleName, + moduleProperties: properties.map(prop => + translatePropertyToCpp(prop, resolveAlias, true), + ), + }), + ModuleSpecClassDeclarationTemplate({ + hasteModuleName, + moduleName, + moduleProperties: properties.map(prop => + translatePropertyToCpp(prop, resolveAlias), + ), + }), + ]; + }); + + const fileName = `${libraryName}JSI.h`; const replacedTemplate = FileTemplate({modules}); return new Map([[fileName, replacedTemplate]]); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 14c4be208220ce..538371a7c49520 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -37,14 +37,14 @@ function FileTemplate( const {packageName, className, methods, imports} = config; return ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleJavaSpec.js * - * @nolint + * ${'@'}nolint */ package ${packageName}; @@ -156,7 +156,7 @@ function translateFunctionParamToJavaType( imports.add('com.facebook.react.bridge.Callback'); return 'Callback'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } @@ -212,15 +212,15 @@ function translateFunctionReturnTypeToJavaType( return nullable ? 'Boolean' : 'boolean'; case 'ObjectTypeAnnotation': imports.add('com.facebook.react.bridge.WritableMap'); - return 'WritableMap'; + return wrapIntoNullableIfNeeded('WritableMap'); case 'GenericObjectTypeAnnotation': imports.add('com.facebook.react.bridge.WritableMap'); - return 'WritableMap'; + return wrapIntoNullableIfNeeded('WritableMap'); case 'ArrayTypeAnnotation': imports.add('com.facebook.react.bridge.WritableArray'); - return 'WritableArray'; + return wrapIntoNullableIfNeeded('WritableArray'); default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } @@ -272,7 +272,7 @@ function getFalsyReturnStatementFromReturnType( case 'ArrayTypeAnnotation': return 'return null;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index d0969a6bffe8d8..4adb37c943c56d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -47,7 +47,8 @@ const HostFunctionTemplate = ({ jsReturnType: JSReturnType, }>) => { return `static facebook::jsi::Value __hostFunction_${hasteModuleName}SpecJSI_${propertyName}(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ${jsReturnType}, "${propertyName}", "${jniSignature}", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ${jsReturnType}, "${propertyName}", "${jniSignature}", args, count, cachedMethodId); }`; }; @@ -99,10 +100,10 @@ const FileTemplate = ({ }>) => { return ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleJniCpp.js */ @@ -114,7 +115,7 @@ namespace react { ${modules} -std::shared_ptr ${libraryName}_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr ${libraryName}_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { ${moduleLookups.map(ModuleLookupTemplate).join('\n')} return nullptr; } @@ -170,7 +171,7 @@ function translateReturnTypeToKind( case 'ArrayTypeAnnotation': return 'ArrayKind'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for returning value, found: ${realTypeAnnotation.type}"`, ); @@ -225,7 +226,7 @@ function translateParamTypeToJniType( case 'FunctionTypeAnnotation': return 'Lcom/facebook/react/bridge/Callback;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for method arg, found: ${realTypeAnnotation.type}"`, ); @@ -277,7 +278,7 @@ function translateReturnTypeToJniType( case 'ArrayTypeAnnotation': return 'Lcom/facebook/react/bridge/WritableArray;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for method return type, found: ${realTypeAnnotation.type}"`, ); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index 815a04e03a8924..146e39b46774a9 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -35,10 +35,10 @@ const HeaderFileTemplate = ({ }: $ReadOnly<{modules: string, libraryName: string}>) => { return ` /** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleJniH.js */ @@ -54,7 +54,8 @@ namespace react { ${modules} -std::shared_ptr ${libraryName}_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr ${libraryName}_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook @@ -63,7 +64,7 @@ std::shared_ptr ${libraryName}_ModuleProvider(const std::string mod // Note: this Android.mk template includes dependencies for both NativeModule and components. const AndroidMkTemplate = ({libraryName}: $ReadOnly<{libraryName: string}>) => { - return `# Copyright (c) Facebook, Inc. and its affiliates. + return `# 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. @@ -77,10 +78,23 @@ LOCAL_MODULE := react_codegen_${libraryName} LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/${libraryName}/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/${libraryName} -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni \ + libfolly_runtime \ + libglog \ + libjsi \ + libreact_codegen_rncore \ + libreact_debug \ + libreact_nativemodule_core \ + libreact_render_core \ + libreact_render_debug \ + libreact_render_graphics \ + librrc_view \ + libturbomodulejsijni \ + libyoga LOCAL_CFLAGS := \\ -DLOG_TAG=\\"ReactNative\\" @@ -91,6 +105,57 @@ include $(BUILD_SHARED_LIBRARY) `; }; +// Note: this CMakeLists.txt template includes dependencies for both NativeModule and components. +const CMakeListsTemplate = ({ + libraryName, +}: $ReadOnly<{libraryName: string}>) => { + return `# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/${libraryName}/*.cpp) + +add_library( + react_codegen_${libraryName} + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_${libraryName} PUBLIC . react/renderer/components/${libraryName}) + +target_link_libraries( + react_codegen_${libraryName} + fbjni + folly_runtime + glog + jsi + ${libraryName !== 'rncore' ? 'react_codegen_rncore' : ''} + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_${libraryName} + PRIVATE + -DLOG_TAG=\\"ReactNative\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) +`; +}; + module.exports = { generate( libraryName: string, @@ -121,9 +186,10 @@ module.exports = { [ 'jni/Android.mk', AndroidMkTemplate({ - libraryName: `${libraryName.toLowerCase()}`, + libraryName: libraryName, }), ], + ['jni/CMakeLists.txt', CMakeListsTemplate({libraryName: libraryName})], ]); }, }; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js index e92bcb66eb3da8..e942ff3c978255 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -112,6 +112,8 @@ class StructCollector { this._insertAlias(typeAnnotation.name, structContext, resolveAlias); return wrapNullable(nullable, typeAnnotation); } + case 'MixedTypeAnnotation': + throw new Error('Mixed types are unsupported in structs'); default: { return wrapNullable(nullable, typeAnnotation); } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js index ffbfea1b8cc701..59121a4b52faa1 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js index 638f33b1fa94de..019724049a15bc 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -79,15 +79,15 @@ function toObjCType( ): string { const [typeAnnotation, nullable] = unwrapNullable(nullableTypeAnnotation); const isRequired = !nullable && !isOptional; - const wrapFollyOptional = (type: string) => { - return isRequired ? type : `folly::Optional<${type}>`; + const wrapOptional = (type: string) => { + return isRequired ? type : `std::optional<${type}>`; }; switch (typeAnnotation.type) { case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': - return wrapFollyOptional('double'); + return wrapOptional('double'); default: (typeAnnotation.name: empty); throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`); @@ -95,15 +95,15 @@ function toObjCType( case 'StringTypeAnnotation': return 'NSString *'; case 'NumberTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'FloatTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'Int32TypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'DoubleTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'BooleanTypeAnnotation': - return wrapFollyOptional('bool'); + return wrapOptional('bool'); case 'GenericObjectTypeAnnotation': return isRequired ? 'id ' : 'id _Nullable '; case 'ArrayTypeAnnotation': @@ -111,7 +111,7 @@ function toObjCType( return isRequired ? 'id ' : 'id _Nullable '; } - return wrapFollyOptional( + return wrapOptional( `std::vector<${toObjCType( hasteModuleName, typeAnnotation.elementType, @@ -123,7 +123,7 @@ function toObjCType( hasteModuleName, structName, ); - return wrapFollyOptional(`${namespacedStructName}::Builder`); + return wrapOptional(`${namespacedStructName}::Builder`); default: (typeAnnotation.type: empty); throw new Error( @@ -144,7 +144,7 @@ function toObjCValue( function wrapPrimitive(type: string) { return !isRequired - ? `${value}.hasValue() ? @((${type})${value}.value()) : nil` + ? `${value}.has_value() ? @((${type})${value}.value()) : nil` : `@(${value})`; } @@ -199,7 +199,7 @@ function toObjCValue( ); case 'TypeAliasTypeAnnotation': return !isRequired - ? `${value}.hasValue() ? ${value}.value().buildUnsafeRawValue() : nil` + ? `${value}.has_value() ? ${value}.value().buildUnsafeRawValue() : nil` : `${value}.buildUnsafeRawValue()`; default: (typeAnnotation.type: empty); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js index fdcb2ab310665f..e17c30005d411b 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -70,15 +70,15 @@ function toObjCType( ): string { const [typeAnnotation, nullable] = unwrapNullable(nullableTypeAnnotation); const isRequired = !nullable && !isOptional; - const wrapFollyOptional = (type: string) => { - return isRequired ? type : `folly::Optional<${type}>`; + const wrapOptional = (type: string) => { + return isRequired ? type : `std::optional<${type}>`; }; switch (typeAnnotation.type) { case 'ReservedTypeAnnotation': switch (typeAnnotation.name) { case 'RootTag': - return wrapFollyOptional('double'); + return wrapOptional('double'); default: (typeAnnotation.name: empty); throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`); @@ -86,22 +86,22 @@ function toObjCType( case 'StringTypeAnnotation': return 'NSString *'; case 'NumberTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'FloatTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'Int32TypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'DoubleTypeAnnotation': - return wrapFollyOptional('double'); + return wrapOptional('double'); case 'BooleanTypeAnnotation': - return wrapFollyOptional('bool'); + return wrapOptional('bool'); case 'GenericObjectTypeAnnotation': return isRequired ? 'id ' : 'id _Nullable'; case 'ArrayTypeAnnotation': if (typeAnnotation.elementType == null) { return isRequired ? 'id ' : 'id _Nullable'; } - return wrapFollyOptional( + return wrapOptional( `facebook::react::LazyVector<${toObjCType( hasteModuleName, typeAnnotation.elementType, @@ -113,7 +113,7 @@ function toObjCType( hasteModuleName, structName, ); - return wrapFollyOptional(namespacedStructName); + return wrapOptional(namespacedStructName); default: (typeAnnotation.type: empty); throw new Error( @@ -190,7 +190,7 @@ function toObjCValue( ); return !isRequired - ? `(${value} == nil ? folly::none : folly::make_optional(${namespacedStructName}(${value})))` + ? `(${value} == nil ? std::nullopt : std::make_optional(${namespacedStructName}(${value})))` : `${namespacedStructName}(${value})`; default: (typeAnnotation.type: empty); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js index 170ac77c8fe863..d5b38f45357a2e 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeStruct.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js index c3d00d033630ec..8f8da790b90407 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -59,10 +59,10 @@ const HeaderFileTemplate = ({ assumeNonnull: boolean, }>) => `/** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleObjCpp * @@ -82,7 +82,7 @@ const HeaderFileTemplate = ({ #import #import #import -#import +#import #import ` + @@ -99,10 +99,10 @@ const SourceFileTemplate = ({ headerFileName: string, moduleImplementations: string, }>) => `/** - * ${'C'}opyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * ${'@'}generated by codegen project: GenerateModuleObjCpp * diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index 6f5c742a346be7..8bedb6cb61f929 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -338,7 +338,7 @@ function getReturnObjCType( case 'GenericObjectTypeAnnotation': return wrapIntoNullableIfNeeded('NSDictionary *'); default: - (typeAnnotation.type: empty); + (typeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`, ); @@ -378,7 +378,7 @@ function getReturnJSType( case 'GenericObjectTypeAnnotation': return 'ObjectKind'; default: - (typeAnnotation.type: empty); + (typeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`, ); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js index 14796e88a65d67..2d9eb34d2564f8 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/Utils.js b/packages/react-native-codegen/src/generators/modules/Utils.js index 10017bb420bb0c..b89df46a01f896 100644 --- a/packages/react-native-codegen/src/generators/modules/Utils.js +++ b/packages/react-native-codegen/src/generators/modules/Utils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index eb1f8ddd6f1edf..16f6bd517ba44d 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -655,6 +655,49 @@ const COMPLEX_OBJECTS: SchemaType = { ], }, }, + { + name: 'getNullableObject', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: [], + }, + }, + params: [], + }, + }, + { + name: 'getNullableGenericObject', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'GenericObjectTypeAnnotation', + }, + }, + params: [], + }, + }, + { + name: 'getNullableArray', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + }, + }, + params: [], + }, + }, ], }, moduleNames: ['SampleTurboModule'], @@ -1459,11 +1502,99 @@ const REAL_MODULE_EXAMPLE: SchemaType = { }, }; +const CXX_ONLY_NATIVE_MODULES: SchemaType = { + modules: { + NativeSampleTurboModule: { + type: 'NativeModule', + aliases: { + ObjectAlias: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'x', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + ], + }, + }, + spec: { + properties: [ + { + name: 'getMixed', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'MixedTypeAnnotation', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'MixedTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getNullableNumberFromNullableAlias', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + params: [ + { + name: 'a', + optional: false, + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectAlias', + }, + }, + }, + ], + }, + }, + ], + }, + moduleNames: ['SampleTurboModuleCxx'], + excludedPlatforms: ['iOS', 'android'], + }, + }, +}; + +const SAMPLE_WITH_UPPERCASE_NAME: SchemaType = { + modules: { + NativeSampleTurboModule: { + type: 'NativeModule', + aliases: {}, + spec: { + properties: [], + }, + moduleNames: ['SampleTurboModule'], + }, + }, +}; + module.exports = { - COMPLEX_OBJECTS, - TWO_MODULES_DIFFERENT_FILES, - EMPTY_NATIVE_MODULES, - SIMPLE_NATIVE_MODULES, - NATIVE_MODULES_WITH_TYPE_ALIASES, - REAL_MODULE_EXAMPLE, + complex_objects: COMPLEX_OBJECTS, + two_modules_different_files: TWO_MODULES_DIFFERENT_FILES, + empty_native_modules: EMPTY_NATIVE_MODULES, + simple_native_modules: SIMPLE_NATIVE_MODULES, + native_modules_with_type_aliases: NATIVE_MODULES_WITH_TYPE_ALIASES, + real_module_example: REAL_MODULE_EXAMPLE, + cxx_only_native_modules: CXX_ONLY_NATIVE_MODULES, + SampleWithUppercaseName: SAMPLE_WITH_UPPERCASE_NAME, }; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js index a03ef0508b7851..dfef8d4cdb8c46 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js index 3acbc7f638f94c..43c2ccf080ed47 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js index e73d46fa5e9ad2..0d7431c05285b0 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleHObjCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js index 854d21388c18a8..53cbac6ba70bf6 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJavaSpec-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js index 0dfc249f71458f..59f2568c770dcf 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniCpp-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js index 4e9e116b9619cb..3321f9f68b2ef9 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleJniH-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js index c1a4feb400adba..bb4428292c53f1 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js +++ b/packages/react-native-codegen/src/generators/modules/__tests__/GenerateModuleMm-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap index 4b0e7d22201dcf..93a57fc91bcb50 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap @@ -1,36 +1,78 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleCpp can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleCpp can generate fixture SampleWithUppercaseName 1`] = ` Map { - "NativeModules.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "SampleWithUppercaseNameJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"SampleWithUppercaseNameJSI.h\\" + +namespace facebook { +namespace react { + + + +NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker) { + +} + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleCpp can generate fixture complex_objects 1`] = ` +Map { + "complex_objectsJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#include \\"complex_objectsJSI.h\\" namespace facebook { namespace react { static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_difficult(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->difficult(rt, args[0].getObject(rt)); + return static_cast(&turboModule)->difficult(rt, args[0].asObject(rt)); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_optionals(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->optionals(rt, args[0].getObject(rt)); + static_cast(&turboModule)->optionals(rt, args[0].asObject(rt)); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_optionalMethod(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->optionalMethod(rt, args[0].getObject(rt), std::move(args[1].getObject(rt).getFunction(rt)), args[2].getObject(rt).getArray(rt)); + static_cast(&turboModule)->optionalMethod(rt, args[0].asObject(rt), args[1].asObject(rt).asFunction(rt), args[2].asObject(rt).asArray(rt)); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArrays(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->getArrays(rt, args[0].getObject(rt)); + static_cast(&turboModule)->getArrays(rt, args[0].asObject(rt)); return jsi::Value::undefined(); } +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getNullableObject(rt); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableGenericObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getNullableGenericObject(rt); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableArray(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getNullableArray(rt); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) : TurboModule(\\"SampleTurboModule\\", jsInvoker) { @@ -38,6 +80,46 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared methodMap_[\\"optionals\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_optionals}; methodMap_[\\"optionalMethod\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_optionalMethod}; methodMap_[\\"getArrays\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArrays}; + methodMap_[\\"getNullableObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableObject}; + methodMap_[\\"getNullableGenericObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableGenericObject}; + methodMap_[\\"getNullableArray\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableArray}; +} + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleCpp can generate fixture cxx_only_native_modules 1`] = ` +Map { + "cxx_only_native_modulesJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#include \\"cxx_only_native_modulesJSI.h\\" + +namespace facebook { +namespace react { + +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getMixed(rt, jsi::Value(rt, args[0])); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getNullableNumberFromNullableAlias(rt, args[0].isNull() || args[0].isUndefined() ? std::nullopt : std::make_optional(args[0].asObject(rt))); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} + +NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModuleCxx\\", jsInvoker) { + methodMap_[\\"getMixed\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed}; + methodMap_[\\"getNullableNumberFromNullableAlias\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias}; } @@ -47,18 +129,18 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared } `; -exports[`GenerateModuleCpp can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleCpp can generate fixture empty_native_modules 1`] = ` Map { - "NativeModules.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "empty_native_modulesJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"empty_native_modulesJSI.h\\" namespace facebook { namespace react { @@ -77,18 +159,18 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared } `; -exports[`GenerateModuleCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleCpp can generate fixture native_modules_with_type_aliases 1`] = ` Map { - "NativeModules.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "native_modules_with_type_aliasesJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"native_modules_with_type_aliasesJSI.h\\" namespace facebook { namespace react { @@ -97,7 +179,7 @@ static jsi::Value __hostFunction_AliasTurboModuleCxxSpecJSI_getConstants(jsi::Ru return static_cast(&turboModule)->getConstants(rt); } static jsi::Value __hostFunction_AliasTurboModuleCxxSpecJSI_cropImage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->cropImage(rt, args[0].getObject(rt)); + static_cast(&turboModule)->cropImage(rt, args[0].asObject(rt)); return jsi::Value::undefined(); } @@ -114,18 +196,18 @@ AliasTurboModuleCxxSpecJSI::AliasTurboModuleCxxSpecJSI(std::shared_ptr "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "real_module_exampleJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"real_module_exampleJSI.h\\" namespace facebook { namespace react { @@ -134,13 +216,13 @@ static jsi::Value __hostFunction_NativeCameraRollManagerCxxSpecJSI_getConstants( return static_cast(&turboModule)->getConstants(rt); } static jsi::Value __hostFunction_NativeCameraRollManagerCxxSpecJSI_getPhotos(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getPhotos(rt, args[0].getObject(rt)); + return static_cast(&turboModule)->getPhotos(rt, args[0].asObject(rt)); } static jsi::Value __hostFunction_NativeCameraRollManagerCxxSpecJSI_saveToCameraRoll(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->saveToCameraRoll(rt, args[0].getString(rt), args[1].getString(rt)); + return static_cast(&turboModule)->saveToCameraRoll(rt, args[0].asString(rt), args[1].asString(rt)); } static jsi::Value __hostFunction_NativeCameraRollManagerCxxSpecJSI_deletePhotos(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->deletePhotos(rt, args[0].getObject(rt).getArray(rt)); + return static_cast(&turboModule)->deletePhotos(rt, args[0].asObject(rt).asArray(rt)); } NativeCameraRollManagerCxxSpecJSI::NativeCameraRollManagerCxxSpecJSI(std::shared_ptr jsInvoker) @@ -151,7 +233,7 @@ NativeCameraRollManagerCxxSpecJSI::NativeCameraRollManagerCxxSpecJSI(std::shared methodMap_[\\"deletePhotos\\"] = MethodMetadata {1, __hostFunction_NativeCameraRollManagerCxxSpecJSI_deletePhotos}; } static jsi::Value __hostFunction_NativeImagePickerIOSCxxSpecJSI_openCameraDialog(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->openCameraDialog(rt, args[0].getObject(rt), std::move(args[1].getObject(rt).getFunction(rt)), std::move(args[2].getObject(rt).getFunction(rt))); + static_cast(&turboModule)->openCameraDialog(rt, args[0].asObject(rt), args[1].asObject(rt).asFunction(rt), args[2].asObject(rt).asFunction(rt)); return jsi::Value::undefined(); } @@ -160,19 +242,19 @@ NativeImagePickerIOSCxxSpecJSI::NativeImagePickerIOSCxxSpecJSI(std::shared_ptr(&turboModule)->reportFatalException(rt, args[0].getString(rt), args[1].getObject(rt).getArray(rt), args[2].getNumber()); + static_cast(&turboModule)->reportFatalException(rt, args[0].asString(rt), args[1].asObject(rt).asArray(rt), args[2].asNumber()); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeExceptionsManagerCxxSpecJSI_reportSoftException(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->reportSoftException(rt, args[0].getString(rt), args[1].getObject(rt).getArray(rt), args[2].getNumber()); + static_cast(&turboModule)->reportSoftException(rt, args[0].asString(rt), args[1].asObject(rt).asArray(rt), args[2].asNumber()); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeExceptionsManagerCxxSpecJSI_reportException(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->reportException(rt, args[0].getObject(rt)); + static_cast(&turboModule)->reportException(rt, args[0].asObject(rt)); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeExceptionsManagerCxxSpecJSI_updateExceptionMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->updateExceptionMessage(rt, args[0].getString(rt), args[1].getObject(rt).getArray(rt), args[2].getNumber()); + static_cast(&turboModule)->updateExceptionMessage(rt, args[0].asString(rt), args[1].asObject(rt).asArray(rt), args[2].asNumber()); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeExceptionsManagerCxxSpecJSI_dismissRedbox(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { @@ -196,18 +278,18 @@ NativeExceptionsManagerCxxSpecJSI::NativeExceptionsManagerCxxSpecJSI(std::shared } `; -exports[`GenerateModuleCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleCpp can generate fixture simple_native_modules 1`] = ` Map { - "NativeModules.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "simple_native_modulesJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"simple_native_modulesJSI.h\\" namespace facebook { namespace react { @@ -220,32 +302,32 @@ static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFunc(jsi: return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getBool(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getBool(rt, args[0].getBool()); + return static_cast(&turboModule)->getBool(rt, args[0].asBool()); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNumber(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getNumber(rt, args[0].getNumber()); + return static_cast(&turboModule)->getNumber(rt, args[0].asNumber()); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getString(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getString(rt, args[0].getString(rt)); + return static_cast(&turboModule)->getString(rt, args[0].asString(rt)); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArray(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getArray(rt, args[0].getObject(rt).getArray(rt)); + return static_cast(&turboModule)->getArray(rt, args[0].asObject(rt).asArray(rt)); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getObject(rt, args[0].getObject(rt)); + return static_cast(&turboModule)->getObject(rt, args[0].asObject(rt)); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getRootTag(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getRootTag(rt, args[0].getNumber()); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValue(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getValue(rt, args[0].getNumber(), args[1].getString(rt), args[2].getObject(rt)); + return static_cast(&turboModule)->getValue(rt, args[0].asNumber(), args[1].asString(rt), args[2].asObject(rt)); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithCallback(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->getValueWithCallback(rt, std::move(args[0].getObject(rt).getFunction(rt))); + static_cast(&turboModule)->getValueWithCallback(rt, args[0].asObject(rt).asFunction(rt)); return jsi::Value::undefined(); } static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithPromise(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getValueWithPromise(rt, args[0].getBool()); + return static_cast(&turboModule)->getValueWithPromise(rt, args[0].asBool()); } NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) @@ -270,18 +352,18 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared } `; -exports[`GenerateModuleCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleCpp can generate fixture two_modules_different_files 1`] = ` Map { - "NativeModules.cpp" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "two_modules_different_filesJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ -#include +#include \\"two_modules_different_filesJSI.h\\" namespace facebook { namespace react { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index 318f5c85f43ed1..7fce7ea931084a 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleH can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleH can generate fixture SampleWithUppercaseName 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "SampleWithUppercaseNameJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -14,19 +14,45 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual jsi::Object difficult(jsi::Runtime &rt, const jsi::Object &A) = 0; -virtual void optionals(jsi::Runtime &rt, const jsi::Object &A) = 0; -virtual void optionalMethod(jsi::Runtime &rt, const jsi::Object &options, const jsi::Function &callback, const jsi::Array &extras) = 0; -virtual void getArrays(jsi::Runtime &rt, const jsi::Object &options) = 0; + + +}; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + + private: + T *instance_; + }; + + Delegate delegate_; }; } // namespace react @@ -35,13 +61,13 @@ virtual void getArrays(jsi::Runtime &rt, const jsi::Object &options) = 0; } `; -exports[`GenerateModuleH can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleH can generate fixture complex_objects 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "complex_objectsJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -49,16 +75,106 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: + virtual jsi::Object difficult(jsi::Runtime &rt, jsi::Object A) = 0; + virtual void optionals(jsi::Runtime &rt, jsi::Object A) = 0; + virtual void optionalMethod(jsi::Runtime &rt, jsi::Object options, jsi::Function callback, jsi::Array extras) = 0; + virtual void getArrays(jsi::Runtime &rt, jsi::Object options) = 0; + virtual std::optional getNullableObject(jsi::Runtime &rt) = 0; + virtual std::optional getNullableGenericObject(jsi::Runtime &rt) = 0; + virtual std::optional getNullableArray(jsi::Runtime &rt) = 0; + +}; +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Object difficult(jsi::Runtime &rt, jsi::Object A) override { + static_assert( + bridging::getParameterCount(&T::difficult) == 2, + \\"Expected difficult(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::difficult, jsInvoker_, instance_, std::move(A)); + } + void optionals(jsi::Runtime &rt, jsi::Object A) override { + static_assert( + bridging::getParameterCount(&T::optionals) == 2, + \\"Expected optionals(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::optionals, jsInvoker_, instance_, std::move(A)); + } + void optionalMethod(jsi::Runtime &rt, jsi::Object options, jsi::Function callback, jsi::Array extras) override { + static_assert( + bridging::getParameterCount(&T::optionalMethod) == 4, + \\"Expected optionalMethod(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::optionalMethod, jsInvoker_, instance_, std::move(options), std::move(callback), std::move(extras)); + } + void getArrays(jsi::Runtime &rt, jsi::Object options) override { + static_assert( + bridging::getParameterCount(&T::getArrays) == 2, + \\"Expected getArrays(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getArrays, jsInvoker_, instance_, std::move(options)); + } + std::optional getNullableObject(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getNullableObject) == 1, + \\"Expected getNullableObject(...) to have 1 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getNullableObject, jsInvoker_, instance_); + } + std::optional getNullableGenericObject(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getNullableGenericObject) == 1, + \\"Expected getNullableGenericObject(...) to have 1 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getNullableGenericObject, jsInvoker_, instance_); + } + std::optional getNullableArray(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getNullableArray) == 1, + \\"Expected getNullableArray(...) to have 1 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getNullableArray, jsInvoker_, instance_); + } + + private: + T *instance_; + }; + + Delegate delegate_; }; } // namespace react @@ -67,13 +183,13 @@ public: } `; -exports[`GenerateModuleH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleH can generate fixture cxx_only_native_modules 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "cxx_only_native_modulesJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -81,32 +197,214 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + +class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { +protected: + NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) = 0; + virtual std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) = 0; + +}; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModuleCxx\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) override { + static_assert( + bridging::getParameterCount(&T::getMixed) == 2, + \\"Expected getMixed(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getMixed, jsInvoker_, instance_, std::move(arg)); + } + std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) override { + static_assert( + bridging::getParameterCount(&T::getNullableNumberFromNullableAlias) == 2, + \\"Expected getNullableNumberFromNullableAlias(...) to have 2 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getNullableNumberFromNullableAlias, jsInvoker_, instance_, std::move(a)); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleH can generate fixture empty_native_modules 1`] = ` +Map { + "empty_native_modulesJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { +protected: + NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + + +}; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + + + private: + T *instance_; + }; + + Delegate delegate_; +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleH can generate fixture native_modules_with_type_aliases 1`] = ` +Map { + "native_modules_with_type_aliasesJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + class JSI_EXPORT AliasTurboModuleCxxSpecJSI : public TurboModule { protected: AliasTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; -virtual void cropImage(jsi::Runtime &rt, const jsi::Object &cropData) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; + virtual void cropImage(jsi::Runtime &rt, jsi::Object cropData) = 0; }; +template +class JSI_EXPORT AliasTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + AliasTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"AliasTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public AliasTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + AliasTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Object getConstants(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getConstants) == 1, + \\"Expected getConstants(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); + } + void cropImage(jsi::Runtime &rt, jsi::Object cropData) override { + static_assert( + bridging::getParameterCount(&T::cropImage) == 2, + \\"Expected cropImage(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::cropImage, jsInvoker_, instance_, std::move(cropData)); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + } // namespace react } // namespace facebook ", } `; -exports[`GenerateModuleH can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleH can generate fixture real_module_example 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "real_module_exampleJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -114,54 +412,216 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + class JSI_EXPORT NativeCameraRollManagerCxxSpecJSI : public TurboModule { protected: NativeCameraRollManagerCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; -virtual jsi::Value getPhotos(jsi::Runtime &rt, const jsi::Object ¶ms) = 0; -virtual jsi::Value saveToCameraRoll(jsi::Runtime &rt, const jsi::String &uri, const jsi::String &type) = 0; -virtual jsi::Value deletePhotos(jsi::Runtime &rt, const jsi::Array &assets) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; + virtual jsi::Value getPhotos(jsi::Runtime &rt, jsi::Object params) = 0; + virtual jsi::Value saveToCameraRoll(jsi::Runtime &rt, jsi::String uri, jsi::String type) = 0; + virtual jsi::Value deletePhotos(jsi::Runtime &rt, jsi::Array assets) = 0; + +}; + +template +class JSI_EXPORT NativeCameraRollManagerCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } +protected: + NativeCameraRollManagerCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"CameraRollManager\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeCameraRollManagerCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeCameraRollManagerCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Object getConstants(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getConstants) == 1, + \\"Expected getConstants(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); + } + jsi::Value getPhotos(jsi::Runtime &rt, jsi::Object params) override { + static_assert( + bridging::getParameterCount(&T::getPhotos) == 2, + \\"Expected getPhotos(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getPhotos, jsInvoker_, instance_, std::move(params)); + } + jsi::Value saveToCameraRoll(jsi::Runtime &rt, jsi::String uri, jsi::String type) override { + static_assert( + bridging::getParameterCount(&T::saveToCameraRoll) == 3, + \\"Expected saveToCameraRoll(...) to have 3 parameters\\"); + + return bridging::callFromJs( + rt, &T::saveToCameraRoll, jsInvoker_, instance_, std::move(uri), std::move(type)); + } + jsi::Value deletePhotos(jsi::Runtime &rt, jsi::Array assets) override { + static_assert( + bridging::getParameterCount(&T::deletePhotos) == 2, + \\"Expected deletePhotos(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::deletePhotos, jsInvoker_, instance_, std::move(assets)); + } + + private: + T *instance_; + }; + + Delegate delegate_; }; + class JSI_EXPORT NativeImagePickerIOSCxxSpecJSI : public TurboModule { protected: NativeImagePickerIOSCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual void openCameraDialog(jsi::Runtime &rt, const jsi::Object &config, const jsi::Function &successCallback, const jsi::Function &cancelCallback) = 0; + virtual void openCameraDialog(jsi::Runtime &rt, jsi::Object config, jsi::Function successCallback, jsi::Function cancelCallback) = 0; + +}; + +template +class JSI_EXPORT NativeImagePickerIOSCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } +protected: + NativeImagePickerIOSCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"ImagePickerIOS\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeImagePickerIOSCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeImagePickerIOSCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + void openCameraDialog(jsi::Runtime &rt, jsi::Object config, jsi::Function successCallback, jsi::Function cancelCallback) override { + static_assert( + bridging::getParameterCount(&T::openCameraDialog) == 4, + \\"Expected openCameraDialog(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::openCameraDialog, jsInvoker_, instance_, std::move(config), std::move(successCallback), std::move(cancelCallback)); + } + + private: + T *instance_; + }; + + Delegate delegate_; }; + class JSI_EXPORT NativeExceptionsManagerCxxSpecJSI : public TurboModule { protected: NativeExceptionsManagerCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual void reportFatalException(jsi::Runtime &rt, const jsi::String &message, const jsi::Array &stack, double exceptionId) = 0; -virtual void reportSoftException(jsi::Runtime &rt, const jsi::String &message, const jsi::Array &stack, double exceptionId) = 0; -virtual void reportException(jsi::Runtime &rt, const jsi::Object &data) = 0; -virtual void updateExceptionMessage(jsi::Runtime &rt, const jsi::String &message, const jsi::Array &stack, double exceptionId) = 0; -virtual void dismissRedbox(jsi::Runtime &rt) = 0; + virtual void reportFatalException(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) = 0; + virtual void reportSoftException(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) = 0; + virtual void reportException(jsi::Runtime &rt, jsi::Object data) = 0; + virtual void updateExceptionMessage(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) = 0; + virtual void dismissRedbox(jsi::Runtime &rt) = 0; }; +template +class JSI_EXPORT NativeExceptionsManagerCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeExceptionsManagerCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"ExceptionsManager\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeExceptionsManagerCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeExceptionsManagerCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + void reportFatalException(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) override { + static_assert( + bridging::getParameterCount(&T::reportFatalException) == 4, + \\"Expected reportFatalException(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::reportFatalException, jsInvoker_, instance_, std::move(message), std::move(stack), std::move(exceptionId)); + } + void reportSoftException(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) override { + static_assert( + bridging::getParameterCount(&T::reportSoftException) == 4, + \\"Expected reportSoftException(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::reportSoftException, jsInvoker_, instance_, std::move(message), std::move(stack), std::move(exceptionId)); + } + void reportException(jsi::Runtime &rt, jsi::Object data) override { + static_assert( + bridging::getParameterCount(&T::reportException) == 2, + \\"Expected reportException(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::reportException, jsInvoker_, instance_, std::move(data)); + } + void updateExceptionMessage(jsi::Runtime &rt, jsi::String message, jsi::Array stack, double exceptionId) override { + static_assert( + bridging::getParameterCount(&T::updateExceptionMessage) == 4, + \\"Expected updateExceptionMessage(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::updateExceptionMessage, jsInvoker_, instance_, std::move(message), std::move(stack), std::move(exceptionId)); + } + void dismissRedbox(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::dismissRedbox) == 1, + \\"Expected dismissRedbox(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::dismissRedbox, jsInvoker_, instance_); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + } // namespace react } // namespace facebook ", } `; -exports[`GenerateModuleH can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleH can generate fixture simple_native_modules 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "simple_native_modulesJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -169,41 +629,157 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; -virtual void voidFunc(jsi::Runtime &rt) = 0; -virtual bool getBool(jsi::Runtime &rt, bool arg) = 0; -virtual double getNumber(jsi::Runtime &rt, double arg) = 0; -virtual jsi::String getString(jsi::Runtime &rt, const jsi::String &arg) = 0; -virtual jsi::Array getArray(jsi::Runtime &rt, const jsi::Array &arg) = 0; -virtual jsi::Object getObject(jsi::Runtime &rt, const jsi::Object &arg) = 0; -virtual double getRootTag(jsi::Runtime &rt, double arg) = 0; -virtual jsi::Object getValue(jsi::Runtime &rt, double x, const jsi::String &y, const jsi::Object &z) = 0; -virtual void getValueWithCallback(jsi::Runtime &rt, const jsi::Function &callback) = 0; -virtual jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; + virtual void voidFunc(jsi::Runtime &rt) = 0; + virtual bool getBool(jsi::Runtime &rt, bool arg) = 0; + virtual double getNumber(jsi::Runtime &rt, double arg) = 0; + virtual jsi::String getString(jsi::Runtime &rt, jsi::String arg) = 0; + virtual jsi::Array getArray(jsi::Runtime &rt, jsi::Array arg) = 0; + virtual jsi::Object getObject(jsi::Runtime &rt, jsi::Object arg) = 0; + virtual double getRootTag(jsi::Runtime &rt, double arg) = 0; + virtual jsi::Object getValue(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) = 0; + virtual void getValueWithCallback(jsi::Runtime &rt, jsi::Function callback) = 0; + virtual jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) = 0; }; +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Object getConstants(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getConstants) == 1, + \\"Expected getConstants(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); + } + void voidFunc(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFunc) == 1, + \\"Expected voidFunc(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFunc, jsInvoker_, instance_); + } + bool getBool(jsi::Runtime &rt, bool arg) override { + static_assert( + bridging::getParameterCount(&T::getBool) == 2, + \\"Expected getBool(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getBool, jsInvoker_, instance_, std::move(arg)); + } + double getNumber(jsi::Runtime &rt, double arg) override { + static_assert( + bridging::getParameterCount(&T::getNumber) == 2, + \\"Expected getNumber(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getNumber, jsInvoker_, instance_, std::move(arg)); + } + jsi::String getString(jsi::Runtime &rt, jsi::String arg) override { + static_assert( + bridging::getParameterCount(&T::getString) == 2, + \\"Expected getString(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getString, jsInvoker_, instance_, std::move(arg)); + } + jsi::Array getArray(jsi::Runtime &rt, jsi::Array arg) override { + static_assert( + bridging::getParameterCount(&T::getArray) == 2, + \\"Expected getArray(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getArray, jsInvoker_, instance_, std::move(arg)); + } + jsi::Object getObject(jsi::Runtime &rt, jsi::Object arg) override { + static_assert( + bridging::getParameterCount(&T::getObject) == 2, + \\"Expected getObject(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getObject, jsInvoker_, instance_, std::move(arg)); + } + double getRootTag(jsi::Runtime &rt, double arg) override { + static_assert( + bridging::getParameterCount(&T::getRootTag) == 2, + \\"Expected getRootTag(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getRootTag, jsInvoker_, instance_, std::move(arg)); + } + jsi::Object getValue(jsi::Runtime &rt, double x, jsi::String y, jsi::Object z) override { + static_assert( + bridging::getParameterCount(&T::getValue) == 4, + \\"Expected getValue(...) to have 4 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValue, jsInvoker_, instance_, std::move(x), std::move(y), std::move(z)); + } + void getValueWithCallback(jsi::Runtime &rt, jsi::Function callback) override { + static_assert( + bridging::getParameterCount(&T::getValueWithCallback) == 2, + \\"Expected getValueWithCallback(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValueWithCallback, jsInvoker_, instance_, std::move(callback)); + } + jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) override { + static_assert( + bridging::getParameterCount(&T::getValueWithPromise) == 2, + \\"Expected getValueWithPromise(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getValueWithPromise, jsInvoker_, instance_, std::move(error)); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + } // namespace react } // namespace facebook ", } `; -exports[`GenerateModuleH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleH can generate fixture two_modules_different_files 1`] = ` Map { - "NativeModules.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "two_modules_different_filesJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleH.js */ @@ -211,25 +787,104 @@ Map { #pragma once #include +#include namespace facebook { namespace react { + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { protected: NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual void voidFunc(jsi::Runtime &rt) = 0; + virtual void voidFunc(jsi::Runtime &rt) = 0; }; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + void voidFunc(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFunc) == 1, + \\"Expected voidFunc(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFunc, jsInvoker_, instance_); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + class JSI_EXPORT NativeSampleTurboModule2CxxSpecJSI : public TurboModule { protected: NativeSampleTurboModule2CxxSpecJSI(std::shared_ptr jsInvoker); public: -virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; -virtual void voidFunc(jsi::Runtime &rt) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; + virtual void voidFunc(jsi::Runtime &rt) = 0; + +}; +template +class JSI_EXPORT NativeSampleTurboModule2CxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModule2CxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule2\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModule2CxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModule2CxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Object getConstants(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getConstants) == 1, + \\"Expected getConstants(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); + } + void voidFunc(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFunc) == 1, + \\"Expected voidFunc(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFunc, jsInvoker_, instance_); + } + + private: + T *instance_; + }; + + Delegate delegate_; }; } // namespace react diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index 232d40e7dc114b..07ab8ba9129c19 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleHObjCpp can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleHObjCpp can generate fixture SampleWithUppercaseName 1`] = ` Map { - "COMPLEX_OBJECTS.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "SampleWithUppercaseName.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -26,7 +26,58 @@ Map { #import #import #import -#import +#import +#import + + +@protocol NativeSampleTurboModuleSpec + + + +@end +namespace facebook { + namespace react { + /** + * ObjC++ class for module 'NativeSampleTurboModule' + */ + class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public ObjCTurboModule { + public: + NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms); + }; + } // namespace react +} // namespace facebook + +", +} +`; + +exports[`GenerateModuleHObjCpp can generate fixture complex_objects 1`] = ` +Map { + "complex_objects.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#ifndef __cplusplus +#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm. +#endif +#import +#import +#import +#import +#import +#import +#import +#import +#import #import namespace JS { @@ -83,11 +134,11 @@ namespace JS { namespace JS { namespace NativeSampleTurboModule { struct SpecOptionalsA { - folly::Optional optionalNumberProperty() const; - folly::Optional> optionalArrayProperty() const; - folly::Optional optionalObjectProperty() const; + std::optional optionalNumberProperty() const; + std::optional> optionalArrayProperty() const; + std::optional optionalObjectProperty() const; id _Nullable optionalGenericObjectProperty() const; - folly::Optional optionalBooleanTypeProperty() const; + std::optional optionalBooleanTypeProperty() const; SpecOptionalsA(NSDictionary *const v) : _v(v) {} private: @@ -118,9 +169,9 @@ namespace JS { namespace NativeSampleTurboModule { struct SpecGetArraysOptions { facebook::react::LazyVector arrayOfNumbers() const; - folly::Optional> optionalArrayOfNumbers() const; + std::optional> optionalArrayOfNumbers() const; facebook::react::LazyVector arrayOfStrings() const; - folly::Optional> optionalArrayOfStrings() const; + std::optional> optionalArrayOfStrings() const; facebook::react::LazyVector arrayOfObjects() const; SpecGetArraysOptions(NSDictionary *const v) : _v(v) {} @@ -141,6 +192,9 @@ namespace JS { callback:(RCTResponseSenderBlock)callback extras:(NSArray *)extras; - (void)getArrays:(JS::NativeSampleTurboModule::SpecGetArraysOptions &)options; +- (NSDictionary * _Nullable)getNullableObject; +- (NSDictionary * _Nullable)getNullableGenericObject; +- (NSArray> * _Nullable)getNullableArray; @end namespace facebook { @@ -199,27 +253,27 @@ inline double JS::NativeSampleTurboModule::SpecOptionalsAOptionalObjectProperty: id const p = _v[@\\"y\\"]; return RCTBridgingToDouble(p); } -inline folly::Optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalNumberProperty() const +inline std::optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalNumberProperty() const { id const p = _v[@\\"optionalNumberProperty\\"]; return RCTBridgingToOptionalDouble(p); } -inline folly::Optional> JS::NativeSampleTurboModule::SpecOptionalsA::optionalArrayProperty() const +inline std::optional> JS::NativeSampleTurboModule::SpecOptionalsA::optionalArrayProperty() const { id const p = _v[@\\"optionalArrayProperty\\"]; return RCTBridgingToOptionalVec(p, ^double(id itemValue_0) { return RCTBridgingToDouble(itemValue_0); }); } -inline folly::Optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalObjectProperty() const +inline std::optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalObjectProperty() const { id const p = _v[@\\"optionalObjectProperty\\"]; - return (p == nil ? folly::none : folly::make_optional(JS::NativeSampleTurboModule::SpecOptionalsAOptionalObjectProperty(p))); + return (p == nil ? std::nullopt : std::make_optional(JS::NativeSampleTurboModule::SpecOptionalsAOptionalObjectProperty(p))); } inline id _Nullable JS::NativeSampleTurboModule::SpecOptionalsA::optionalGenericObjectProperty() const { id const p = _v[@\\"optionalGenericObjectProperty\\"]; return p; } -inline folly::Optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalBooleanTypeProperty() const +inline std::optional JS::NativeSampleTurboModule::SpecOptionalsA::optionalBooleanTypeProperty() const { id const p = _v[@\\"optionalBooleanTypeProperty\\"]; return RCTBridgingToOptionalBool(p); @@ -234,7 +288,7 @@ inline facebook::react::LazyVector JS::NativeSampleTurboModule::SpecGetA id const p = _v[@\\"arrayOfNumbers\\"]; return RCTBridgingToVec(p, ^double(id itemValue_0) { return RCTBridgingToDouble(itemValue_0); }); } -inline folly::Optional> JS::NativeSampleTurboModule::SpecGetArraysOptions::optionalArrayOfNumbers() const +inline std::optional> JS::NativeSampleTurboModule::SpecGetArraysOptions::optionalArrayOfNumbers() const { id const p = _v[@\\"optionalArrayOfNumbers\\"]; return RCTBridgingToOptionalVec(p, ^double(id itemValue_0) { return RCTBridgingToDouble(itemValue_0); }); @@ -244,7 +298,7 @@ inline facebook::react::LazyVector JS::NativeSampleTurboModule::Spec id const p = _v[@\\"arrayOfStrings\\"]; return RCTBridgingToVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); }); } -inline folly::Optional> JS::NativeSampleTurboModule::SpecGetArraysOptions::optionalArrayOfStrings() const +inline std::optional> JS::NativeSampleTurboModule::SpecGetArraysOptions::optionalArrayOfStrings() const { id const p = _v[@\\"optionalArrayOfStrings\\"]; return RCTBridgingToOptionalVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); }); @@ -258,13 +312,48 @@ inline facebook::react::LazyVector "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#ifndef __cplusplus +#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm. +#endif +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + + + +", +} +`; + +exports[`GenerateModuleHObjCpp can generate fixture empty_native_modules 1`] = ` Map { - "EMPTY_NATIVE_MODULES.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "empty_native_modules.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -284,7 +373,7 @@ Map { #import #import #import -#import +#import #import @@ -309,13 +398,13 @@ namespace facebook { } `; -exports[`GenerateModuleHObjCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleHObjCpp can generate fixture native_modules_with_type_aliases 1`] = ` Map { - "NATIVE_MODULES_WITH_TYPE_ALIASES.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "native_modules_with_type_aliases.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -335,7 +424,7 @@ Map { #import #import #import -#import +#import #import namespace JS { @@ -391,9 +480,9 @@ namespace JS { struct Options { JS::AliasTurboModule::OptionsOffset offset() const; JS::AliasTurboModule::OptionsSize size() const; - folly::Optional displaySize() const; + std::optional displaySize() const; NSString *resizeMode() const; - folly::Optional allowExternalStorage() const; + std::optional allowExternalStorage() const; Options(NSDictionary *const v) : _v(v) {} private: @@ -461,17 +550,17 @@ inline JS::AliasTurboModule::OptionsSize JS::AliasTurboModule::Options::size() c id const p = _v[@\\"size\\"]; return JS::AliasTurboModule::OptionsSize(p); } -inline folly::Optional JS::AliasTurboModule::Options::displaySize() const +inline std::optional JS::AliasTurboModule::Options::displaySize() const { id const p = _v[@\\"displaySize\\"]; - return (p == nil ? folly::none : folly::make_optional(JS::AliasTurboModule::OptionsDisplaySize(p))); + return (p == nil ? std::nullopt : std::make_optional(JS::AliasTurboModule::OptionsDisplaySize(p))); } inline NSString *JS::AliasTurboModule::Options::resizeMode() const { id const p = _v[@\\"resizeMode\\"]; return RCTBridgingToOptionalString(p); } -inline folly::Optional JS::AliasTurboModule::Options::allowExternalStorage() const +inline std::optional JS::AliasTurboModule::Options::allowExternalStorage() const { id const p = _v[@\\"allowExternalStorage\\"]; return RCTBridgingToOptionalBool(p); @@ -480,13 +569,13 @@ inline folly::Optional JS::AliasTurboModule::Options::allowExternalStorage } `; -exports[`GenerateModuleHObjCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleHObjCpp can generate fixture real_module_example 1`] = ` Map { - "REAL_MODULE_EXAMPLE.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "real_module_example.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -506,7 +595,7 @@ Map { #import #import #import -#import +#import #import namespace JS { @@ -517,8 +606,8 @@ namespace JS { NSString *groupName() const; NSString *groupTypes() const; NSString *assetType() const; - folly::Optional maxSize() const; - folly::Optional> mimeTypes() const; + std::optional maxSize() const; + std::optional> mimeTypes() const; GetPhotosParams(NSDictionary *const v) : _v(v) {} private: @@ -558,11 +647,11 @@ namespace facebook { namespace JS { namespace NativeExceptionsManager { struct StackFrame { - folly::Optional column() const; + std::optional column() const; NSString *file() const; - folly::Optional lineNumber() const; + std::optional lineNumber() const; NSString *methodName() const; - folly::Optional collapse() const; + std::optional collapse() const; StackFrame(NSDictionary *const v) : _v(v) {} private: @@ -681,17 +770,17 @@ inline NSString *JS::NativeCameraRollManager::GetPhotosParams::assetType() const id const p = _v[@\\"assetType\\"]; return RCTBridgingToOptionalString(p); } -inline folly::Optional JS::NativeCameraRollManager::GetPhotosParams::maxSize() const +inline std::optional JS::NativeCameraRollManager::GetPhotosParams::maxSize() const { id const p = _v[@\\"maxSize\\"]; return RCTBridgingToOptionalDouble(p); } -inline folly::Optional> JS::NativeCameraRollManager::GetPhotosParams::mimeTypes() const +inline std::optional> JS::NativeCameraRollManager::GetPhotosParams::mimeTypes() const { id const p = _v[@\\"mimeTypes\\"]; return RCTBridgingToOptionalVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); }); } -inline folly::Optional JS::NativeExceptionsManager::StackFrame::column() const +inline std::optional JS::NativeExceptionsManager::StackFrame::column() const { id const p = _v[@\\"column\\"]; return RCTBridgingToOptionalDouble(p); @@ -701,7 +790,7 @@ inline NSString *JS::NativeExceptionsManager::StackFrame::file() const id const p = _v[@\\"file\\"]; return RCTBridgingToString(p); } -inline folly::Optional JS::NativeExceptionsManager::StackFrame::lineNumber() const +inline std::optional JS::NativeExceptionsManager::StackFrame::lineNumber() const { id const p = _v[@\\"lineNumber\\"]; return RCTBridgingToOptionalDouble(p); @@ -711,7 +800,7 @@ inline NSString *JS::NativeExceptionsManager::StackFrame::methodName() const id const p = _v[@\\"methodName\\"]; return RCTBridgingToString(p); } -inline folly::Optional JS::NativeExceptionsManager::StackFrame::collapse() const +inline std::optional JS::NativeExceptionsManager::StackFrame::collapse() const { id const p = _v[@\\"collapse\\"]; return RCTBridgingToOptionalBool(p); @@ -770,13 +859,13 @@ inline bool JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig::videoMode() co } `; -exports[`GenerateModuleHObjCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleHObjCpp can generate fixture simple_native_modules 1`] = ` Map { - "SIMPLE_NATIVE_MODULES.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "simple_native_modules.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -796,7 +885,7 @@ Map { #import #import #import -#import +#import #import namespace JS { @@ -876,13 +965,13 @@ inline JS::NativeSampleTurboModule::Constants::Builder::Builder(Constants i) : _ } `; -exports[`GenerateModuleHObjCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleHObjCpp can generate fixture two_modules_different_files 1`] = ` Map { - "TWO_MODULES_DIFFERENT_FILES.h" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "two_modules_different_files.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -902,7 +991,7 @@ Map { #import #import #import -#import +#import #import diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap index f7654f6e4c3f58..3fec5218b9ffa3 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap @@ -1,13 +1,47 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleJavaSpec can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture SampleWithUppercaseName 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJavaSpec.js + * + * @nolint + */ + +package com.facebook.fbreact.specs; + +import com.facebook.proguard.annotations.DoNotStrip; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.bridge.ReactModuleWithSpec; +import com.facebook.react.turbomodule.core.interfaces.TurboModule; + +public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { + public NativeSampleTurboModuleSpec(ReactApplicationContext reactContext) { + super(reactContext); + } + + +} +", +} +`; + +exports[`GenerateModuleJavaSpec can generate fixture complex_objects 1`] = ` +Map { + "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -24,8 +58,10 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactModuleWithSpec; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.turbomodule.core.interfaces.TurboModule; +import javax.annotation.Nullable; public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { public NativeSampleTurboModuleSpec(ReactApplicationContext reactContext) { @@ -47,19 +83,33 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo @ReactMethod @DoNotStrip public abstract void getArrays(ReadableMap options); + + @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip + public abstract @Nullable WritableMap getNullableObject(); + + @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip + public abstract @Nullable WritableMap getNullableGenericObject(); + + @ReactMethod(isBlockingSynchronousMethod = true) + @DoNotStrip + public abstract @Nullable WritableArray getNullableArray(); } ", } `; -exports[`GenerateModuleJavaSpec can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture cxx_only_native_modules 1`] = `Map {}`; + +exports[`GenerateModuleJavaSpec can generate fixture empty_native_modules 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -86,14 +136,14 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } `; -exports[`GenerateModuleJavaSpec can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture native_modules_with_type_aliases 1`] = ` Map { "java/com/facebook/fbreact/specs/AliasTurboModuleSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -123,14 +173,14 @@ public abstract class AliasTurboModuleSpec extends ReactContextBaseJavaModule im } `; -exports[`GenerateModuleJavaSpec can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture real_module_example 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeCameraRollManagerSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -169,10 +219,10 @@ public abstract class NativeCameraRollManagerSpec extends ReactContextBaseJavaMo ", "java/com/facebook/fbreact/specs/NativeExceptionsManagerSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -219,14 +269,14 @@ public abstract class NativeExceptionsManagerSpec extends ReactContextBaseJavaMo } `; -exports[`GenerateModuleJavaSpec can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture simple_native_modules 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -331,14 +381,14 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } `; -exports[`GenerateModuleJavaSpec can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleJavaSpec can generate fixture two_modules_different_files 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * @@ -366,10 +416,10 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo ", "java/com/facebook/fbreact/specs/NativeSampleTurboModule2Spec.java" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJavaSpec.js * diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap index 328f1a34779a55..9d771b73dddaa2 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap @@ -1,36 +1,92 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleJniCpp can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture SampleWithUppercaseName 1`] = ` Map { - "jni/COMPLEX_OBJECTS-generated.cpp" => " + "jni/SampleWithUppercaseName-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"COMPLEX_OBJECTS.h\\" +#include \\"SampleWithUppercaseName.h\\" + +namespace facebook { +namespace react { + + + +NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) + : JavaTurboModule(params) { + +} + +std::shared_ptr SampleWithUppercaseName_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { + if (moduleName == \\"SampleTurboModule\\") { + return std::make_shared(params); + } + return nullptr; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleJniCpp can generate fixture complex_objects 1`] = ` +Map { + "jni/complex_objects-generated.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniCpp.js + */ + +#include \\"complex_objects.h\\" namespace facebook { namespace react { static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_difficult(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"difficult\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"difficult\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_optionals(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"optionals\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"optionals\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_optionalMethod(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"optionalMethod\\", \\"(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/ReadableArray;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"optionalMethod\\", \\"(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/ReadableArray;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getArrays(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"getArrays\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"getArrays\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count, cachedMethodId); +} + +static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableObject(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getNullableObject\\", \\"()Lcom/facebook/react/bridge/WritableMap;\\", args, count, cachedMethodId); +} + +static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableGenericObject(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getNullableGenericObject\\", \\"()Lcom/facebook/react/bridge/WritableMap;\\", args, count, cachedMethodId); +} + +static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableArray(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ArrayKind, \\"getNullableArray\\", \\"()Lcom/facebook/react/bridge/WritableArray;\\", args, count, cachedMethodId); } NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -39,9 +95,12 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboMo methodMap_[\\"optionals\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_optionals}; methodMap_[\\"optionalMethod\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleSpecJSI_optionalMethod}; methodMap_[\\"getArrays\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArrays}; + methodMap_[\\"getNullableObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableObject}; + methodMap_[\\"getNullableGenericObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableGenericObject}; + methodMap_[\\"getNullableArray\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableArray}; } -std::shared_ptr COMPLEX_OBJECTS_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr complex_objects_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"SampleTurboModule\\") { return std::make_shared(params); } @@ -54,19 +113,49 @@ std::shared_ptr COMPLEX_OBJECTS_ModuleProvider(const std::string mo } `; -exports[`GenerateModuleJniCpp can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture cxx_only_native_modules 1`] = ` +Map { + "jni/cxx_only_native_modules-generated.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniCpp.js + */ + +#include \\"cxx_only_native_modules.h\\" + +namespace facebook { +namespace react { + + + +std::shared_ptr cxx_only_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { + + return nullptr; +} + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleJniCpp can generate fixture empty_native_modules 1`] = ` Map { - "jni/EMPTY_NATIVE_MODULES-generated.cpp" => " + "jni/empty_native_modules-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"EMPTY_NATIVE_MODULES.h\\" +#include \\"empty_native_modules.h\\" namespace facebook { namespace react { @@ -78,7 +167,7 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboMo } -std::shared_ptr EMPTY_NATIVE_MODULES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr empty_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"SampleTurboModule\\") { return std::make_shared(params); } @@ -91,19 +180,19 @@ std::shared_ptr EMPTY_NATIVE_MODULES_ModuleProvider(const std::stri } `; -exports[`GenerateModuleJniCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture native_modules_with_type_aliases 1`] = ` Map { - "jni/NATIVE_MODULES_WITH_TYPE_ALIASES-generated.cpp" => " + "jni/native_modules_with_type_aliases-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"NATIVE_MODULES_WITH_TYPE_ALIASES.h\\" +#include \\"native_modules_with_type_aliases.h\\" namespace facebook { namespace react { @@ -111,7 +200,8 @@ namespace react { static facebook::jsi::Value __hostFunction_AliasTurboModuleSpecJSI_cropImage(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"cropImage\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"cropImage\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count, cachedMethodId); } AliasTurboModuleSpecJSI::AliasTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -119,7 +209,7 @@ AliasTurboModuleSpecJSI::AliasTurboModuleSpecJSI(const JavaTurboModule::InitPara methodMap_[\\"cropImage\\"] = MethodMetadata {1, __hostFunction_AliasTurboModuleSpecJSI_cropImage}; } -std::shared_ptr NATIVE_MODULES_WITH_TYPE_ALIASES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr native_modules_with_type_aliases_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"AliasTurboModule\\") { return std::make_shared(params); } @@ -132,19 +222,19 @@ std::shared_ptr NATIVE_MODULES_WITH_TYPE_ALIASES_ModuleProvider(con } `; -exports[`GenerateModuleJniCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture real_module_example 1`] = ` Map { - "jni/REAL_MODULE_EXAMPLE-generated.cpp" => " + "jni/real_module_example-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"REAL_MODULE_EXAMPLE.h\\" +#include \\"real_module_example.h\\" namespace facebook { namespace react { @@ -152,15 +242,18 @@ namespace react { static facebook::jsi::Value __hostFunction_NativeCameraRollManagerSpecJSI_getPhotos(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"getPhotos\\", \\"(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"getPhotos\\", \\"(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeCameraRollManagerSpecJSI_saveToCameraRoll(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"saveToCameraRoll\\", \\"(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"saveToCameraRoll\\", \\"(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeCameraRollManagerSpecJSI_deletePhotos(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"deletePhotos\\", \\"(Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"deletePhotos\\", \\"(Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V\\", args, count, cachedMethodId); } NativeCameraRollManagerSpecJSI::NativeCameraRollManagerSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -170,23 +263,28 @@ NativeCameraRollManagerSpecJSI::NativeCameraRollManagerSpecJSI(const JavaTurboMo methodMap_[\\"deletePhotos\\"] = MethodMetadata {1, __hostFunction_NativeCameraRollManagerSpecJSI_deletePhotos}; } static facebook::jsi::Value __hostFunction_NativeExceptionsManagerSpecJSI_reportFatalException(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportFatalException\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportFatalException\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeExceptionsManagerSpecJSI_reportSoftException(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportSoftException\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportSoftException\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeExceptionsManagerSpecJSI_reportException(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportException\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"reportException\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeExceptionsManagerSpecJSI_updateExceptionMessage(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"updateExceptionMessage\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"updateExceptionMessage\\", \\"(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;D)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeExceptionsManagerSpecJSI_dismissRedbox(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"dismissRedbox\\", \\"()V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"dismissRedbox\\", \\"()V\\", args, count, cachedMethodId); } NativeExceptionsManagerSpecJSI::NativeExceptionsManagerSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -198,7 +296,7 @@ NativeExceptionsManagerSpecJSI::NativeExceptionsManagerSpecJSI(const JavaTurboMo methodMap_[\\"dismissRedbox\\"] = MethodMetadata {0, __hostFunction_NativeExceptionsManagerSpecJSI_dismissRedbox}; } -std::shared_ptr REAL_MODULE_EXAMPLE_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr real_module_example_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"CameraRollManager\\") { return std::make_shared(params); } @@ -214,65 +312,76 @@ std::shared_ptr REAL_MODULE_EXAMPLE_ModuleProvider(const std::strin } `; -exports[`GenerateModuleJniCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture simple_native_modules 1`] = ` Map { - "jni/SIMPLE_NATIVE_MODULES-generated.cpp" => " + "jni/simple_native_modules-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"SIMPLE_NATIVE_MODULES.h\\" +#include \\"simple_native_modules.h\\" namespace facebook { namespace react { static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getConstants\\", \\"()Ljava/util/Map;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getConstants\\", \\"()Ljava/util/Map;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getBool(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, BooleanKind, \\"getBool\\", \\"(Z)Z\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, BooleanKind, \\"getBool\\", \\"(Z)Z\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNumber(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, NumberKind, \\"getNumber\\", \\"(D)D\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, NumberKind, \\"getNumber\\", \\"(D)D\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getString(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, StringKind, \\"getString\\", \\"(Ljava/lang/String;)Ljava/lang/String;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, StringKind, \\"getString\\", \\"(Ljava/lang/String;)Ljava/lang/String;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getArray(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ArrayKind, \\"getArray\\", \\"(Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/bridge/WritableArray;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ArrayKind, \\"getArray\\", \\"(Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/bridge/WritableArray;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getObject(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getObject\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getObject\\", \\"(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, NumberKind, \\"getRootTag\\", \\"(D)D\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, NumberKind, \\"getRootTag\\", \\"(D)D\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getValue(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getValue\\", \\"(DLjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, ObjectKind, \\"getValue\\", \\"(DLjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"getValueWithCallback\\", \\"(Lcom/facebook/react/bridge/Callback;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"getValueWithCallback\\", \\"(Lcom/facebook/react/bridge/Callback;)V\\", args, count, cachedMethodId); } static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"getValueWithPromise\\", \\"(ZLcom/facebook/react/bridge/Promise;)V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, PromiseKind, \\"getValueWithPromise\\", \\"(ZLcom/facebook/react/bridge/Promise;)V\\", args, count, cachedMethodId); } NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -290,7 +399,7 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboMo methodMap_[\\"getValueWithPromise\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise}; } -std::shared_ptr SIMPLE_NATIVE_MODULES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr simple_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"SampleTurboModule\\") { return std::make_shared(params); } @@ -303,25 +412,26 @@ std::shared_ptr SIMPLE_NATIVE_MODULES_ModuleProvider(const std::str } `; -exports[`GenerateModuleJniCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleJniCpp can generate fixture two_modules_different_files 1`] = ` Map { - "jni/TWO_MODULES_DIFFERENT_FILES-generated.cpp" => " + "jni/two_modules_different_files-generated.cpp" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniCpp.js */ -#include \\"TWO_MODULES_DIFFERENT_FILES.h\\" +#include \\"two_modules_different_files.h\\" namespace facebook { namespace react { static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count, cachedMethodId); } NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -331,7 +441,8 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboMo static facebook::jsi::Value __hostFunction_NativeSampleTurboModule2SpecJSI_voidFunc(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { - return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count); + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count, cachedMethodId); } NativeSampleTurboModule2SpecJSI::NativeSampleTurboModule2SpecJSI(const JavaTurboModule::InitParams ¶ms) @@ -339,7 +450,7 @@ NativeSampleTurboModule2SpecJSI::NativeSampleTurboModule2SpecJSI(const JavaTurbo methodMap_[\\"voidFunc\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModule2SpecJSI_voidFunc}; } -std::shared_ptr TWO_MODULES_DIFFERENT_FILES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { +std::shared_ptr two_modules_different_files_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { if (moduleName == \\"SampleTurboModule\\") { return std::make_shared(params); } diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index 054b514908fd7a..0a84dc885c4fa7 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleJniH can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleJniH can generate fixture SampleWithUppercaseName 1`] = ` Map { - "jni/COMPLEX_OBJECTS.h" => " + "jni/SampleWithUppercaseName.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -30,12 +30,124 @@ public: }; -std::shared_ptr COMPLEX_OBJECTS_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr SampleWithUppercaseName_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := react_codegen_SampleWithUppercaseName + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/SampleWithUppercaseName/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/SampleWithUppercaseName + +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga + +LOCAL_CFLAGS := \\\\ + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + +LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall + +include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/SampleWithUppercaseName/*.cpp) + +add_library( + react_codegen_SampleWithUppercaseName + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_SampleWithUppercaseName PUBLIC . react/renderer/components/SampleWithUppercaseName) + +target_link_libraries( + react_codegen_SampleWithUppercaseName + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_SampleWithUppercaseName + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) +", +} +`; + +exports[`GenerateModuleJniH can generate fixture complex_objects 1`] = ` +Map { + "jni/complex_objects.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniH.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +/** + * JNI C++ class for module 'NativeSampleTurboModule' + */ +class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public JavaTurboModule { +public: + NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms); +}; + + +JSI_EXPORT +std::shared_ptr complex_objects_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); + +} // namespace react +} // namespace facebook +", + "jni/Android.mk" => "# 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. @@ -49,10 +161,11 @@ LOCAL_MODULE := react_codegen_complex_objects LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/complex_objects/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/complex_objects -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -60,18 +173,167 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/complex_objects/*.cpp) + +add_library( + react_codegen_complex_objects + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_complex_objects PUBLIC . react/renderer/components/complex_objects) + +target_link_libraries( + react_codegen_complex_objects + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_complex_objects + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; -exports[`GenerateModuleJniH can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJniH can generate fixture cxx_only_native_modules 1`] = ` Map { - "jni/EMPTY_NATIVE_MODULES.h" => " + "jni/cxx_only_native_modules.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniH.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + + + +JSI_EXPORT +std::shared_ptr cxx_only_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); + +} // namespace react +} // namespace facebook +", + "jni/Android.mk" => "# 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := react_codegen_cxx_only_native_modules + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/cxx_only_native_modules/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/cxx_only_native_modules + +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga + +LOCAL_CFLAGS := \\\\ + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + +LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall + +include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/cxx_only_native_modules/*.cpp) + +add_library( + react_codegen_cxx_only_native_modules + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_cxx_only_native_modules PUBLIC . react/renderer/components/cxx_only_native_modules) + +target_link_libraries( + react_codegen_cxx_only_native_modules + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_cxx_only_native_modules + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) +", +} +`; + +exports[`GenerateModuleJniH can generate fixture empty_native_modules 1`] = ` +Map { + "jni/empty_native_modules.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -94,12 +356,13 @@ public: }; -std::shared_ptr EMPTY_NATIVE_MODULES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr empty_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. @@ -113,10 +376,11 @@ LOCAL_MODULE := react_codegen_empty_native_modules LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/empty_native_modules/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/empty_native_modules -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -124,18 +388,63 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/empty_native_modules/*.cpp) + +add_library( + react_codegen_empty_native_modules + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_empty_native_modules PUBLIC . react/renderer/components/empty_native_modules) + +target_link_libraries( + react_codegen_empty_native_modules + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_empty_native_modules + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; -exports[`GenerateModuleJniH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleJniH can generate fixture native_modules_with_type_aliases 1`] = ` Map { - "jni/NATIVE_MODULES_WITH_TYPE_ALIASES.h" => " + "jni/native_modules_with_type_aliases.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -158,12 +467,13 @@ public: }; -std::shared_ptr NATIVE_MODULES_WITH_TYPE_ALIASES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr native_modules_with_type_aliases_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. @@ -177,10 +487,11 @@ LOCAL_MODULE := react_codegen_native_modules_with_type_aliases LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -188,18 +499,63 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/native_modules_with_type_aliases/*.cpp) + +add_library( + react_codegen_native_modules_with_type_aliases + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_native_modules_with_type_aliases PUBLIC . react/renderer/components/native_modules_with_type_aliases) + +target_link_libraries( + react_codegen_native_modules_with_type_aliases + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_native_modules_with_type_aliases + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; -exports[`GenerateModuleJniH can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleJniH can generate fixture real_module_example 1`] = ` Map { - "jni/REAL_MODULE_EXAMPLE.h" => " + "jni/real_module_example.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -230,12 +586,13 @@ public: }; -std::shared_ptr REAL_MODULE_EXAMPLE_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr real_module_example_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. @@ -249,10 +606,11 @@ LOCAL_MODULE := react_codegen_real_module_example LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/real_module_example/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/real_module_example -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -260,18 +618,63 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/real_module_example/*.cpp) + +add_library( + react_codegen_real_module_example + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_real_module_example PUBLIC . react/renderer/components/real_module_example) + +target_link_libraries( + react_codegen_real_module_example + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_real_module_example + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; -exports[`GenerateModuleJniH can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleJniH can generate fixture simple_native_modules 1`] = ` Map { - "jni/SIMPLE_NATIVE_MODULES.h" => " + "jni/simple_native_modules.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -294,12 +697,13 @@ public: }; -std::shared_ptr SIMPLE_NATIVE_MODULES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr simple_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. @@ -313,10 +717,11 @@ LOCAL_MODULE := react_codegen_simple_native_modules LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/simple_native_modules/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/simple_native_modules -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -324,18 +729,63 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/simple_native_modules/*.cpp) + +add_library( + react_codegen_simple_native_modules + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_simple_native_modules PUBLIC . react/renderer/components/simple_native_modules) + +target_link_libraries( + react_codegen_simple_native_modules + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_simple_native_modules + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; -exports[`GenerateModuleJniH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleJniH can generate fixture two_modules_different_files 1`] = ` Map { - "jni/TWO_MODULES_DIFFERENT_FILES.h" => " + "jni/two_modules_different_files.h" => " /** - * Copyright (c) Facebook, Inc. and its affiliates. + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleJniH.js */ @@ -366,12 +816,13 @@ public: }; -std::shared_ptr TWO_MODULES_DIFFERENT_FILES_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); +JSI_EXPORT +std::shared_ptr two_modules_different_files_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react } // namespace facebook ", - "jni/Android.mk" => "# Copyright (c) Facebook, Inc. and its affiliates. + "jni/Android.mk" => "# 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. @@ -385,10 +836,11 @@ LOCAL_MODULE := react_codegen_two_modules_different_files LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/two_modules_different_files/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/two_modules_different_files -LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libfbjni libturbomodulejsijni libreact_codegen_rncore libreact_debug libreact_render_debug +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga LOCAL_CFLAGS := \\\\ -DLOG_TAG=\\\\\\"ReactNative\\\\\\" @@ -396,6 +848,51 @@ LOCAL_CFLAGS := \\\\ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/two_modules_different_files/*.cpp) + +add_library( + react_codegen_two_modules_different_files + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_two_modules_different_files PUBLIC . react/renderer/components/two_modules_different_files) + +target_link_libraries( + react_codegen_two_modules_different_files + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_two_modules_different_files + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) ", } `; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap index 3053a5fee6acc6..3b2acb73c23930 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateModuleMm can generate fixture COMPLEX_OBJECTS 1`] = ` +exports[`GenerateModuleMm can generate fixture SampleWithUppercaseName 1`] = ` Map { - "COMPLEX_OBJECTS-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "SampleWithUppercaseName-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -15,7 +15,39 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"COMPLEX_OBJECTS.h\\" +#import \\"SampleWithUppercaseName.h\\" + + +namespace facebook { + namespace react { + + + NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms) + : ObjCTurboModule(params) { + + } + } // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleMm can generate fixture complex_objects 1`] = ` +Map { + "complex_objects-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#import \\"complex_objects.h\\" @implementation RCTCxxConvert (NativeSampleTurboModule_SpecDifficultAE) + (RCTManagedPointer *)JS_NativeSampleTurboModule_SpecDifficultAE:(id)json @@ -72,6 +104,18 @@ namespace facebook { return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, \\"getArrays\\", @selector(getArrays:), args, count); } + static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableObject(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, ObjectKind, \\"getNullableObject\\", @selector(getNullableObject), args, count); + } + + static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableGenericObject(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, ObjectKind, \\"getNullableGenericObject\\", @selector(getNullableGenericObject), args, count); + } + + static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableArray(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, ArrayKind, \\"getNullableArray\\", @selector(getNullableArray), args, count); + } + NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms) : ObjCTurboModule(params) { @@ -86,6 +130,15 @@ namespace facebook { methodMap_[\\"getArrays\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArrays}; setMethodArgConversionSelector(@\\"getArrays\\", 0, @\\"JS_NativeSampleTurboModule_SpecGetArraysOptions:\\"); + + methodMap_[\\"getNullableObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableObject}; + + + methodMap_[\\"getNullableGenericObject\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableGenericObject}; + + + methodMap_[\\"getNullableArray\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_getNullableArray}; + } } // namespace react } // namespace facebook @@ -93,13 +146,35 @@ namespace facebook { } `; -exports[`GenerateModuleMm can generate fixture EMPTY_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleMm can generate fixture cxx_only_native_modules 1`] = ` +Map { + "cxx_only_native_modules-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#import \\"cxx_only_native_modules.h\\" + + +", +} +`; + +exports[`GenerateModuleMm can generate fixture empty_native_modules 1`] = ` Map { - "EMPTY_NATIVE_MODULES-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "empty_native_modules-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -108,7 +183,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"EMPTY_NATIVE_MODULES.h\\" +#import \\"empty_native_modules.h\\" namespace facebook { @@ -125,13 +200,13 @@ namespace facebook { } `; -exports[`GenerateModuleMm can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` +exports[`GenerateModuleMm can generate fixture native_modules_with_type_aliases 1`] = ` Map { - "NATIVE_MODULES_WITH_TYPE_ALIASES-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "native_modules_with_type_aliases-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -140,7 +215,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"NATIVE_MODULES_WITH_TYPE_ALIASES.h\\" +#import \\"native_modules_with_type_aliases.h\\" @implementation RCTCxxConvert (AliasTurboModule_OptionsOffset) + (RCTManagedPointer *)JS_AliasTurboModule_OptionsOffset:(id)json @@ -185,13 +260,13 @@ namespace facebook { } `; -exports[`GenerateModuleMm can generate fixture REAL_MODULE_EXAMPLE 1`] = ` +exports[`GenerateModuleMm can generate fixture real_module_example 1`] = ` Map { - "REAL_MODULE_EXAMPLE-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "real_module_example-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -200,7 +275,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"REAL_MODULE_EXAMPLE.h\\" +#import \\"real_module_example.h\\" @implementation RCTCxxConvert (NativeCameraRollManager_GetPhotosParams) + (RCTManagedPointer *)JS_NativeCameraRollManager_GetPhotosParams:(id)json @@ -317,13 +392,13 @@ namespace facebook { } `; -exports[`GenerateModuleMm can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` +exports[`GenerateModuleMm can generate fixture simple_native_modules 1`] = ` Map { - "SIMPLE_NATIVE_MODULES-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "simple_native_modules-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -332,7 +407,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"SIMPLE_NATIVE_MODULES.h\\" +#import \\"simple_native_modules.h\\" namespace facebook { @@ -424,13 +499,13 @@ namespace facebook { } `; -exports[`GenerateModuleMm can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` +exports[`GenerateModuleMm can generate fixture two_modules_different_files 1`] = ` Map { - "TWO_MODULES_DIFFERENT_FILES-generated.mm" => "/** - * Copyright (c) Facebook, Inc. and its affiliates. + "two_modules_different_files-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. * * @generated by codegen project: GenerateModuleObjCpp * @@ -439,7 +514,7 @@ Map { * must have a single output. More files => more genrule()s => slower builds. */ -#import \\"TWO_MODULES_DIFFERENT_FILES.h\\" +#import \\"two_modules_different_files.h\\" namespace facebook { diff --git a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/failures.js b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/failures.js index b5a8f8a127cc56..1d7072636a48a8 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/failures.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/failures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,11 +8,13 @@ * @format */ +// @licenselint-loose-mode + 'use strict'; const COMMANDS_DEFINED_INLINE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -48,7 +50,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_MULTIPLE_TIMES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -89,7 +91,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_WITHOUT_REF = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -127,7 +129,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_WITH_NULLABLE_REF = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -165,7 +167,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -208,7 +210,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_WITHOUT_METHOD_NAMES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -249,7 +251,7 @@ export default (codegenNativeComponent( const NULLABLE_WITH_DEFAULT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -278,7 +280,7 @@ export default (codegenNativeComponent( const NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -307,7 +309,7 @@ export default (codegenNativeComponent( const PROPS_CONFLICT_NAMES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -337,7 +339,7 @@ export default (codegenNativeComponent( const PROPS_CONFLICT_WITH_SPREAD_PROPS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -371,7 +373,7 @@ export default (codegenNativeComponent( const PROPS_SPREAD_CONFLICTS_WITH_PROPS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -405,7 +407,7 @@ export default (codegenNativeComponent( const PROP_NUMBER_TYPE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -434,7 +436,7 @@ export default (codegenNativeComponent( const PROP_MIXED_ENUM = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -463,7 +465,7 @@ export default (codegenNativeComponent( const PROP_ENUM_BOOLEAN = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -492,7 +494,7 @@ export default (codegenNativeComponent( const PROP_ARRAY_MIXED_ENUM = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -521,7 +523,7 @@ export default (codegenNativeComponent( const PROP_ARRAY_ENUM_BOOLEAN = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -550,7 +552,7 @@ export default (codegenNativeComponent( const PROP_ARRAY_ENUM_INT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js index ef77f69d312742..6c94f1065b0c24 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,6 +8,8 @@ * @format */ +// @licenselint-loose-mode + 'use strict'; const EVENT_DEFINITION = ` @@ -86,7 +88,7 @@ const EVENT_DEFINITION = ` const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -126,7 +128,7 @@ export default (codegenNativeComponent('Module', { const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -167,7 +169,7 @@ export default codegenNativeComponent('Module', { const NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -194,7 +196,7 @@ export default (codegenNativeComponent('Module', { const ALL_PROP_TYPES_NO_EVENTS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -318,7 +320,7 @@ export default (codegenNativeComponent( const ARRAY_PROP_TYPES_NO_EVENTS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -471,7 +473,7 @@ export default (codegenNativeComponent( const OBJECT_PROP_TYPES_NO_EVENTS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -563,7 +565,7 @@ export default (codegenNativeComponent( const PROPS_ALIASED_LOCALLY = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -608,7 +610,7 @@ export default (codegenNativeComponent( const EVENTS_DEFINED_INLINE_WITH_ALL_TYPES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -717,7 +719,7 @@ export default (codegenNativeComponent( const EVENTS_DEFINED_AS_NULL_INLINE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -766,7 +768,7 @@ export default (codegenNativeComponent( const PROPS_AND_EVENTS_TYPES_EXPORTED = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -809,7 +811,7 @@ export default (codegenNativeComponent( const PROPS_AS_EXTERNAL_TYPES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -839,7 +841,7 @@ export default (codegenNativeComponent( const COMMANDS_DEFINED_WITH_ALL_TYPES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -889,7 +891,7 @@ export default (codegenNativeComponent( const COMMANDS_WITH_EXTERNAL_TYPES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -939,7 +941,7 @@ export default (codegenNativeComponent( const COMMANDS_AND_EVENTS_TYPES_EXPORTED = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 48836ae868944b..5f52a06d543815 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -16,7 +16,7 @@ exports[`RN Codegen Flow Parser Fails with error message NON_OPTIONAL_KEY_WITH_D exports[`RN Codegen Flow Parser Fails with error message NULLABLE_WITH_DEFAULT 1`] = `"WithDefault<> is optional and does not need to be marked as optional. Please remove the ? annotation in front of it."`; -exports[`RN Codegen Flow Parser Fails with error message PROP_ARRAY_ENUM_BOOLEAN 1`] = `"Unsupported union type for \\"someProp\\", recieved \\"BooleanLiteralTypeAnnotation\\""`; +exports[`RN Codegen Flow Parser Fails with error message PROP_ARRAY_ENUM_BOOLEAN 1`] = `"Unsupported union type for \\"someProp\\", received \\"BooleanLiteralTypeAnnotation\\""`; exports[`RN Codegen Flow Parser Fails with error message PROP_ARRAY_ENUM_INT 1`] = `"Arrays of int enums are not supported (see: \\"someProp\\")"`; diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js b/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js index 9c93fe7f7c85ac..8c5a3c3457a806 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index 48756da897a77e..163b5feb5e6714 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/events.js b/packages/react-native-codegen/src/parsers/flow/components/events.js index f6c68c80fcd578..a6a788a467d86e 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/events.js +++ b/packages/react-native-codegen/src/parsers/flow/components/events.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -17,9 +17,11 @@ import type { } from '../../../CodegenSchema.js'; function getPropertyType( + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ name, - optional, - typeAnnotation, + optional: boolean, + typeAnnotation: $FlowFixMe, ): NamedShape { const type = typeAnnotation.type === 'GenericTypeAnnotation' @@ -98,10 +100,10 @@ function getPropertyType( } function findEventArgumentsAndType( - typeAnnotation, - types, - bubblingType, - paperName, + typeAnnotation: $FlowFixMe, + types: TypeMap, + bubblingType: void | 'direct' | 'bubble', + paperName: ?$FlowFixMe, ) { if (!typeAnnotation.id) { throw new Error("typeAnnotation of event doesn't have a name"); @@ -151,6 +153,8 @@ function findEventArgumentsAndType( } } +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ function buildPropertiesForEvent(property): NamedShape { const name = property.key.name; const optional = @@ -163,7 +167,9 @@ function buildPropertiesForEvent(property): NamedShape { return getPropertyType(name, optional, typeAnnotation); } -function getEventArgument(argumentProps, name) { +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function getEventArgument(argumentProps, name: $FlowFixMe) { return { type: 'ObjectTypeAnnotation', properties: argumentProps.map(buildPropertiesForEvent), diff --git a/packages/react-native-codegen/src/parsers/flow/components/extends.js b/packages/react-native-codegen/src/parsers/flow/components/extends.js index 890329400a6206..5cd021512f1d77 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/extends.js +++ b/packages/react-native-codegen/src/parsers/flow/components/extends.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/index.js b/packages/react-native-codegen/src/parsers/flow/components/index.js index e49d40b98465e3..e488635d94300e 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/index.js +++ b/packages/react-native-codegen/src/parsers/flow/components/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,17 +9,19 @@ */ 'use strict'; -import type {CommandOptions} from './options'; import type {TypeDeclarationMap} from '../utils'; - +import type {CommandOptions} from './options'; import type {ComponentSchemaBuilderConfig} from './schema.js'; + +const {getTypes} = require('../utils'); const {getCommands} = require('./commands'); const {getEvents} = require('./events'); -const {getProps, getPropProperties} = require('./props'); -const {getCommandOptions, getOptions} = require('./options'); const {getExtendsProps, removeKnownExtends} = require('./extends'); -const {getTypes} = require('../utils'); +const {getCommandOptions, getOptions} = require('./options'); +const {getPropProperties, getProps} = require('./props'); +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ function findComponentConfig(ast) { const foundConfigs = []; @@ -41,9 +43,10 @@ function findComponentConfig(ast) { const typeArgumentParams = declaration.typeArguments.params; const funcArgumentParams = declaration.arguments; - const nativeComponentType = {}; - nativeComponentType.propsTypeName = typeArgumentParams[0].id.name; - nativeComponentType.componentName = funcArgumentParams[0].value; + const nativeComponentType: {[string]: string} = { + propsTypeName: typeArgumentParams[0].id.name, + componentName: funcArgumentParams[0].value, + }; if (funcArgumentParams.length > 1) { nativeComponentType.optionsExpression = funcArgumentParams[1]; } @@ -122,6 +125,8 @@ function findComponentConfig(ast) { } function getCommandProperties( + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ commandTypeName, types: TypeDeclarationMap, commandOptions: ?CommandOptions, @@ -174,6 +179,8 @@ function getCommandProperties( } // $FlowFixMe[signature-verification-failure] there's no flowtype for AST +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ function buildComponentSchema(ast): ComponentSchemaBuilderConfig { const { componentName, diff --git a/packages/react-native-codegen/src/parsers/flow/components/options.js b/packages/react-native-codegen/src/parsers/flow/components/options.js index 8a137c5cd7c911..beb032eae320ab 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/options.js +++ b/packages/react-native-codegen/src/parsers/flow/components/options.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/components/props.js b/packages/react-native-codegen/src/parsers/flow/components/props.js index aad5402450045e..003f47bed2e29e 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/props.js +++ b/packages/react-native-codegen/src/parsers/flow/components/props.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -9,6 +9,7 @@ */ 'use strict'; +import type {ASTNode} from '../utils'; const {getValueFromTypes} = require('../utils.js'); @@ -166,7 +167,7 @@ function getTypeAnnotationForArray( ); } else { throw new Error( - `Unsupported union type for "${name}", recieved "${unionType}"`, + `Unsupported union type for "${name}", received "${unionType}"`, ); } default: @@ -177,7 +178,7 @@ function getTypeAnnotationForArray( function getTypeAnnotation( name: string, - annotation, + annotation: $FlowFixMe | ASTNode, defaultValue: $FlowFixMe | null, withNullDefault: boolean, types: TypeDeclarationMap, @@ -319,6 +320,10 @@ function getTypeAnnotation( `Unsupported union type for "${name}", received "${unionType}"`, ); } + case 'ObjectTypeAnnotation': + throw new Error( + `Cannot use "${type}" type annotation for "${name}": object types must be declared using $ReadOnly<>`, + ); case 'NumberTypeAnnotation': throw new Error( `Cannot use "${type}" type annotation for "${name}": must use a specific numeric type like Int32, Double, or Float`, diff --git a/packages/react-native-codegen/src/parsers/flow/components/schema.js b/packages/react-native-codegen/src/parsers/flow/components/schema.js index 21ce46d6856ea0..ed6223c3347b50 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/components/schema.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/errors.js b/packages/react-native-codegen/src/parsers/flow/errors.js index b480f321f592a4..41fc7f8ca4eed5 100644 --- a/packages/react-native-codegen/src/parsers/flow/errors.js +++ b/packages/react-native-codegen/src/parsers/flow/errors.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/index.js b/packages/react-native-codegen/src/parsers/flow/index.js index b7550b07a77213..516025223e7694 100644 --- a/packages/react-native-codegen/src/parsers/flow/index.js +++ b/packages/react-native-codegen/src/parsers/flow/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/failures.js b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/failures.js index be76b9039dec8b..8024079b0fb683 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/failures.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/failures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,11 +8,13 @@ * @format */ +// @licenselint-loose-mode + 'use strict'; const NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -36,7 +38,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -60,7 +62,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULES_WITH_READ_ONLY_OBJECT_NO_TYPE_FOR_CONTENT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -84,7 +86,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULES_WITH_NOT_ONLY_METHODS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -112,7 +114,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULES_WITH_UNNAMED_PARAMS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -137,7 +139,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -162,7 +164,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -184,7 +186,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule2'); const TWO_NATIVE_EXTENDING_TURBO_MODULE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js index e05e185232ca59..cbbc156c29f97c 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,11 +8,13 @@ * @format */ +// @licenselint-loose-mode + 'use strict'; const EMPTY_NATIVE_MODULE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -36,7 +38,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_COMPLEX_OBJECTS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -71,7 +73,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -101,13 +103,13 @@ export interface Spec extends TurboModule { |}; } -export default TurboModuleRegistry.getEnforcing('PlatformConstants'); +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); `; const NATIVE_MODULE_WITH_BASIC_PARAM_TYPES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -134,7 +136,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_ALIASES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -159,7 +161,8 @@ export type ObjectAlias = {| y: number, label: string, truthy: boolean, -|} +|}; +export type ReadOnlyAlias = $ReadOnly; export interface Spec extends TurboModule { // Exported methods. @@ -167,6 +170,9 @@ export interface Spec extends TurboModule { +getVoid: () => Void; +getArray: (a: Array) => {| a: B |}; +getStringFromAlias: (a: ObjectAlias) => string; + +getStringFromNullableAlias: (a: ?ObjectAlias) => string; + +getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string; + +getStringFromNullableReadOnlyAlias: (a: ?ReadOnlyAlias) => string; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); @@ -175,7 +181,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_NESTED_ALIASES = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -210,7 +216,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_FLOAT_AND_INT32 = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -235,7 +241,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_SIMPLE_OBJECT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -259,7 +265,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_UNSAFE_OBJECT = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -284,7 +290,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_ROOT_TAG = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -308,7 +314,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_NULLABLE_PARAM = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -333,7 +339,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_BASIC_ARRAY = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -358,7 +364,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -395,7 +401,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -419,7 +425,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -445,7 +451,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_COMPLEX_ARRAY = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -467,8 +473,9 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); `; -const NATIVE_MODULE_WITH_PROMISE = `/** - * Copyright (c) Facebook, Inc. and its affiliates. +const NATIVE_MODULE_WITH_PROMISE = ` +/** + * 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. @@ -497,7 +504,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const NATIVE_MODULE_WITH_CALLBACK = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -524,7 +531,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); const ANDROID_ONLY_NATIVE_MODULE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -548,7 +555,7 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModuleAndroid' const IOS_ONLY_NATIVE_MODULE = ` /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -570,6 +577,31 @@ export default TurboModuleRegistry.getEnforcing('SampleTurboModuleIOS'); `; +const CXX_ONLY_NATIVE_MODULE = ` +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + +getCallback: () => () => void; + +getMixed: (arg: mixed) => mixed; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModuleCxx'); + +`; + module.exports = { NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY, NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE, @@ -591,4 +623,5 @@ module.exports = { EMPTY_NATIVE_MODULE, ANDROID_ONLY_NATIVE_MODULE, IOS_ONLY_NATIVE_MODULE, + CXX_ONLY_NATIVE_MODULE, }; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap index b17885a171e66c..aef18a0ef6c783 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap @@ -36,6 +36,62 @@ exports[`RN Codegen Flow Parser can generate fixture ANDROID_ONLY_NATIVE_MODULE }" `; +exports[`RN Codegen Flow Parser can generate fixture CXX_ONLY_NATIVE_MODULE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getCallback', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [] + }, + 'params': [] + } + }, + { + 'name': 'getMixed', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'MixedTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModuleCxx' + ], + 'excludedPlatforms': [ + 'iOS', + 'android' + ] + } + } +}" +`; + exports[`RN Codegen Flow Parser can generate fixture EMPTY_NATIVE_MODULE 1`] = ` "{ 'modules': { @@ -195,6 +251,72 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ALIASES } ] } + }, + { + 'name': 'getStringFromNullableAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } + }, + { + 'name': 'getStringFromReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + ] + } + }, + { + 'name': 'getStringFromNullableReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } } ] }, @@ -884,7 +1006,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_COMPLEX_ ] }, 'moduleNames': [ - 'PlatformConstants' + 'SampleTurboModule' ] } } diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js index 411890dec515b7..25c9d178d7d0ac 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -712,7 +712,7 @@ describe('Flow Module Parser', () => { const RETURN_TYPE_DESCRIPTION = IS_RETURN_TYPE_NULLABLE ? 'a nullable' : 'a non-nullable'; - const annotateRet = retType => + const annotateRet = (retType: string) => IS_RETURN_TYPE_NULLABLE ? `?${retType}` : retType; function parseReturnType( @@ -927,7 +927,7 @@ describe('Flow Module Parser', () => { ? 'an optional' : 'a required'; - function annotateProp(propName, propType) { + function annotateProp(propName: string, propType: string) { if (nullable && optional) { return `${propName}?: ?${propType}`; } @@ -1229,7 +1229,7 @@ describe('Flow Module Parser', () => { }); }); -function parseModule(source) { +function parseModule(source: string) { const schema = parseString(source, `${MODULE_NAME}.js`); const module = schema.modules.NativeFoo; invariant( diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js index cd32e108ef379e..103c80e8c1e044 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/modules/errors.js b/packages/react-native-codegen/src/parsers/flow/modules/errors.js index ea35c9ef66c7eb..c8bb4253885e66 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/errors.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/errors.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 63e14547608834..38ce80db4e746c 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -70,6 +70,7 @@ function translateTypeAnnotation( types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, tryParse: ParserErrorCapturer, + cxxOnly: boolean, ): Nullable { const {nullable, typeAnnotation, typeAliasResolutionStatus} = resolveTypeAnnotation(flowTypeAnnotation, types); @@ -121,6 +122,7 @@ function translateTypeAnnotation( * to be parseable. */ nullGuard, + cxxOnly, ), ); @@ -171,13 +173,18 @@ function translateTypeAnnotation( typeAnnotation, ); - return translateTypeAnnotation( - hasteModuleName, - typeAnnotation.typeParameters.params[0], - types, - aliasMap, - tryParse, + const [paramType, isParamNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typeAnnotation.typeParameters.params[0], + types, + aliasMap, + tryParse, + cxxOnly, + ), ); + + return wrapNullable(nullable || isParamNullable, paramType); } case 'Stringish': { return wrapNullable(nullable, { @@ -239,6 +246,7 @@ function translateTypeAnnotation( types, aliasMap, tryParse, + cxxOnly, ), ); @@ -355,9 +363,18 @@ function translateTypeAnnotation( types, aliasMap, tryParse, + cxxOnly, ), ); } + case 'MixedTypeAnnotation': { + if (cxxOnly) { + return wrapNullable(nullable, { + type: 'MixedTypeAnnotation', + }); + } + // Fallthrough + } default: { throw new UnsupportedFlowTypeAnnotationParserError( hasteModuleName, @@ -401,6 +418,7 @@ function translateFunctionTypeAnnotation( types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, tryParse: ParserErrorCapturer, + cxxOnly: boolean, ): NativeModuleFunctionTypeAnnotation { type Param = NamedShape>; const params: Array = []; @@ -420,6 +438,7 @@ function translateFunctionTypeAnnotation( types, aliasMap, tryParse, + cxxOnly, ), ); @@ -463,10 +482,11 @@ function translateFunctionTypeAnnotation( types, aliasMap, tryParse, + cxxOnly, ), ); - if (returnTypeAnnotation.type === 'FunctionTypeAnnotation') { + if (!cxxOnly && returnTypeAnnotation.type === 'FunctionTypeAnnotation') { throw new UnsupportedFunctionReturnTypeAnnotationParserError( hasteModuleName, flowFunctionTypeAnnotation.returnType, @@ -494,6 +514,7 @@ function buildPropertySchema( types: TypeDeclarationMap, aliasMap: {...NativeModuleAliasMap}, tryParse: ParserErrorCapturer, + cxxOnly: boolean, ): NativeModulePropertyShape { let nullable = false; let {key, value} = property; @@ -522,12 +543,13 @@ function buildPropertySchema( types, aliasMap, tryParse, + cxxOnly, ), ), }; } -function isModuleInterface(node) { +function isModuleInterface(node: $FlowFixMe) { return ( node.type === 'InterfaceDeclaration' && node.extends.length === 1 && @@ -653,6 +675,7 @@ function buildModuleSchema( // Eventually this should be made explicit in the Flow type itself. // Also check the hasteModuleName for platform suffix. // Note: this shape is consistent with ComponentSchema. + let cxxOnly = false; const excludedPlatforms = []; const namesToValidate = [...moduleNames, hasteModuleName]; namesToValidate.forEach(name => { @@ -660,6 +683,9 @@ function buildModuleSchema( excludedPlatforms.push('iOS'); } else if (name.endsWith('IOS')) { excludedPlatforms.push('android'); + } else if (name.endsWith('Cxx')) { + cxxOnly = true; + excludedPlatforms.push('iOS', 'android'); } }); @@ -680,6 +706,7 @@ function buildModuleSchema( types, aliasMap, tryParse, + cxxOnly, ), })); }) diff --git a/packages/react-native-codegen/src/parsers/flow/modules/schema.js b/packages/react-native-codegen/src/parsers/flow/modules/schema.js index da3da6a4947649..4e3fda6bea4a90 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/schema.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/modules/utils.js b/packages/react-native-codegen/src/parsers/flow/modules/utils.js index 8b8aa0b0648d3e..b013f76c8ce59e 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/utils.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/utils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/flow/utils.js b/packages/react-native-codegen/src/parsers/flow/utils.js index 70d4536a12ef25..86547dc9b85589 100644 --- a/packages/react-native-codegen/src/parsers/flow/utils.js +++ b/packages/react-native-codegen/src/parsers/flow/utils.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -197,6 +197,11 @@ function isModuleRegistryCall(node: $FlowFixMe): boolean { ) { return false; } + + if (memberExpression.computed) { + return false; + } + return true; } diff --git a/packages/react-native-codegen/src/parsers/schema/index.js b/packages/react-native-codegen/src/parsers/schema/index.js index bf736a725fa052..646aa86fcee82d 100644 --- a/packages/react-native-codegen/src/parsers/schema/index.js +++ b/packages/react-native-codegen/src/parsers/schema/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/failures.js b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/failures.js new file mode 100644 index 00000000000000..eefd9e316f18e5 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/failures.js @@ -0,0 +1,505 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +// @licenselint-loose-mode + +'use strict'; + +const COMMANDS_DEFINED_INLINE = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + // No props +} + +export const Commands = codegenNativeCommands<{ + readonly hotspotUpdate: ( + ref: React.Ref<'RCTView'>, + x: Int32, + y: Int32, + ) => void; +}>({ + supportedCommands: ['hotspotUpdate'], +}); + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_MULTIPLE_TIMES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +interface NativeCommands { + readonly hotspotUpdate: ( + viewRef: React.Ref<'RCTView'>, + x: Int32, + y: Int32, + ) => void; +} + +export interface ModuleProps extends ViewProps { + // No props or events +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['hotspotUpdate'], +}); +export const Commands2 = codegenNativeCommands({ + supportedCommands: ['hotspotUpdate'], +}); + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_WITHOUT_REF = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +interface NativeCommands { + readonly hotspotUpdate: (x: Int32, y: Int32) => void; +} + +export interface ModuleProps extends ViewProps { + // No props or events +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['hotspotUpdate'], +}); + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_WITH_NULLABLE_REF = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +interface NativeCommands { + readonly hotspotUpdate: (viewRef: React.Ref<'RCTView'> | null | undefined, x: Int32, y: Int32) => void; +} + +export interface ModuleProps extends ViewProps { + // No props or events +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['hotspotUpdate'], +}); + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +interface NativeCommands { + readonly hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; + readonly scrollTo: ( + viewRef: React.Ref<'RCTView'>, + y: Int32, + animated: boolean, + ) => void; +} + +export interface ModuleProps extends ViewProps { + // No props or events +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['scrollTo'], +}); +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_WITHOUT_METHOD_NAMES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +interface NativeCommands { + readonly hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void; + readonly scrollTo: ( + viewRef: React.Ref<'RCTView'>, + y: Int32, + animated: boolean, + ) => void; +} + +export interface ModuleProps extends ViewProps { + // No props or events +} + +export const Commands = codegenNativeCommands(); + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const NULLABLE_WITH_DEFAULT = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {WithDefault, Float} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + nullable_with_default: WithDefault | null | undefined; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {WithDefault, Float} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + required_key_with_default: WithDefault; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROPS_CONFLICT_NAMES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + isEnabled: string, + + isEnabled: boolean, +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROPS_CONFLICT_WITH_SPREAD_PROPS = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +type PropsInFile = Readonly<{ + isEnabled: boolean, +}>; + +export interface ModuleProps extends ViewProps, PropsInFile { + isEnabled: boolean, +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_NUMBER_TYPE = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + someProp: number +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_MIXED_ENUM = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type {WithDefault} from 'CodegenTypes'; + +export interface ModuleProps extends ViewProps { + someProp?: WithDefault<'foo' | 1, 1>; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_ENUM_BOOLEAN = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type {WithDefault} from 'CodegenTypes'; + +export interface ModuleProps extends ViewProps { + someProp?: WithDefault +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_ARRAY_MIXED_ENUM = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type {WithDefault} from 'CodegenTypes'; + +export interface ModuleProps extends ViewProps { + someProp?: WithDefault, 1>; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_ARRAY_ENUM_BOOLEAN = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type {WithDefault} from 'CodegenTypes'; + +export interface ModuleProps extends ViewProps { + someProp?: WithDefault, false>; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROP_ARRAY_ENUM_INT = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type {WithDefault} from 'CodegenTypes'; + +export interface ModuleProps extends ViewProps { + someProp?: WithDefault, 0>; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +module.exports = { + COMMANDS_DEFINED_INLINE, + COMMANDS_DEFINED_MULTIPLE_TIMES, + COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES, + COMMANDS_DEFINED_WITHOUT_METHOD_NAMES, + COMMANDS_DEFINED_WITHOUT_REF, + COMMANDS_DEFINED_WITH_NULLABLE_REF, + NULLABLE_WITH_DEFAULT, + NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE, + PROPS_CONFLICT_NAMES, + PROPS_CONFLICT_WITH_SPREAD_PROPS, + PROP_NUMBER_TYPE, + PROP_MIXED_ENUM, + PROP_ENUM_BOOLEAN, + PROP_ARRAY_MIXED_ENUM, + PROP_ARRAY_ENUM_BOOLEAN, + PROP_ARRAY_ENUM_INT, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js new file mode 100644 index 00000000000000..cb1357c40127a1 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js @@ -0,0 +1,974 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +// @licenselint-loose-mode + +'use strict'; + +const EVENT_DEFINITION = ` + boolean_required: boolean; + boolean_optional_key?: boolean; + boolean_optional_value: boolean | null | undefined; + boolean_optional_both?: boolean | null | undefined; + + string_required: string; + string_optional_key?: string; + string_optional_value: string | null | undefined; + string_optional_both?: string | null | undefined; + + double_required: Double; + double_optional_key?: Double; + double_optional_value: Double | null | undefined; + double_optional_both?: Double | null | undefined; + + float_required: Float; + float_optional_key?: Float; + float_optional_value: Float | null | undefined; + float_optional_both?: Float | null | undefined; + + int32_required: Int32; + int32_optional_key?: Int32; + int32_optional_value: Int32 | null | undefined; + int32_optional_both?: Int32 | null | undefined; + + enum_required: 'small' | 'large'; + enum_optional_key?: 'small' | 'large'; + enum_optional_value: ('small' | 'large') | null | undefined; + enum_optional_both?: ('small' | 'large') | null | undefined; + + object_required: { + boolean_required: boolean; + }; + + object_optional_key?: { + string_optional_key?: string; + }; + + object_optional_value: { + float_optional_value: Float | null | undefined; + } | null | undefined; + + object_optional_both?: { + int32_optional_both?: Int32 | null | undefined; + } | null | undefined; + + object_required_nested_2_layers: { + object_optional_nested_1_layer?: { + boolean_required: Int32; + string_optional_key?: string; + double_optional_value: Double | null | undefined; + float_optional_value: Float | null | undefined; + int32_optional_both?: Int32 | null | undefined; + } | null | undefined; + }; + + object_readonly_required: Readonly<{ + boolean_required: boolean; + }>; + + object_readonly_optional_key?: Readonly<{ + string_optional_key?: string; + }>; + + object_readonly_optional_value: Readonly<{ + float_optional_value: Float | null | undefined; + }> | null | undefined; + + object_readonly_optional_both?: Readonly<{ + int32_optional_both?: Int32 | null | undefined; + }> | null | undefined; +`; + +const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +import type { + BubblingEventHandler, + DirectEventHandler, + WithDefault, +} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +export interface ModuleProps extends ViewProps { + // Props + boolean_default_true_optional_both?: WithDefault; + + // Events + onDirectEventDefinedInlineNull: DirectEventHandler; + onBubblingEventDefinedInlineNull: BubblingEventHandler; +} + +export default codegenNativeComponent('Module', { + interfaceOnly: true, + paperComponentName: 'RCTModule', +}) as HostComponent; +`; + +const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type { + BubblingEventHandler, + DirectEventHandler, + WithDefault, +} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + // Props + boolean_default_true_optional_both?: WithDefault; + + // Events + onDirectEventDefinedInlineNull: DirectEventHandler; + onBubblingEventDefinedInlineNull: BubblingEventHandler; +} + +export default codegenNativeComponent('Module', { + interfaceOnly: true, + excludedPlatforms: ['android'], + paperComponentName: 'RCTModule', +}) as HostComponent; +`; + +const NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + +} + +export default codegenNativeComponent('Module', { + deprecatedViewConfigName: 'DeprecateModuleName', +}) as HostComponent; +`; + +const ALL_PROP_TYPES_NO_EVENTS = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32, Double, Float, WithDefault} from 'CodegenTypes'; +import type {ImageSource} from 'ImageSource'; +import type { + ColorValue, + ColorArrayValue, + PointValue, + EdgeInsetsValue, +} from 'StyleSheetTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + // Props + // Boolean props + boolean_required: boolean; + boolean_optional_key?: WithDefault; + boolean_optional_both?: WithDefault; + + // Boolean props, null default + boolean_null_optional_key?: WithDefault; + boolean_null_optional_both?: WithDefault; + + // String props + string_required: string; + string_optional_key?: WithDefault; + string_optional_both?: WithDefault; + + // String props, null default + string_null_optional_key?: WithDefault; + string_null_optional_both?: WithDefault; + + // Stringish props + stringish_required: Stringish; + stringish_optional_key?: WithDefault; + stringish_optional_both?: WithDefault; + + // Stringish props, null default + stringish_null_optional_key?: WithDefault; + stringish_null_optional_both?: WithDefault; + + // Double props + double_required: Double; + double_optional_key?: WithDefault; + double_optional_both?: WithDefault; + + // Float props + float_required: Float; + float_optional_key?: WithDefault; + float_optional_both?: WithDefault; + + // Float props, null default + float_null_optional_key?: WithDefault; + float_null_optional_both?: WithDefault; + + // Int32 props + int32_required: Int32; + int32_optional_key?: WithDefault; + int32_optional_both?: WithDefault; + + // String enum props + enum_optional_key?: WithDefault<'small' | 'large', 'small'>; + enum_optional_both?: WithDefault<'small' | 'large', 'small'>; + + // Int enum props + int_enum_optional_key?: WithDefault<0 | 1, 0>; + + // Object props + object_optional_key?: Readonly<{prop: string}>; + object_optional_both?: Readonly<{prop: string} | null | undefined>; + object_optional_value: Readonly<{prop: string} | null | undefined>; + + // ImageSource props + image_required: ImageSource; + image_optional_value: ImageSource | null | undefined; + image_optional_both?: ImageSource | null | undefined; + + // ColorValue props + color_required: ColorValue; + color_optional_key?: ColorValue; + color_optional_value: ColorValue | null | undefined; + color_optional_both?: ColorValue | null | undefined; + + // ColorArrayValue props + color_array_required: ColorArrayValue; + color_array_optional_key?: ColorArrayValue; + color_array_optional_value: ColorArrayValue | null | undefined; + color_array_optional_both?: ColorArrayValue | null | undefined; + + // ProcessedColorValue props + processed_color_required: ProcessedColorValue; + processed_color_optional_key?: ProcessedColorValue; + processed_color_optional_value: ProcessedColorValue | null | undefined; + processed_color_optional_both?: ProcessedColorValue | null | undefined; + + // PointValue props + point_required: PointValue; + point_optional_key?: PointValue; + point_optional_value: PointValue | null | undefined; + point_optional_both?: PointValue | null | undefined; + + // EdgeInsets props + insets_required: EdgeInsetsValue; + insets_optional_key?: EdgeInsetsValue; + insets_optional_value: EdgeInsetsValue | null | undefined; + insets_optional_both?: EdgeInsetsValue | null | undefined; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const ARRAY_PROP_TYPES_NO_EVENTS = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32, Double, Float, WithDefault} from 'CodegenTypes'; +import type {ImageSource} from 'ImageSource'; +import type { + ColorValue, + ColorArrayValue, + PointValue, + EdgeInsetsValue, +} from 'StyleSheetTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +type ObjectType = Readonly<{prop: string}>; +type ArrayObjectType = ReadonlyArray>; + +export interface ModuleProps extends ViewProps { + // Props + // Boolean props + array_boolean_required: ReadonlyArray; + array_boolean_optional_key?: ReadonlyArray; + array_boolean_optional_value: ReadonlyArray | null | undefined; + array_boolean_optional_both?: ReadonlyArray | null | undefined; + + // String props + array_string_required: ReadonlyArray; + array_string_optional_key?: ReadonlyArray; + array_string_optional_value: ReadonlyArray | null | undefined; + array_string_optional_both?: ReadonlyArray | null | undefined; + + // Double props + array_double_required: ReadonlyArray; + array_double_optional_key?: ReadonlyArray; + array_double_optional_value: ReadonlyArray | null | undefined; + array_double_optional_both?: ReadonlyArray | null | undefined; + + // Float props + array_float_required: ReadonlyArray; + array_float_optional_key?: ReadonlyArray; + array_float_optional_value: ReadonlyArray | null | undefined; + array_float_optional_both?: ReadonlyArray | null | undefined; + + // Int32 props + array_int32_required: ReadonlyArray; + array_int32_optional_key?: ReadonlyArray; + array_int32_optional_value: ReadonlyArray | null | undefined; + array_int32_optional_both?: ReadonlyArray | null | undefined; + + // String enum props + array_enum_optional_key?: WithDefault< + ReadonlyArray<'small' | 'large'>, + 'small' + >; + array_enum_optional_both?: WithDefault< + ReadonlyArray<'small' | 'large'>, + 'small' + >; + + // ImageSource props + array_image_required: ReadonlyArray; + array_image_optional_key?: ReadonlyArray; + array_image_optional_value: ReadonlyArray | null | undefined; + array_image_optional_both?: ReadonlyArray | null | undefined; + + // ColorValue props + array_color_required: ReadonlyArray; + array_color_optional_key?: ReadonlyArray; + array_color_optional_value: ReadonlyArray | null | undefined; + array_color_optional_both?: ReadonlyArray | null | undefined; + + // PointValue props + array_point_required: ReadonlyArray; + array_point_optional_key?: ReadonlyArray; + array_point_optional_value: ReadonlyArray | null | undefined; + array_point_optional_both?: ReadonlyArray | null | undefined; + + // EdgeInsetsValue props + array_insets_required: ReadonlyArray; + array_insets_optional_key?: ReadonlyArray; + array_insets_optional_value: ReadonlyArray | null | undefined; + array_insets_optional_both?: ReadonlyArray | null | undefined; + + // Object props + array_object_required: ReadonlyArray>; + array_object_optional_key?: ReadonlyArray>; + array_object_optional_value: ArrayObjectType | null | undefined; + array_object_optional_both?: ReadonlyArray | null | undefined; + + // Nested array object types + array_of_array_object_required: ReadonlyArray< + Readonly<{ + // This needs to be the same name as the top level array above + array_object_required: ReadonlyArray>; + }> + >; + array_of_array_object_optional_key?: ReadonlyArray< + Readonly<{ + // This needs to be the same name as the top level array above + array_object_optional_key: ReadonlyArray>; + }> + >; + array_of_array_object_optional_value: ReadonlyArray< + Readonly<{ + // This needs to be the same name as the top level array above + array_object_optional_value: ReadonlyArray< + Readonly<{prop: string | null | undefined}> + >; + }> + > | null | undefined; + array_of_array_object_optional_both?: ReadonlyArray< + Readonly<{ + // This needs to be the same name as the top level array above + array_object_optional_both: ReadonlyArray< + Readonly<{prop?: string | null | undefined}> + >; + }> + > | null | undefined; + + // Nested array of array of object types + array_of_array_of_object_required: ReadonlyArray< + ReadonlyArray< + Readonly<{ + prop: string; + }> + > + >; + + // Nested array of array of object types (in file) + array_of_array_of_object_required_in_file: ReadonlyArray< + ReadonlyArray + >; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const OBJECT_PROP_TYPES_NO_EVENTS = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32, Double, Float, WithDefault} from 'CodegenTypes'; +import type {ImageSource} from 'ImageSource'; +import type { + ColorValue, + ColorArrayValue, + PointValue, + EdgeInsetsValue, +} from 'StyleSheetTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + // Props + // Boolean props + boolean_required: Readonly<{prop: boolean}>; + boolean_optional: Readonly<{prop?: WithDefault}>; + + // String props + string_required: Readonly<{prop: string}>; + string_optional: Readonly<{prop?: WithDefault}>; + + // Double props + double_required: Readonly<{prop: Double}>; + double_optional: Readonly<{prop?: WithDefault}>; + + // Float props + float_required: Readonly<{prop: Float}>; + float_optional: Readonly<{prop?: WithDefault}>; + + // Int32 props + int_required: Readonly<{prop: Int32}>; + int_optional: Readonly<{prop?: WithDefault}>; + + // String enum props + enum_optional: Readonly<{ + prop?: WithDefault, 'small'>; + }>; + + // ImageSource props + image_required: Readonly<{prop: ImageSource}>; + image_optional_key: Readonly<{prop?: ImageSource}>; + image_optional_value: Readonly<{prop: ImageSource | null | undefined}>; + image_optional_both: Readonly<{prop?: ImageSource | null | undefined}>; + + // ColorValue props + color_required: Readonly<{prop: ColorValue}>; + color_optional_key: Readonly<{prop?: ColorValue}>; + color_optional_value: Readonly<{prop: ColorValue | null | undefined}>; + color_optional_both: Readonly<{prop?: ColorValue | null | undefined}>; + + // ProcessedColorValue props + processed_color_required: Readonly<{prop: ProcessedColorValue}>; + processed_color_optional_key: Readonly<{prop?: ProcessedColorValue}>; + processed_color_optional_value: Readonly<{ + prop: ProcessedColorValue | null | undefined; + }>; + processed_color_optional_both: Readonly<{ + prop?: ProcessedColorValue | null | undefined; + }>; + + // PointValue props + point_required: Readonly<{prop: PointValue}>; + point_optional_key: Readonly<{prop?: PointValue}>; + point_optional_value: Readonly<{prop: PointValue | null | undefined}>; + point_optional_both: Readonly<{prop?: PointValue | null | undefined}>; + + // EdgeInsetsValue props + insets_required: Readonly<{prop: EdgeInsetsValue}>; + insets_optional_key: Readonly<{prop?: EdgeInsetsValue}>; + insets_optional_value: Readonly<{prop: EdgeInsetsValue | null | undefined}>; + insets_optional_both: Readonly<{prop?: EdgeInsetsValue | null | undefined}>; + + // Nested object props + object_required: Readonly<{prop: Readonly<{nestedProp: string}>}>; + object_optional_key?: Readonly<{prop: Readonly<{nestedProp: string}>}>; + object_optional_value: Readonly<{ + prop: Readonly<{nestedProp: string}>; + }> | null | undefined; + object_optional_both?: Readonly<{ + prop: Readonly<{nestedProp: string}>; + }> | null | undefined; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROPS_ALIASED_LOCALLY = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +type DeepSpread = Readonly<{ + otherStringProp: string; +}>; + +export interface PropsInFile extends DeepSpread { + isEnabled: boolean; + label: string; +} + +type ReadOnlyPropsInFile = Readonly; + +export interface ModuleProps extends ViewProps, ReadOnlyPropsInFile { + localType: ReadOnlyPropsInFile; + localArr: ReadonlyArray; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const EVENTS_DEFINED_INLINE_WITH_ALL_TYPES = ` +/** + * 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. + * + * @format + */ + +import type {HostComponent} from 'react-native'; +const codegenNativeComponent = require('codegenNativeComponent'); + +import type { + Int32, + Double, + Float, + BubblingEventHandler, + DirectEventHandler, +} from 'CodegenTypes'; + +import type {ViewProps} from 'ViewPropTypes'; + +export interface ModuleProps extends ViewProps { + // No Props + + // Events + onDirectEventDefinedInline: DirectEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + >; + + onDirectEventDefinedInlineOptionalKey?: DirectEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + >; + + onDirectEventDefinedInlineOptionalValue: DirectEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + > | null | undefined; + + onDirectEventDefinedInlineOptionalBoth?: DirectEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + > | null | undefined; + + onDirectEventDefinedInlineWithPaperName?: DirectEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }>, + 'paperDirectEventDefinedInlineWithPaperName' + > | null | undefined; + + onBubblingEventDefinedInline: BubblingEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + >; + + onBubblingEventDefinedInlineOptionalKey?: BubblingEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + >; + + onBubblingEventDefinedInlineOptionalValue: BubblingEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + > | null | undefined; + + onBubblingEventDefinedInlineOptionalBoth?: BubblingEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }> + > | null | undefined; + + onBubblingEventDefinedInlineWithPaperName?: BubblingEventHandler< + Readonly<{ + ${EVENT_DEFINITION} + }>, + 'paperBubblingEventDefinedInlineWithPaperName' + > | null | undefined; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const EVENTS_DEFINED_AS_NULL_INLINE = ` +/** + * 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. + * + * @format + */ + +'use strict'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {BubblingEventHandler, DirectEventHandler} from 'CodegenTypese'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export interface ModuleProps extends ViewProps { + // No props + + // Events defined inline + onDirectEventDefinedInlineNull: DirectEventHandler; + onDirectEventDefinedInlineNullOptionalKey?: DirectEventHandler; + onDirectEventDefinedInlineNullOptionalValue: DirectEventHandler | null | undefined; + onDirectEventDefinedInlineNullOptionalBoth?: DirectEventHandler; + onDirectEventDefinedInlineNullWithPaperName?: DirectEventHandler< + null, + 'paperDirectEventDefinedInlineNullWithPaperName' + > | null | undefined; + + onBubblingEventDefinedInlineNull: BubblingEventHandler; + onBubblingEventDefinedInlineNullOptionalKey?: BubblingEventHandler; + onBubblingEventDefinedInlineNullOptionalValue: BubblingEventHandler | null | undefined; + onBubblingEventDefinedInlineNullOptionalBoth?: BubblingEventHandler | null | undefined; + onBubblingEventDefinedInlineNullWithPaperName?: BubblingEventHandler< + null, + 'paperBubblingEventDefinedInlineNullWithPaperName' + > | null | undefined; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROPS_AND_EVENTS_TYPES_EXPORTED = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; +import type { + BubblingEventHandler, + DirectEventHandler, +} from 'CodegenTypes'; + +export type EventInFile = Readonly<{ + ${EVENT_DEFINITION} +}>; + +export interface ModuleProps extends ViewProps { + // No props + + // Events defined inline + onBubblingEventDefinedInline: BubblingEventHandler; + onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler< + EventInFile, + 'paperBubblingEventDefinedInlineWithPaperName' + >; + onDirectEventDefinedInline: DirectEventHandler; + onDirectEventDefinedInlineWithPaperName: DirectEventHandler< + EventInFile, + 'paperDirectEventDefinedInlineWithPaperName' + >; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const PROPS_AS_EXTERNAL_TYPES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {HostComponent} from 'react-native'; + +export type String = string; +export type AnotherArray = ReadonlyArray; + +export interface ModuleProps { + disable: String; + array: AnotherArray; +} + +export default codegenNativeComponent( + 'Module', +) as HostComponent; +`; + +const COMMANDS_DEFINED_WITH_ALL_TYPES = ` +/** + * 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. + * + * @format + */ + + const codegenNativeCommands = require('codegenNativeCommands'); + const codegenNativeComponent = require('codegenNativeComponent'); + + import type {Int32, Double, Float} from 'CodegenTypes'; + import type {RootTag} from 'RCTExport'; + import type {ViewProps} from 'ViewPropTypes'; + import type {HostComponent} from 'react-native'; + + +export interface ModuleProps extends ViewProps { + // No props or events +} + +type NativeType = HostComponent; + + interface NativeCommands { + readonly handleRootTag: (viewRef: React.ElementRef, rootTag: RootTag) => void; + readonly hotspotUpdate: (viewRef: React.ElementRef, x: Int32, y: Int32) => void; + readonly scrollTo: ( + viewRef: React.ElementRef, + x: Float, + y: Int32, + z: Double, + animated: boolean, + ) => void; + } + + export const Commands = codegenNativeCommands({ + supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'], + }); + +export default codegenNativeComponent( + 'Module', +) as NativeType; +`; + +const COMMANDS_WITH_EXTERNAL_TYPES = ` +/** + * 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. + * + * @format + */ + +const codegenNativeCommands = require('codegenNativeCommands'); +const codegenNativeComponent = require('codegenNativeComponent'); + +import type {Int32} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +export type Boolean = boolean; +export type Int = Int32; +export type Void = void; + +export interface ModuleProps extends ViewProps { + // No props or events +} + +type NativeType = HostComponent; + +export type ScrollTo = ( + viewRef: React.ElementRef, + y: Int, + animated: Boolean, +) => Void; + +interface NativeCommands { + readonly scrollTo: ScrollTo; +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['scrollTo'], +}); + +export default codegenNativeComponent('Module') as NativeType; + +`; + +const COMMANDS_AND_EVENTS_TYPES_EXPORTED = ` +/** + * 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. + * + * @format + */ + +import type { + BubblingEventHandler, + DirectEventHandler, +} from 'CodegenTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {HostComponent} from 'react-native'; + +const codegenNativeComponent = require('codegenNativeComponent'); + +export type EventInFile = Readonly<{ + ${EVENT_DEFINITION} +}>; + +export type Boolean = boolean; +export type Int = Int32; +export type Void = void; + +export interface ModuleProps extends ViewProps { + // No props + + // Events defined inline + onBubblingEventDefinedInline: BubblingEventHandler, + onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler, + onDirectEventDefinedInline: DirectEventHandler, + onDirectEventDefinedInlineWithPaperName: DirectEventHandler, +} + +type NativeType = HostComponent; + +export type ScrollTo = (viewRef: React.ElementRef, y: Int, animated: Boolean) => Void; + +interface NativeCommands { + readonly scrollTo: ScrollTo; +} + +export const Commands = codegenNativeCommands({ + supportedCommands: ['scrollTo'] +}); + +export default codegenNativeComponent( + 'Module', +) as NativeType; +`; + +module.exports = { + ALL_PROP_TYPES_NO_EVENTS, + ARRAY_PROP_TYPES_NO_EVENTS, + OBJECT_PROP_TYPES_NO_EVENTS, + PROPS_ALIASED_LOCALLY, + ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS, + ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST, + NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION, + EVENTS_DEFINED_INLINE_WITH_ALL_TYPES, + EVENTS_DEFINED_AS_NULL_INLINE, + PROPS_AND_EVENTS_TYPES_EXPORTED, + COMMANDS_AND_EVENTS_TYPES_EXPORTED, + COMMANDS_DEFINED_WITH_ALL_TYPES, + PROPS_AS_EXTERNAL_TYPES, + COMMANDS_WITH_EXTERNAL_TYPES, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap new file mode 100644 index 00000000000000..bfaa95fdbf9840 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap @@ -0,0 +1,9397 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_INLINE 1`] = `"codegenNativeCommands doesn't support inline definitions. Specify a file local type alias"`; + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_MULTIPLE_TIMES 1`] = `"codegenNativeCommands may only be called once in a file"`; + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITH_MISMATCHED_METHOD_NAMES 1`] = `"codegenNativeCommands expected the same supportedCommands specified in the NativeCommands interface: hotspotUpdate, scrollTo"`; + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITH_NULLABLE_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<>"`; + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITHOUT_METHOD_NAMES 1`] = `"codegenNativeCommands must be passed options including the supported commands"`; + +exports[`RN Codegen TypeScript Parser Fails with error message COMMANDS_DEFINED_WITHOUT_REF 1`] = `"The first argument of method hotspotUpdate must be of type React.ElementRef<>"`; + +exports[`RN Codegen TypeScript Parser Fails with error message NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE 1`] = `"key required_key_with_default must be optional if used with WithDefault<> annotation"`; + +exports[`RN Codegen TypeScript Parser Fails with error message NULLABLE_WITH_DEFAULT 1`] = `"WithDefault<> is optional and does not need to be marked as optional. Please remove the union of void and/or null"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_ARRAY_ENUM_BOOLEAN 1`] = `"Unsupported union type for \\"someProp\\", received \\"BooleanLiteral\\""`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_ARRAY_ENUM_INT 1`] = `"Arrays of int enums are not supported (see: \\"someProp\\")"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_ARRAY_MIXED_ENUM 1`] = `"Mixed types are not supported (see \\"someProp\\")"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_ENUM_BOOLEAN 1`] = `"Unsupported union type for \\"someProp\\", received \\"BooleanLiteral\\""`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_MIXED_ENUM 1`] = `"Mixed types are not supported (see \\"someProp\\")"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROP_NUMBER_TYPE 1`] = `"Cannot use \\"TSNumberKeyword\\" type annotation for \\"someProp\\": must use a specific numeric type like Int32, Double, or Float"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROPS_CONFLICT_NAMES 1`] = `"A prop was already defined with the name isEnabled"`; + +exports[`RN Codegen TypeScript Parser Fails with error message PROPS_CONFLICT_WITH_SPREAD_PROPS 1`] = `"A prop was already defined with the name isEnabled"`; + +exports[`RN Codegen TypeScript Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': true + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': true + } + }, + { + 'name': 'boolean_null_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': null + } + }, + { + 'name': 'boolean_null_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': null + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': '' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': '' + } + }, + { + 'name': 'string_null_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'string_null_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'stringish_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'stringish_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': '' + } + }, + { + 'name': 'stringish_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': '' + } + }, + { + 'name': 'stringish_null_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'stringish_null_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation', + 'default': 0 + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation', + 'default': 1.1 + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation', + 'default': 1.1 + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': 0 + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': 1.1 + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': 1.1 + } + }, + { + 'name': 'float_null_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': null + } + }, + { + 'name': 'float_null_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': null + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation', + 'default': 0 + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation', + 'default': 1 + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation', + 'default': 1 + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'default': 'small', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'default': 'small', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'int_enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32EnumTypeAnnotation', + 'default': 0, + 'options': [ + 0, + 1 + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + }, + { + 'name': 'image_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + }, + { + 'name': 'image_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + }, + { + 'name': 'image_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + }, + { + 'name': 'color_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'color_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'color_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'color_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'color_array_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'color_array_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'color_array_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'color_array_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'processed_color_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'processed_color_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'processed_color_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'processed_color_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + }, + { + 'name': 'point_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + }, + { + 'name': 'point_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + }, + { + 'name': 'point_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + }, + { + 'name': 'point_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + }, + { + 'name': 'insets_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + }, + { + 'name': 'insets_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + }, + { + 'name': 'insets_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + }, + { + 'name': 'insets_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture ARRAY_PROP_TYPES_NO_EVENTS 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [ + { + 'name': 'array_boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'BooleanTypeAnnotation' + } + } + }, + { + 'name': 'array_boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'BooleanTypeAnnotation' + } + } + }, + { + 'name': 'array_boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'BooleanTypeAnnotation' + } + } + }, + { + 'name': 'array_boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'BooleanTypeAnnotation' + } + } + }, + { + 'name': 'array_string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + }, + { + 'name': 'array_string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + }, + { + 'name': 'array_string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + }, + { + 'name': 'array_string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + }, + { + 'name': 'array_double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'DoubleTypeAnnotation' + } + } + }, + { + 'name': 'array_double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'DoubleTypeAnnotation' + } + } + }, + { + 'name': 'array_double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'DoubleTypeAnnotation' + } + } + }, + { + 'name': 'array_double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'DoubleTypeAnnotation' + } + } + }, + { + 'name': 'array_float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'FloatTypeAnnotation' + } + } + }, + { + 'name': 'array_float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'FloatTypeAnnotation' + } + } + }, + { + 'name': 'array_float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'FloatTypeAnnotation' + } + } + }, + { + 'name': 'array_float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'FloatTypeAnnotation' + } + } + }, + { + 'name': 'array_int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'Int32TypeAnnotation' + } + } + }, + { + 'name': 'array_int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'Int32TypeAnnotation' + } + } + }, + { + 'name': 'array_int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'Int32TypeAnnotation' + } + } + }, + { + 'name': 'array_int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'Int32TypeAnnotation' + } + } + }, + { + 'name': 'array_enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringEnumTypeAnnotation', + 'default': 'small', + 'options': [ + 'small', + 'large' + ] + } + } + }, + { + 'name': 'array_enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringEnumTypeAnnotation', + 'default': 'small', + 'options': [ + 'small', + 'large' + ] + } + } + }, + { + 'name': 'array_image_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + }, + { + 'name': 'array_image_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + }, + { + 'name': 'array_image_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + }, + { + 'name': 'array_image_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + }, + { + 'name': 'array_color_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'array_color_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'array_color_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'array_color_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + }, + { + 'name': 'array_point_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + }, + { + 'name': 'array_point_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + }, + { + 'name': 'array_point_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + }, + { + 'name': 'array_point_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + }, + { + 'name': 'array_insets_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + }, + { + 'name': 'array_insets_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + }, + { + 'name': 'array_insets_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + }, + { + 'name': 'array_insets_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + }, + { + 'name': 'array_object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + }, + { + 'name': 'array_object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + }, + { + 'name': 'array_object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + }, + { + 'name': 'array_object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + }, + { + 'name': 'array_of_array_object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'array_object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + ] + } + } + }, + { + 'name': 'array_of_array_object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'array_object_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + ] + } + } + }, + { + 'name': 'array_of_array_object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'array_object_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + ] + } + } + }, + { + 'name': 'array_of_array_object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'array_object_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + ] + } + } + }, + { + 'name': 'array_of_array_of_object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + }, + { + 'name': 'array_of_array_of_object_required_in_file', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture COMMANDS_AND_EVENTS_TYPES_EXPORTED 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onBubblingEventDefinedInline', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineWithPaperName', + 'optional': false, + 'bubblingType': 'bubble', + 'paperTopLevelNameDeprecated': 'paperBubblingEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInline', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineWithPaperName', + 'optional': false, + 'bubblingType': 'direct', + 'paperTopLevelNameDeprecated': 'paperDirectEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + } + ], + 'props': [], + 'commands': [ + { + 'name': 'scrollTo', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'params': [ + { + 'name': 'y', + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'animated', + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } + } + } + ] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture COMMANDS_DEFINED_WITH_ALL_TYPES 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [], + 'commands': [ + { + 'name': 'handleRootTag', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'params': [ + { + 'name': 'rootTag', + 'typeAnnotation': { + 'type': 'ReservedTypeAnnotation', + 'name': 'RootTag' + } + } + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } + } + }, + { + 'name': 'hotspotUpdate', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'params': [ + { + 'name': 'x', + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'y', + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } + } + }, + { + 'name': 'scrollTo', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'params': [ + { + 'name': 'x', + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'y', + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'z', + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'animated', + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } + } + } + ] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture COMMANDS_WITH_EXTERNAL_TYPES 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [], + 'commands': [ + { + 'name': 'scrollTo', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'params': [ + { + 'name': 'y', + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'animated', + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ], + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + } + } + } + ] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture EVENTS_DEFINED_AS_NULL_INLINE 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onDirectEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineNullOptionalKey', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineNullOptionalValue', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineNullOptionalBoth', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineNullWithPaperName', + 'optional': true, + 'bubblingType': 'direct', + 'paperTopLevelNameDeprecated': 'paperDirectEventDefinedInlineNullWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNullOptionalKey', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNullOptionalValue', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNullOptionalBoth', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNullWithPaperName', + 'optional': true, + 'bubblingType': 'bubble', + 'paperTopLevelNameDeprecated': 'paperBubblingEventDefinedInlineNullWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + } + ], + 'props': [], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ALL_TYPES 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onDirectEventDefinedInline', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineOptionalKey', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineOptionalValue', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineOptionalBoth', + 'optional': true, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineWithPaperName', + 'optional': true, + 'bubblingType': 'direct', + 'paperTopLevelNameDeprecated': 'paperDirectEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInline', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineOptionalKey', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineOptionalValue', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineOptionalBoth', + 'optional': true, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineWithPaperName', + 'optional': true, + 'bubblingType': 'bubble', + 'paperTopLevelNameDeprecated': 'paperBubblingEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + } + ], + 'props': [], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'deprecatedViewConfigName': 'DeprecateModuleName', + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture OBJECT_PROP_TYPES_NO_EVENTS 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + } + ] + } + }, + { + 'name': 'boolean_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + } + ] + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + }, + { + 'name': 'string_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': '' + } + } + ] + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'double_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'float_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'int_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'int_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation', + 'default': 0 + } + } + ] + } + }, + { + 'name': 'enum_optional', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringEnumTypeAnnotation', + 'default': 'small', + 'options': [ + 'small', + 'large' + ] + } + } + } + ] + } + }, + { + 'name': 'image_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + ] + } + }, + { + 'name': 'image_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + ] + } + }, + { + 'name': 'image_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + ] + } + }, + { + 'name': 'image_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ImageSourcePrimitive' + } + } + ] + } + }, + { + 'name': 'color_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'color_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'color_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'color_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'processed_color_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'processed_color_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'processed_color_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'processed_color_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'ColorPrimitive' + } + } + ] + } + }, + { + 'name': 'point_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + ] + } + }, + { + 'name': 'point_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + ] + } + }, + { + 'name': 'point_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + ] + } + }, + { + 'name': 'point_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'PointPrimitive' + } + } + ] + } + }, + { + 'name': 'insets_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + ] + } + }, + { + 'name': 'insets_optional_key', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + ] + } + }, + { + 'name': 'insets_optional_value', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + ] + } + }, + { + 'name': 'insets_optional_both', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': true, + 'typeAnnotation': { + 'type': 'ReservedPropTypeAnnotation', + 'name': 'EdgeInsetsPrimitive' + } + } + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'nestedProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'nestedProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'nestedProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'prop', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'nestedProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + ] + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'interfaceOnly': true, + 'paperComponentName': 'RCTModule', + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onDirectEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + } + ], + 'props': [ + { + 'name': 'boolean_default_true_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': true + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS_NO_CAST 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'interfaceOnly': true, + 'excludedPlatforms': [ + 'android' + ], + 'paperComponentName': 'RCTModule', + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onDirectEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineNull', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [] + } + } + } + ], + 'props': [ + { + 'name': 'boolean_default_true_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': true + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture PROPS_ALIASED_LOCALLY 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [], + 'props': [ + { + 'name': 'otherStringProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'isEnabled', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + }, + { + 'name': 'label', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'localType', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'otherStringProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'isEnabled', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + }, + { + 'name': 'label', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + }, + { + 'name': 'localArr', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'otherStringProp', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'isEnabled', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation', + 'default': false + } + }, + { + 'name': 'label', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + } + ] + } + } + } + ], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture PROPS_AND_EVENTS_TYPES_EXPORTED 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [ + { + 'type': 'ReactNativeBuiltInType', + 'knownTypeName': 'ReactNativeCoreViewProps' + } + ], + 'events': [ + { + 'name': 'onBubblingEventDefinedInline', + 'optional': false, + 'bubblingType': 'bubble', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onBubblingEventDefinedInlineWithPaperName', + 'optional': false, + 'bubblingType': 'bubble', + 'paperTopLevelNameDeprecated': 'paperBubblingEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInline', + 'optional': false, + 'bubblingType': 'direct', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + }, + { + 'name': 'onDirectEventDefinedInlineWithPaperName', + 'optional': false, + 'bubblingType': 'direct', + 'paperTopLevelNameDeprecated': 'paperDirectEventDefinedInlineWithPaperName', + 'typeAnnotation': { + 'type': 'EventTypeAnnotation', + 'argument': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'boolean_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'string_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'string_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'double_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'float_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'enum_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'enum_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringEnumTypeAnnotation', + 'options': [ + 'small', + 'large' + ] + } + }, + { + 'name': 'object_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_required_nested_2_layers', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'object_optional_nested_1_layer', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + }, + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'double_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'DoubleTypeAnnotation' + } + }, + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + }, + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'object_readonly_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'boolean_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'string_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'float_optional_value', + 'optional': true, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'object_readonly_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'int32_optional_both', + 'optional': true, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + } + ] + } + } + } + ], + 'props': [], + 'commands': [] + } + } + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture PROPS_AS_EXTERNAL_TYPES 1`] = ` +"{ + 'modules': { + 'Module': { + 'type': 'Component', + 'components': { + 'Module': { + 'extendsProps': [], + 'events': [], + 'props': [ + { + 'name': 'disable', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation', + 'default': null + } + }, + { + 'name': 'array', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ], + 'commands': [] + } + } + } + } +}" +`; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js new file mode 100644 index 00000000000000..223c7d558efb18 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js @@ -0,0 +1,44 @@ +/** + * 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. + * + * @emails oncall+react_native + * @flow strict-local + * @format + */ + +'use strict'; + +const TypeScriptParser = require('../../index.js'); +const fixtures = require('../__test_fixtures__/fixtures.js'); +const failureFixtures = require('../__test_fixtures__/failures.js'); +jest.mock('fs', () => ({ + readFileSync: filename => fixtures[filename] || failureFixtures[filename], +})); + +describe('RN Codegen TypeScript Parser', () => { + Object.keys(fixtures) + .sort() + .forEach(fixtureName => { + it(`can generate fixture ${fixtureName}`, () => { + const schema = TypeScriptParser.parseFile(fixtureName); + const serializedSchema = JSON.stringify(schema, null, 2).replace( + /"/g, + "'", + ); + expect(serializedSchema).toMatchSnapshot(); + }); + }); + + Object.keys(failureFixtures) + .sort() + .forEach(fixtureName => { + it(`Fails with error message ${fixtureName}`, () => { + expect(() => { + TypeScriptParser.parseFile(fixtureName); + }).toThrowErrorMatchingSnapshot(); + }); + }); +}); diff --git a/packages/react-native-codegen/src/parsers/typescript/components/commands.js b/packages/react-native-codegen/src/parsers/typescript/components/commands.js new file mode 100644 index 00000000000000..c8b56c205dd0c6 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/commands.js @@ -0,0 +1,129 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type { + NamedShape, + CommandTypeAnnotation, +} from '../../../CodegenSchema.js'; +import type {TypeDeclarationMap} from '../utils.js'; + +const {getValueFromTypes} = require('../utils.js'); + +type EventTypeAST = Object; + +function buildCommandSchema(property: EventTypeAST, types: TypeDeclarationMap) { + const name = property.key.name; + const optional = property.optional || false; + const value = getValueFromTypes( + property.typeAnnotation.typeAnnotation, + types, + ); + + const firstParam = value.parameters[0].typeAnnotation; + + if ( + !( + firstParam.typeAnnotation != null && + firstParam.typeAnnotation.type === 'TSTypeReference' && + firstParam.typeAnnotation.typeName.left?.name === 'React' && + firstParam.typeAnnotation.typeName.right?.name === 'ElementRef' + ) + ) { + throw new Error( + `The first argument of method ${name} must be of type React.ElementRef<>`, + ); + } + + const params = value.parameters.slice(1).map(param => { + const paramName = param.name; + const paramValue = getValueFromTypes( + param.typeAnnotation.typeAnnotation, + types, + ); + + const type = + paramValue.type === 'TSTypeReference' + ? paramValue.typeName.name + : paramValue.type; + let returnType; + + switch (type) { + case 'RootTag': + returnType = { + type: 'ReservedTypeAnnotation', + name: 'RootTag', + }; + break; + case 'TSBooleanKeyword': + returnType = { + type: 'BooleanTypeAnnotation', + }; + break; + case 'Int32': + returnType = { + type: 'Int32TypeAnnotation', + }; + break; + case 'Double': + returnType = { + type: 'DoubleTypeAnnotation', + }; + break; + case 'Float': + returnType = { + type: 'FloatTypeAnnotation', + }; + break; + case 'TSStringKeyword': + returnType = { + type: 'StringTypeAnnotation', + }; + break; + default: + (type: empty); + throw new Error( + `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`, + ); + } + + return { + name: paramName, + typeAnnotation: returnType, + }; + }); + + return { + name, + optional, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + params, + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + }, + }; +} + +function getCommands( + commandTypeAST: $ReadOnlyArray, + types: TypeDeclarationMap, +): $ReadOnlyArray> { + return commandTypeAST + .filter(property => property.type === 'TSPropertySignature') + .map(property => buildCommandSchema(property, types)) + .filter(Boolean); +} + +module.exports = { + getCommands, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/events.js b/packages/react-native-codegen/src/parsers/typescript/components/events.js new file mode 100644 index 00000000000000..39649de38ebaa2 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/events.js @@ -0,0 +1,283 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type { + EventTypeShape, + NamedShape, + EventTypeAnnotation, +} from '../../../CodegenSchema.js'; + +function getPropertyType( + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ + name, + optional: boolean, + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ + typeAnnotation, +): NamedShape { + const type = + typeAnnotation.type === 'TSTypeReference' + ? typeAnnotation.typeName.name + : typeAnnotation.type; + + switch (type) { + case 'TSBooleanKeyword': + return { + name, + optional, + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }; + case 'TSStringKeyword': + return { + name, + optional, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }; + case 'Int32': + return { + name, + optional, + typeAnnotation: { + type: 'Int32TypeAnnotation', + }, + }; + case 'Double': + return { + name, + optional, + typeAnnotation: { + type: 'DoubleTypeAnnotation', + }, + }; + case 'Float': + return { + name, + optional, + typeAnnotation: { + type: 'FloatTypeAnnotation', + }, + }; + case 'Readonly': + return getPropertyType( + name, + optional, + typeAnnotation.typeParameters.params[0], + ); + + case 'TSTypeLiteral': + return { + name, + optional, + typeAnnotation: { + type: 'ObjectTypeAnnotation', + properties: typeAnnotation.members.map(buildPropertiesForEvent), + }, + }; + + case 'TSUnionType': + // Check for + if ( + typeAnnotation.types.some( + t => t.type === 'TSNullKeyword' || t.type === 'TSUndefinedKeyword', + ) + ) { + const optionalType = typeAnnotation.types.filter( + t => t.type !== 'TSNullKeyword' && t.type !== 'TSUndefinedKeyword', + )[0]; + + // Check for <(T | T2) | null | undefined> + if (optionalType.type === 'TSParenthesizedType') { + return getPropertyType(name, true, optionalType.typeAnnotation); + } + + return getPropertyType(name, true, optionalType); + } + + return { + name, + optional, + typeAnnotation: { + type: 'StringEnumTypeAnnotation', + options: typeAnnotation.types.map(option => option.literal.value), + }, + }; + default: + (type: empty); + throw new Error(`Unable to determine event type for "${name}": ${type}`); + } +} + +function findEventArgumentsAndType( + typeAnnotation: $FlowFixMe, + types: TypeMap, + bubblingType: void | 'direct' | 'bubble', + paperName: ?$FlowFixMe, +) { + if (!typeAnnotation.typeName) { + throw new Error("typeAnnotation of event doesn't have a name"); + } + const name = typeAnnotation.typeName.name; + if (name === 'Readonly') { + return { + argumentProps: typeAnnotation.typeParameters.params[0].members, + paperTopLevelNameDeprecated: paperName, + bubblingType, + }; + } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') { + const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct'; + const paperTopLevelNameDeprecated = + typeAnnotation.typeParameters.params.length > 1 + ? typeAnnotation.typeParameters.params[1].literal.value + : null; + + if (typeAnnotation.typeParameters.params[0].type === 'TSNullKeyword') { + return { + argumentProps: [], + bubblingType: eventType, + paperTopLevelNameDeprecated, + }; + } + return findEventArgumentsAndType( + typeAnnotation.typeParameters.params[0], + types, + eventType, + paperTopLevelNameDeprecated, + ); + } else if (types[name]) { + return findEventArgumentsAndType( + types[name].typeAnnotation, + types, + bubblingType, + paperName, + ); + } else { + return { + argumentProps: null, + bubblingType: null, + paperTopLevelNameDeprecated: null, + }; + } +} + +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function buildPropertiesForEvent(property): NamedShape { + const name = property.key.name; + const optional = property.optional || false; + let typeAnnotation = property.typeAnnotation.typeAnnotation; + + return getPropertyType(name, optional, typeAnnotation); +} + +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function getEventArgument(argumentProps, name: $FlowFixMe) { + return { + type: 'ObjectTypeAnnotation', + properties: argumentProps.map(buildPropertiesForEvent), + }; +} + +function buildEventSchema( + types: TypeMap, + property: EventTypeAST, +): ?EventTypeShape { + const name = property.key.name; + + let optional = property.optional || false; + let typeAnnotation = property.typeAnnotation.typeAnnotation; + + // Check for T | null | undefined + if ( + typeAnnotation.type === 'TSUnionType' && + typeAnnotation.types.some( + t => t.type === 'TSNullKeyword' || t.type === 'TSUndefinedKeyword', + ) + ) { + typeAnnotation = typeAnnotation.types.filter( + t => t.type !== 'TSNullKeyword' && t.type !== 'TSUndefinedKeyword', + )[0]; + optional = true; + } + + if ( + typeAnnotation.type !== 'TSTypeReference' || + (typeAnnotation.typeName.name !== 'BubblingEventHandler' && + typeAnnotation.typeName.name !== 'DirectEventHandler') + ) { + return null; + } + + const {argumentProps, bubblingType, paperTopLevelNameDeprecated} = + findEventArgumentsAndType(typeAnnotation, types); + + if (bubblingType && argumentProps) { + if (paperTopLevelNameDeprecated != null) { + return { + name, + optional, + bubblingType, + paperTopLevelNameDeprecated, + typeAnnotation: { + type: 'EventTypeAnnotation', + argument: getEventArgument(argumentProps, name), + }, + }; + } + + return { + name, + optional, + bubblingType, + typeAnnotation: { + type: 'EventTypeAnnotation', + argument: getEventArgument(argumentProps, name), + }, + }; + } + + if (argumentProps === null) { + throw new Error(`Unable to determine event arguments for "${name}"`); + } + + if (bubblingType === null) { + throw new Error(`Unable to determine event arguments for "${name}"`); + } +} + +// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser +type EventTypeAST = Object; + +type TypeMap = { + // $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser + [string]: Object, + ... +}; + +function getEvents( + eventTypeAST: $ReadOnlyArray, + types: TypeMap, +): $ReadOnlyArray { + return eventTypeAST + .filter(property => property.type === 'TSPropertySignature') + .map(property => buildEventSchema(types, property)) + .filter(Boolean); +} + +module.exports = { + getEvents, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/extends.js b/packages/react-native-codegen/src/parsers/typescript/components/extends.js new file mode 100644 index 00000000000000..2b16a91a5d1476 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/extends.js @@ -0,0 +1,66 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type {ExtendsPropsShape} from '../../../CodegenSchema.js'; +import type {TypeDeclarationMap} from '../utils.js'; + +function extendsForProp(prop: PropsAST, types: TypeDeclarationMap) { + if (!prop.expression) { + console.log('null', prop); + } + const name = prop.expression.name; + + if (types[name] != null) { + // This type is locally defined in the file + return null; + } + + switch (name) { + case 'ViewProps': + return { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }; + default: { + throw new Error(`Unable to handle prop spread: ${name}`); + } + } +} + +function removeKnownExtends( + typeDefinition: $ReadOnlyArray, + types: TypeDeclarationMap, +): $ReadOnlyArray { + return typeDefinition.filter( + prop => + prop.type !== 'TSExpressionWithTypeArguments' || + extendsForProp(prop, types) === null, + ); +} + +// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser +type PropsAST = Object; + +function getExtendsProps( + typeDefinition: $ReadOnlyArray, + types: TypeDeclarationMap, +): $ReadOnlyArray { + return typeDefinition + .filter(prop => prop.type === 'TSExpressionWithTypeArguments') + .map(prop => extendsForProp(prop, types)) + .filter(Boolean); +} + +module.exports = { + getExtendsProps, + removeKnownExtends, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/index.js b/packages/react-native-codegen/src/parsers/typescript/components/index.js new file mode 100644 index 00000000000000..77258ed4b9c2db --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/index.js @@ -0,0 +1,226 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; +import type {TypeDeclarationMap} from '../utils'; +import type {CommandOptions} from './options'; +import type {ComponentSchemaBuilderConfig} from './schema.js'; + +const {getTypes} = require('../utils'); +const {getCommands} = require('./commands'); +const {getEvents} = require('./events'); +const {getExtendsProps, removeKnownExtends} = require('./extends'); +const {getCommandOptions, getOptions} = require('./options'); +const {getPropProperties, getProps} = require('./props'); + +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function findComponentConfig(ast) { + const foundConfigs = []; + + const defaultExports = ast.body.filter( + node => node.type === 'ExportDefaultDeclaration', + ); + + defaultExports.forEach(statement => { + let declaration = statement.declaration; + + // codegenNativeComponent can be nested inside a cast + // expression so we need to go one level deeper + if (declaration.type === 'TSAsExpression') { + declaration = declaration.expression; + } + + try { + if (declaration.callee.name === 'codegenNativeComponent') { + const typeArgumentParams = declaration.typeParameters.params; + const funcArgumentParams = declaration.arguments; + + const nativeComponentType: {[string]: string} = { + propsTypeName: typeArgumentParams[0].typeName.name, + componentName: funcArgumentParams[0].value, + }; + if (funcArgumentParams.length > 1) { + nativeComponentType.optionsExpression = funcArgumentParams[1]; + } + foundConfigs.push(nativeComponentType); + } + } catch (e) { + // ignore + } + }); + + if (foundConfigs.length === 0) { + throw new Error('Could not find component config for native component'); + } + if (foundConfigs.length > 1) { + throw new Error('Only one component is supported per file'); + } + + const foundConfig = foundConfigs[0]; + + const namedExports = ast.body.filter( + node => node.type === 'ExportNamedDeclaration', + ); + + const commandsTypeNames = namedExports + .map(statement => { + let callExpression; + let calleeName; + try { + callExpression = statement.declaration.declarations[0].init; + calleeName = callExpression.callee.name; + } catch (e) { + return; + } + + if (calleeName !== 'codegenNativeCommands') { + return; + } + + // const statement.declaration.declarations[0].init + if (callExpression.arguments.length !== 1) { + throw new Error( + 'codegenNativeCommands must be passed options including the supported commands', + ); + } + + const typeArgumentParam = callExpression.typeParameters.params[0]; + + if (typeArgumentParam.type !== 'TSTypeReference') { + throw new Error( + "codegenNativeCommands doesn't support inline definitions. Specify a file local type alias", + ); + } + + return { + commandTypeName: typeArgumentParam.typeName.name, + commandOptionsExpression: callExpression.arguments[0], + }; + }) + .filter(Boolean); + + if (commandsTypeNames.length > 1) { + throw new Error('codegenNativeCommands may only be called once in a file'); + } + + return { + ...foundConfig, + commandTypeName: + commandsTypeNames[0] == null + ? null + : commandsTypeNames[0].commandTypeName, + commandOptionsExpression: + commandsTypeNames[0] == null + ? null + : commandsTypeNames[0].commandOptionsExpression, + }; +} + +function getCommandProperties( + /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ + commandTypeName, + types: TypeDeclarationMap, + commandOptions: ?CommandOptions, +) { + if (commandTypeName == null) { + return []; + } + + const typeAlias = types[commandTypeName]; + + if (typeAlias.type !== 'TSInterfaceDeclaration') { + throw new Error( + `The type argument for codegenNativeCommands must be an interface, received ${typeAlias.type}`, + ); + } + + let properties; + try { + properties = typeAlias.body.body; + } catch (e) { + throw new Error( + `Failed to find type definition for "${commandTypeName}", please check that you have a valid codegen typescript file`, + ); + } + + const typeScriptPropertyNames = properties + .map(property => property && property.key && property.key.name) + .filter(Boolean); + + if (commandOptions == null || commandOptions.supportedCommands == null) { + throw new Error( + 'codegenNativeCommands must be given an options object with supportedCommands array', + ); + } + + if ( + commandOptions.supportedCommands.length !== + typeScriptPropertyNames.length || + !commandOptions.supportedCommands.every(supportedCommand => + typeScriptPropertyNames.includes(supportedCommand), + ) + ) { + throw new Error( + `codegenNativeCommands expected the same supportedCommands specified in the ${commandTypeName} interface: ${typeScriptPropertyNames.join( + ', ', + )}`, + ); + } + + return properties; +} + +// $FlowFixMe[signature-verification-failure] TODO(T108222691): Use flow-types for @babel/parser +/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's + * LTI update could not be added via codemod */ +function buildComponentSchema(ast): ComponentSchemaBuilderConfig { + const { + componentName, + propsTypeName, + commandTypeName, + commandOptionsExpression, + optionsExpression, + } = findComponentConfig(ast); + + const types = getTypes(ast); + + const propProperties = getPropProperties(propsTypeName, types); + const commandOptions = getCommandOptions(commandOptionsExpression); + + const commandProperties = getCommandProperties( + commandTypeName, + types, + commandOptions, + ); + + const extendsProps = getExtendsProps(propProperties, types); + const options = getOptions(optionsExpression); + + const nonExtendsProps = removeKnownExtends(propProperties, types); + const props = getProps(nonExtendsProps, types); + const events = getEvents(propProperties, types); + const commands = getCommands(commandProperties, types); + + return { + filename: componentName, + componentName, + options, + extendsProps, + events, + props, + commands, + }; +} + +module.exports = { + buildComponentSchema, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/options.js b/packages/react-native-codegen/src/parsers/typescript/components/options.js new file mode 100644 index 00000000000000..4b0f9711172fea --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/options.js @@ -0,0 +1,87 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type {OptionsShape} from '../../../CodegenSchema.js'; + +// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser +type OptionsAST = Object; + +export type CommandOptions = $ReadOnly<{ + supportedCommands: $ReadOnlyArray, +}>; + +function getCommandOptions( + commandOptionsExpression: OptionsAST, +): ?CommandOptions { + if (commandOptionsExpression == null) { + return null; + } + + let foundOptions; + try { + foundOptions = commandOptionsExpression.properties.reduce( + (options, prop) => { + options[prop.key.name] = ( + (prop && prop.value && prop.value.elements) || + [] + ).map(element => element && element.value); + return options; + }, + {}, + ); + } catch (e) { + throw new Error( + 'Failed to parse command options, please check that they are defined correctly', + ); + } + + return foundOptions; +} + +function getOptions(optionsExpression: OptionsAST): ?OptionsShape { + if (!optionsExpression) { + return null; + } + let foundOptions; + try { + foundOptions = optionsExpression.properties.reduce((options, prop) => { + if (prop.value.type === 'ArrayExpression') { + options[prop.key.name] = prop.value.elements.map( + element => element.value, + ); + } else { + options[prop.key.name] = prop.value.value; + } + return options; + }, {}); + } catch (e) { + throw new Error( + 'Failed to parse codegen options, please check that they are defined correctly', + ); + } + + if ( + foundOptions.paperComponentName && + foundOptions.paperComponentNameDeprecated + ) { + throw new Error( + 'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated', + ); + } + + return foundOptions; +} + +module.exports = { + getCommandOptions, + getOptions, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/props.js b/packages/react-native-codegen/src/parsers/typescript/components/props.js new file mode 100644 index 00000000000000..74659ff0dc6ec9 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/props.js @@ -0,0 +1,634 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; +import type {ASTNode} from '../utils'; + +const {getValueFromTypes} = require('../utils.js'); + +import type {NamedShape, PropTypeAnnotation} from '../../../CodegenSchema.js'; +import type {TypeDeclarationMap} from '../utils.js'; + +function getPropProperties( + propsTypeName: string, + types: TypeDeclarationMap, +): $FlowFixMe { + const alias = types[propsTypeName]; + const aliasKind = + alias.type === 'TSInterfaceDeclaration' ? 'interface' : 'type'; + + try { + if (aliasKind === 'interface') { + return [...(alias.extends ?? []), ...alias.body.body]; + } + + return ( + alias.typeAnnotation.members || + alias.typeAnnotation.typeParameters.params[0].members || + alias.typeAnnotation.typeParameters.params + ); + } catch (e) { + throw new Error( + `Failed to find ${aliasKind} definition for "${propsTypeName}", please check that you have a valid codegen typescript file`, + ); + } +} + +function getTypeAnnotationForArray( + name: string, + typeAnnotation: $FlowFixMe, + defaultValue: $FlowFixMe | null, + types: TypeDeclarationMap, +) { + const extractedTypeAnnotation = getValueFromTypes(typeAnnotation, types); + + if ( + extractedTypeAnnotation.type === 'TSUnionType' && + extractedTypeAnnotation.types.some( + t => t.type === 'TSNullKeyword' || t.type === 'TSUndefinedKeyword', + ) + ) { + throw new Error( + 'Nested optionals such as "ReadonlyArray" are not supported, please declare optionals at the top level of value definitions as in "ReadonlyArray | null | undefined"', + ); + } + + if ( + extractedTypeAnnotation.type === 'TSTypeReference' && + extractedTypeAnnotation.typeName.name === 'WithDefault' + ) { + throw new Error( + 'Nested defaults such as "ReadonlyArray>" are not supported, please declare defaults at the top level of value definitions as in "WithDefault, false>"', + ); + } + + if (extractedTypeAnnotation.type === 'TSTypeReference') { + // Resolve the type alias if it's not defined inline + const objectType = getValueFromTypes(extractedTypeAnnotation, types); + + if (objectType.typeName.name === 'Readonly') { + return { + type: 'ObjectTypeAnnotation', + properties: flattenProperties( + objectType.typeParameters.params[0].members || + objectType.typeParameters.params, + types, + ) + .map(prop => buildPropSchema(prop, types)) + .filter(Boolean), + }; + } + + if (objectType.typeName.name === 'ReadonlyArray') { + // We need to go yet another level deeper to resolve + // types that may be defined in a type alias + const nestedObjectType = getValueFromTypes( + objectType.typeParameters.params[0], + types, + ); + + return { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ObjectTypeAnnotation', + properties: flattenProperties( + nestedObjectType.typeParameters.params[0].members || + nestedObjectType.typeParameters.params, + types, + ) + .map(prop => buildPropSchema(prop, types)) + .filter(Boolean), + }, + }; + } + } + + const type = + extractedTypeAnnotation.elementType === 'TSTypeReference' + ? extractedTypeAnnotation.elementType.typeName.name + : extractedTypeAnnotation.elementType?.type || + extractedTypeAnnotation.typeName?.name || + extractedTypeAnnotation.type; + + switch (type) { + case 'TSNumberKeyword': + return { + type: 'FloatTypeAnnotation', + }; + case 'ImageSource': + return { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }; + case 'ColorValue': + case 'ProcessedColorValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }; + case 'PointValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }; + case 'EdgeInsetsValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'EdgeInsetsPrimitive', + }; + case 'Stringish': + return { + type: 'StringTypeAnnotation', + }; + case 'Int32': + return { + type: 'Int32TypeAnnotation', + }; + case 'Double': + return { + type: 'DoubleTypeAnnotation', + }; + case 'Float': + return { + type: 'FloatTypeAnnotation', + }; + case 'TSBooleanKeyword': + return { + type: 'BooleanTypeAnnotation', + }; + case 'TSStringKeyword': + return { + type: 'StringTypeAnnotation', + }; + case 'TSUnionType': + typeAnnotation.types.reduce((lastType, currType) => { + const lastFlattenedType = + lastType && lastType.type === 'TSLiteralType' + ? lastType.literal.type + : lastType.type; + const currFlattenedType = + currType.type === 'TSLiteralType' + ? currType.literal.type + : currType.type; + + if (lastFlattenedType && currFlattenedType !== lastFlattenedType) { + throw new Error(`Mixed types are not supported (see "${name}")`); + } + return currType; + }); + + if (defaultValue === null) { + throw new Error(`A default enum value is required for "${name}"`); + } + + const unionType = typeAnnotation.types[0].type; + if ( + unionType === 'TSLiteralType' && + typeAnnotation.types[0].literal?.type === 'StringLiteral' + ) { + return { + type: 'StringEnumTypeAnnotation', + default: (defaultValue: string), + options: typeAnnotation.types.map(option => option.literal.value), + }; + } else if ( + unionType === 'TSLiteralType' && + typeAnnotation.types[0].literal?.type === 'NumericLiteral' + ) { + throw new Error( + `Arrays of int enums are not supported (see: "${name}")`, + ); + } else { + throw new Error( + `Unsupported union type for "${name}", received "${ + unionType === 'TSLiteralType' + ? typeAnnotation.types[0].literal?.type + : unionType + }"`, + ); + } + default: + (type: empty); + throw new Error(`Unknown prop type for "${name}": ${type}`); + } +} + +function getTypeAnnotation( + name: string, + annotation: $FlowFixMe | ASTNode, + defaultValue: $FlowFixMe | null, + withNullDefault: boolean, + types: TypeDeclarationMap, +) { + const typeAnnotation = getValueFromTypes(annotation, types); + + // Covers: readonly T[] + if ( + typeAnnotation.type === 'TSTypeOperator' && + typeAnnotation.operator === 'readonly' && + typeAnnotation.typeAnnotation.type === 'TSArrayType' + ) { + return { + type: 'ArrayTypeAnnotation', + elementType: getTypeAnnotationForArray( + name, + typeAnnotation.typeAnnotation, + defaultValue, + types, + ), + }; + } + + // Covers: ReadonlyArray + if ( + typeAnnotation.type === 'TSTypeReference' && + typeAnnotation.typeName.name === 'ReadonlyArray' + ) { + return { + type: 'ArrayTypeAnnotation', + elementType: getTypeAnnotationForArray( + name, + typeAnnotation.typeParameters.params[0], + defaultValue, + types, + ), + }; + } + + // Covers: Readonly + if ( + typeAnnotation.type === 'TSTypeReference' && + typeAnnotation.typeName?.name === 'Readonly' && + typeAnnotation.typeParameters.type === 'TSTypeParameterInstantiation' && + typeAnnotation.typeParameters.params[0].type === 'TSArrayType' + ) { + return { + type: 'ArrayTypeAnnotation', + elementType: getTypeAnnotationForArray( + name, + typeAnnotation.typeParameters.params[0], + defaultValue, + types, + ), + }; + } + + if ( + (typeAnnotation.type === 'TSTypeReference' || + typeAnnotation.type === 'TSTypeLiteral') && + typeAnnotation.typeName?.name === 'Readonly' + ) { + const rawProperties = + typeAnnotation.typeParameters.params[0].members || + (typeAnnotation.typeParameters.params[0].types && + typeAnnotation.typeParameters.params[0].types[0].members) || + typeAnnotation.typeParameters.params; + + const flattenedProperties = flattenProperties(rawProperties, types); + + const properties = flattenedProperties + .map(prop => buildPropSchema(prop, types)) + .filter(Boolean); + + return { + type: 'ObjectTypeAnnotation', + properties, + }; + } + + const type = + typeAnnotation.type === 'TSTypeReference' || + typeAnnotation.type === 'TSTypeAliasDeclaration' + ? typeAnnotation.typeName.name + : typeAnnotation.type; + + switch (type) { + case 'ImageSource': + return { + type: 'ReservedPropTypeAnnotation', + name: 'ImageSourcePrimitive', + }; + case 'ColorValue': + case 'ProcessedColorValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }; + case 'ColorArrayValue': + return { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'ReservedPropTypeAnnotation', + name: 'ColorPrimitive', + }, + }; + case 'PointValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'PointPrimitive', + }; + case 'EdgeInsetsValue': + return { + type: 'ReservedPropTypeAnnotation', + name: 'EdgeInsetsPrimitive', + }; + case 'Int32': + return { + type: 'Int32TypeAnnotation', + default: ((defaultValue ? defaultValue : 0): number), + }; + case 'Double': + return { + type: 'DoubleTypeAnnotation', + default: ((defaultValue ? defaultValue : 0): number), + }; + case 'Float': + return { + type: 'FloatTypeAnnotation', + default: withNullDefault + ? (defaultValue: number | null) + : ((defaultValue ? defaultValue : 0): number), + }; + case 'TSBooleanKeyword': + return { + type: 'BooleanTypeAnnotation', + default: withNullDefault + ? (defaultValue: boolean | null) + : ((defaultValue == null ? false : defaultValue): boolean), + }; + case 'TSStringKeyword': + if (typeof defaultValue !== 'undefined') { + return { + type: 'StringTypeAnnotation', + default: (defaultValue: string | null), + }; + } + throw new Error(`A default string (or null) is required for "${name}"`); + case 'Stringish': + if (typeof defaultValue !== 'undefined') { + return { + type: 'StringTypeAnnotation', + default: (defaultValue: string | null), + }; + } + throw new Error(`A default string (or null) is required for "${name}"`); + case 'TSUnionType': + typeAnnotation.types.reduce((lastType, currType) => { + const lastFlattenedType = + lastType && lastType.type === 'TSLiteralType' + ? lastType.literal.type + : lastType.type; + const currFlattenedType = + currType.type === 'TSLiteralType' + ? currType.literal.type + : currType.type; + + if (lastFlattenedType && currFlattenedType !== lastFlattenedType) { + throw new Error(`Mixed types are not supported (see "${name}")`); + } + return currType; + }); + + if (defaultValue === null) { + throw new Error(`A default enum value is required for "${name}"`); + } + + const unionType = typeAnnotation.types[0].type; + if ( + unionType === 'TSLiteralType' && + typeAnnotation.types[0].literal?.type === 'StringLiteral' + ) { + return { + type: 'StringEnumTypeAnnotation', + default: (defaultValue: string), + options: typeAnnotation.types.map(option => option.literal.value), + }; + } else if ( + unionType === 'TSLiteralType' && + typeAnnotation.types[0].literal?.type === 'NumericLiteral' + ) { + return { + type: 'Int32EnumTypeAnnotation', + default: (defaultValue: number), + options: typeAnnotation.types.map(option => option.literal.value), + }; + } else { + throw new Error( + `Unsupported union type for "${name}", received "${ + unionType === 'TSLiteralType' + ? typeAnnotation.types[0].literal?.type + : unionType + }"`, + ); + } + case 'TSNumberKeyword': + throw new Error( + `Cannot use "${type}" type annotation for "${name}": must use a specific numeric type like Int32, Double, or Float`, + ); + default: + (type: empty); + throw new Error(`Unknown prop type for "${name}": "${type}"`); + } +} + +function buildPropSchema( + property: PropAST, + types: TypeDeclarationMap, +): ?NamedShape { + const name = property.key.name; + + const value = getValueFromTypes( + property.typeAnnotation.typeAnnotation, + types, + ); + + let typeAnnotation = value; + let optional = property.optional || false; + + // Check for optional type in union e.g. T | null | undefined + if ( + typeAnnotation.type === 'TSUnionType' && + typeAnnotation.types.some( + t => t.type === 'TSNullKeyword' || t.type === 'TSUndefinedKeyword', + ) + ) { + typeAnnotation = typeAnnotation.types.filter( + t => t.type !== 'TSNullKeyword' && t.type !== 'TSUndefinedKeyword', + )[0]; + optional = true; + + // Check against optional type inside `WithDefault` + if ( + typeAnnotation.type === 'TSTypeReference' && + typeAnnotation.typeName.name === 'WithDefault' + ) { + throw new Error( + 'WithDefault<> is optional and does not need to be marked as optional. Please remove the union of void and/or null', + ); + } + } + + // example: WithDefault; + if ( + value.type === 'TSTypeReference' && + typeAnnotation.typeName.name === 'WithDefault' + ) { + optional = true; + } + + // example: Readonly<{prop: string} | null | undefined>; + if ( + value.type === 'TSTypeReference' && + typeAnnotation.typeParameters?.params[0].type === 'TSUnionType' && + typeAnnotation.typeParameters?.params[0].types.some( + element => + element.type === 'TSNullKeyword' || + element.type === 'TSUndefinedKeyword', + ) + ) { + optional = true; + } + + if ( + !property.optional && + value.type === 'TSTypeReference' && + typeAnnotation.typeName.name === 'WithDefault' + ) { + throw new Error( + `key ${name} must be optional if used with WithDefault<> annotation`, + ); + } + + let type = typeAnnotation.type; + if ( + type === 'TSTypeReference' && + (typeAnnotation.typeName.name === 'DirectEventHandler' || + typeAnnotation.typeName.name === 'BubblingEventHandler') + ) { + return null; + } + + if ( + name === 'style' && + type === 'GenericTypeAnnotation' && + typeAnnotation.typeName.name === 'ViewStyleProp' + ) { + return null; + } + + let defaultValue = null; + let withNullDefault = false; + if ( + type === 'TSTypeReference' && + typeAnnotation.typeName.name === 'WithDefault' + ) { + if (typeAnnotation.typeParameters.params.length === 1) { + throw new Error( + `WithDefault requires two parameters, did you forget to provide a default value for "${name}"?`, + ); + } + + let defaultValueType = typeAnnotation.typeParameters.params[1].type; + defaultValue = typeAnnotation.typeParameters.params[1].value; + + if (defaultValueType === 'TSLiteralType') { + defaultValueType = typeAnnotation.typeParameters.params[1].literal.type; + defaultValue = typeAnnotation.typeParameters.params[1].literal.value; + } + + if (defaultValueType === 'TSNullKeyword') { + defaultValue = null; + withNullDefault = true; + } + + typeAnnotation = typeAnnotation.typeParameters.params[0]; + type = + typeAnnotation.type === 'TSTypeReference' + ? typeAnnotation.typeName.name + : typeAnnotation.type; + } + + return { + name, + optional, + typeAnnotation: getTypeAnnotation( + name, + typeAnnotation, + defaultValue, + withNullDefault, + types, + ), + }; +} + +// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser +type PropAST = Object; + +function verifyPropNotAlreadyDefined( + props: $ReadOnlyArray, + needleProp: PropAST, +) { + const propName = needleProp.key.name; + const foundProp = props.some(prop => prop.key.name === propName); + if (foundProp) { + throw new Error(`A prop was already defined with the name ${propName}`); + } +} + +function flattenProperties( + typeDefinition: $ReadOnlyArray, + types: TypeDeclarationMap, +) { + return typeDefinition + .map(property => { + if (property.type === 'TSPropertySignature') { + return property; + } else if (property.type === 'TSTypeReference') { + return flattenProperties( + getPropProperties(property.typeName.name, types), + types, + ); + } else if (property.type === 'TSExpressionWithTypeArguments') { + return flattenProperties( + getPropProperties(property.expression.name, types), + types, + ); + } + }) + .reduce((acc, item) => { + if (Array.isArray(item)) { + item.forEach(prop => { + verifyPropNotAlreadyDefined(acc, prop); + }); + return acc.concat(item); + } else { + verifyPropNotAlreadyDefined(acc, item); + acc.push(item); + return acc; + } + }, []) + .filter(Boolean); +} + +function getProps( + typeDefinition: $ReadOnlyArray, + types: TypeDeclarationMap, +): $ReadOnlyArray> { + return flattenProperties(typeDefinition, types) + .map(property => { + return buildPropSchema(property, types); + }) + .filter(Boolean); +} + +module.exports = { + getProps, + getPropProperties, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/components/schema.js b/packages/react-native-codegen/src/parsers/typescript/components/schema.js new file mode 100644 index 00000000000000..ed6223c3347b50 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/components/schema.js @@ -0,0 +1,62 @@ +/** + * 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. + * + * @format + * @flow strict-local + */ + +'use strict'; + +import type { + EventTypeShape, + NamedShape, + CommandTypeAnnotation, + PropTypeAnnotation, + ExtendsPropsShape, + SchemaType, + OptionsShape, +} from '../../../CodegenSchema.js'; + +export type ComponentSchemaBuilderConfig = $ReadOnly<{ + filename: string, + componentName: string, + extendsProps: $ReadOnlyArray, + events: $ReadOnlyArray, + props: $ReadOnlyArray>, + commands: $ReadOnlyArray>, + options?: ?OptionsShape, +}>; + +function wrapComponentSchema({ + filename, + componentName, + extendsProps, + events, + props, + options, + commands, +}: ComponentSchemaBuilderConfig): SchemaType { + return { + modules: { + [filename]: { + type: 'Component', + components: { + [componentName]: { + ...(options || {}), + extendsProps, + events, + props, + commands, + }, + }, + }, + }, + }; +} + +module.exports = { + wrapComponentSchema, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/errors.js b/packages/react-native-codegen/src/parsers/typescript/errors.js new file mode 100644 index 00000000000000..41fc7f8ca4eed5 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/errors.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +class ParserError extends Error { + nodes: $ReadOnlyArray<$FlowFixMe>; + constructor( + hasteModuleName: string, + astNodeOrNodes: $FlowFixMe, + message: string, + ) { + super(`Module ${hasteModuleName}: ${message}`); + + this.nodes = Array.isArray(astNodeOrNodes) + ? astNodeOrNodes + : [astNodeOrNodes]; + + // assign the error class name in your custom error (as a shortcut) + this.name = this.constructor.name; + + // capturing the stack trace keeps the reference to your error class + Error.captureStackTrace(this, this.constructor); + } +} + +module.exports = { + ParserError, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/index.js b/packages/react-native-codegen/src/parsers/typescript/index.js new file mode 100644 index 00000000000000..92f41635cc7687 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/index.js @@ -0,0 +1,153 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {SchemaType} from '../../CodegenSchema.js'; +const babelParser = require('@babel/parser'); +const fs = require('fs'); +const path = require('path'); +const {buildComponentSchema} = require('./components'); +const {wrapComponentSchema} = require('./components/schema'); +const {buildModuleSchema} = require('./modules'); +const {wrapModuleSchema} = require('./modules/schema'); + +const { + createParserErrorCapturer, + visit, + isModuleRegistryCall, +} = require('./utils'); +const invariant = require('invariant'); + +function getConfigType( + // TODO(T108222691): Use flow-types for @babel/parser + ast: $FlowFixMe, +): 'module' | 'component' | 'none' { + let isComponent = false; + let isModule = false; + + visit(ast, { + CallExpression(node) { + if ( + node.callee.type === 'Identifier' && + node.callee.name === 'codegenNativeComponent' + ) { + isComponent = true; + } + + if (isModuleRegistryCall(node)) { + isModule = true; + } + }, + + TSInterfaceDeclaration(node) { + if ( + Array.isArray(node.extends) && + node.extends.some( + extension => extension.expression.name === 'TurboModule', + ) + ) { + isModule = true; + } + }, + }); + + if (isModule && isComponent) { + throw new Error( + 'Found type extending "TurboModule" and exported "codegenNativeComponent" declaration in one file. Split them into separated files.', + ); + } + + if (isModule) { + return 'module'; + } else if (isComponent) { + return 'component'; + } else { + return 'none'; + } +} + +function buildSchema(contents: string, filename: ?string): SchemaType { + // Early return for non-Spec JavaScript files + if ( + !contents.includes('codegenNativeComponent') && + !contents.includes('TurboModule') + ) { + return {modules: {}}; + } + + const ast = babelParser.parse(contents, { + sourceType: 'module', + plugins: ['typescript'], + }).program; + + const configType = getConfigType(ast); + + switch (configType) { + case 'component': { + return wrapComponentSchema(buildComponentSchema(ast)); + } + case 'module': { + if (filename === undefined || filename === null) { + throw new Error('Filepath expected while parasing a module'); + } + const hasteModuleName = path.basename(filename).replace(/\.tsx?$/, ''); + + const [parsingErrors, tryParse] = createParserErrorCapturer(); + + const schema = tryParse(() => + buildModuleSchema(hasteModuleName, ast, tryParse), + ); + + if (parsingErrors.length > 0) { + /** + * TODO(T77968131): We have two options: + * - Throw the first error, but indicate there are more then one errors. + * - Display all errors, nicely formatted. + * + * For the time being, we're just throw the first error. + **/ + + throw parsingErrors[0]; + } + + invariant( + schema != null, + 'When there are no parsing errors, the schema should not be null', + ); + + return wrapModuleSchema(schema, hasteModuleName); + } + default: + return {modules: {}}; + } +} + +function parseFile(filename: string): SchemaType { + const contents = fs.readFileSync(filename, 'utf8'); + + return buildSchema(contents, filename); +} + +function parseModuleFixture(filename: string): SchemaType { + const contents = fs.readFileSync(filename, 'utf8'); + + return buildSchema(contents, 'path/NativeSampleTurboModule.ts'); +} + +function parseString(contents: string, filename: ?string): SchemaType { + return buildSchema(contents, filename); +} + +module.exports = { + parseFile, + parseModuleFixture, + parseString, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/failures.js b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/failures.js new file mode 100644 index 00000000000000..f25e8b3d10347a --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/failures.js @@ -0,0 +1,167 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +// @licenselint-loose-mode + +const NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + getString: (arg: string) => Array; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + getString: (arg: Array) => string; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULES_WITH_NOT_ONLY_METHODS = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getBool: (arg: boolean) => boolean; + readonly getNumber: (arg: number) => number; + readonly getString: (arg: string) => string; + sampleBool: boolean, + +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); + +`; + +const NATIVE_MODULES_WITH_UNNAMED_PARAMS = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getBool: (boolean) => boolean; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getBool: (arg: boolean) => Promise; + +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); + +`; + +const TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule1'); +export default TurboModuleRegistry.getEnforcing('SampleTurboModule2'); +`; + +const TWO_NATIVE_EXTENDING_TURBO_MODULE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getSth: (a: number | null | undefined) => void; +} + +export interface Spec2 extends TurboModule { + readonly getSth: (a: number | null | undefined) => void; +} +`; + +module.exports = { + NATIVE_MODULES_WITH_UNNAMED_PARAMS, + NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE, + NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM, + NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT, + TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT, + NATIVE_MODULES_WITH_NOT_ONLY_METHODS, + TWO_NATIVE_EXTENDING_TURBO_MODULE, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js new file mode 100644 index 00000000000000..39956142c70e5e --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js @@ -0,0 +1,647 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +// @licenselint-loose-mode + +const EMPTY_NATIVE_MODULE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_COMPLEX_OBJECTS = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; + +export interface Spec extends TurboModule { + // Exported methods. + readonly getObject: (arg: {const1: {const1: boolean}}) => { + const1: {const1: boolean}, + }; + readonly getReadOnlyObject: (arg: Readonly<{const1: Readonly<{const1: boolean}>}>) => Readonly<{ + const1: {const1: boolean}, + }>; + readonly getObject2: (arg: { a: String }) => Object; + readonly getObjectInArray: (arg: {const1: {const1: boolean}}) => Array<{ + const1: {const1: boolean}, + }>; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; + +export interface Spec extends TurboModule { + readonly getConstants: () => { + isTesting: boolean; + reactNativeVersion: { + major: number; + minor: number; + patch?: number; + prerelease: number | null | undefined; + }; + forceTouchAvailable: boolean; + osVersion: string; + systemName: string; + interfaceIdiom: string; + }; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_BASIC_PARAM_TYPES = ` +/** + * 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. + * + * @format + */ + + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly passBool?: (arg: boolean) => void; + readonly passNumber: (arg: number) => void; + readonly passString: (arg: string) => void; + readonly passStringish: (arg: Stringish) => void; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); + +`; + +const NATIVE_MODULE_WITH_ALIASES = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +type NumNum = number; +export type Num = (arg: NumNum) => void; +type Num2 = Num; +export type Void = void; +export type A = number; +export type B = number; +export type ObjectAlias = { + x: number; + y: number; + label: string; + truthy: boolean; +}; +export type ReadOnlyAlias = Readonly; + +export interface Spec extends TurboModule { + // Exported methods. + readonly getNumber: Num2; + readonly getVoid: () => Void; + readonly getArray: (a: Array) => {a: B}; + readonly getStringFromAlias: (a: ObjectAlias) => string; + readonly getStringFromNullableAlias: (a: ObjectAlias | null) => string; + readonly getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string; + readonly getStringFromNullableReadOnlyAlias: (a: ReadOnlyAlias | null) => string; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_NESTED_ALIASES = ` +/** + * 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. + * + * @format + */ + + +import type {TurboModule} from '../RCTExport'; +import * as TurboModuleRegistry from '../TurboModuleRegistry'; + +type Bar = { + z: number +}; + +type Foo = { + bar1: Bar, + bar2: Bar, +}; + +export interface Spec extends TurboModule { + // Exported methods. + foo1: (x: Foo) => Foo; + foo2: (x: Foo) => void; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); + +`; + +const NATIVE_MODULE_WITH_FLOAT_AND_INT32 = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import type {Int32, Float} from 'react-native/Libraries/Types/CodegenTypes'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getInt: (arg: Int32) => Int32; + readonly getFloat: (arg: Float) => Float; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_SIMPLE_OBJECT = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getObject: (o: Object) => Object, +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_UNSAFE_OBJECT = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; +import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes'; + +export interface Spec extends TurboModule { + readonly getUnsafeObject: (o: UnsafeObject) => UnsafeObject; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_ROOT_TAG = ` +/** + * 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. + * + * @format + */ + +import type { + TurboModule, + RootTag, +} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getRootTag: (rootTag: RootTag) => RootTag; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_NULLABLE_PARAM = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly voidFunc: (arg: string | null | undefined) => void; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_BASIC_ARRAY = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: (arg: Array) => Array; + readonly getArray: (arg: ReadonlyArray) => ReadonlyArray; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_BASIC_ARRAY2 = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: (arg: string[]) => string[]; + readonly getArray: (arg: readonly string[]) => readonly string[]; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +type DisplayMetricsAndroid = { + width: number; +}; + +export interface Spec extends TurboModule { + readonly getConstants: () => { + readonly Dimensions: { + windowPhysicalPixels: DisplayMetricsAndroid; + }; + }; + readonly getConstants2: () => Readonly<{ + readonly Dimensions: { + windowPhysicalPixels: DisplayMetricsAndroid; + }; + }>; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: ( + arg: Array<[string, string]>, + ) => Array; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_ARRAY2_WITH_UNION_AND_TOUPLE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: ( + arg: [string, string][], + ) => (string | number | boolean)[]; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type SomeString = string; + +export interface Spec extends TurboModule { + readonly getArray: (arg: Array) => Array; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_ARRAY2_WITH_ALIAS = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type SomeString = string; + +export interface Spec extends TurboModule { + readonly getArray: (arg: SomeString[]) => string[]; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_COMPLEX_ARRAY = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: ( + arg: Array>>>>, + ) => Array>>; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_COMPLEX_ARRAY2 = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getArray: ( + arg: string[][][][][], + ) => string[][][]; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_PROMISE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export type String = string; +export type SomeObj = { a: string }; + +export interface Spec extends TurboModule { + readonly getValueWithPromise: () => Promise; + readonly getValueWithPromiseDefinedSomewhereElse: () => Promise; + readonly getValueWithPromiseObjDefinedSomewhereElse: () => Promise; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const NATIVE_MODULE_WITH_CALLBACK = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getValueWithCallback: ( + callback: (value: string, arr: Array>) => void, + ) => void; +} + +export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +`; + +const ANDROID_ONLY_NATIVE_MODULE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule {} + +export default TurboModuleRegistry.getEnforcing( + 'SampleTurboModuleAndroid', +); +`; + +const IOS_ONLY_NATIVE_MODULE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule {} + +export default TurboModuleRegistry.getEnforcing( + 'SampleTurboModuleIOS', +); +`; + +const CXX_ONLY_NATIVE_MODULE = ` +/** + * 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. + * + * @format + */ + +import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; +import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; + +export interface Spec extends TurboModule { + readonly getCallback: () => () => void; + readonly getMixed: (arg: unknown) => unknown; +} + +export default TurboModuleRegistry.getEnforcing( + 'SampleTurboModuleCxx', +); +`; + +module.exports = { + NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY, + NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE, + NATIVE_MODULE_WITH_ARRAY2_WITH_UNION_AND_TOUPLE, + NATIVE_MODULE_WITH_FLOAT_AND_INT32, + NATIVE_MODULE_WITH_ALIASES, + NATIVE_MODULE_WITH_NESTED_ALIASES, + NATIVE_MODULE_WITH_PROMISE, + NATIVE_MODULE_WITH_COMPLEX_OBJECTS, + NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY, + NATIVE_MODULE_WITH_SIMPLE_OBJECT, + NATIVE_MODULE_WITH_UNSAFE_OBJECT, + NATIVE_MODULE_WITH_ROOT_TAG, + NATIVE_MODULE_WITH_NULLABLE_PARAM, + NATIVE_MODULE_WITH_BASIC_ARRAY, + NATIVE_MODULE_WITH_BASIC_ARRAY2, + NATIVE_MODULE_WITH_COMPLEX_ARRAY, + NATIVE_MODULE_WITH_COMPLEX_ARRAY2, + NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS, + NATIVE_MODULE_WITH_ARRAY2_WITH_ALIAS, + NATIVE_MODULE_WITH_BASIC_PARAM_TYPES, + NATIVE_MODULE_WITH_CALLBACK, + EMPTY_NATIVE_MODULE, + ANDROID_ONLY_NATIVE_MODULE, + IOS_ONLY_NATIVE_MODULE, + CXX_ONLY_NATIVE_MODULE, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap new file mode 100644 index 00000000000000..20420a83361108 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap @@ -0,0 +1,1665 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`; + +exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_ARRAY_WITH_NO_TYPE_FOR_CONTENT_AS_PARAM 1`] = `"Module NativeSampleTurboModule: Generic 'Array' must have type parameters."`; + +exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_NOT_ONLY_METHODS 1`] = `"Module NativeSampleTurboModule: TypeScript interfaces extending TurboModule must only contain 'FunctionTypeAnnotation's. Property 'sampleBool' refers to a 'TSBooleanKeyword'."`; + +exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_PROMISE_WITHOUT_TYPE 1`] = `"Module NativeSampleTurboModule: Generic 'Promise' must have type parameters."`; + +exports[`RN Codegen TypeScript Parser Fails with error message NATIVE_MODULES_WITH_UNNAMED_PARAMS 1`] = `"Module NativeSampleTurboModule: All function parameters must be named."`; + +exports[`RN Codegen TypeScript Parser Fails with error message TWO_NATIVE_EXTENDING_TURBO_MODULE 1`] = `"Module NativeSampleTurboModule: Every NativeModule spec file must declare exactly one NativeModule TypeScript interface. This file declares 2: 'Spec', and 'Spec2'. Please remove the extraneous TypeScript interface declarations."`; + +exports[`RN Codegen TypeScript Parser Fails with error message TWO_NATIVE_MODULES_EXPORTED_WITH_DEFAULT 1`] = `"Module NativeSampleTurboModule: No TypeScript interfaces extending TurboModule were detected in this NativeModule spec."`; + +exports[`RN Codegen TypeScript Parser can generate fixture ANDROID_ONLY_NATIVE_MODULE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [] + }, + 'moduleNames': [ + 'SampleTurboModuleAndroid' + ], + 'excludedPlatforms': [ + 'iOS' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture CXX_ONLY_NATIVE_MODULE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getCallback', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [] + }, + 'params': [] + } + }, + { + 'name': 'getMixed', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'MixedTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModuleCxx' + ], + 'excludedPlatforms': [ + 'iOS', + 'android' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture EMPTY_NATIVE_MODULE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture IOS_ONLY_NATIVE_MODULE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [] + }, + 'moduleNames': [ + 'SampleTurboModuleIOS' + ], + 'excludedPlatforms': [ + 'android' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ALIASES 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': { + 'ObjectAlias': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'x', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + }, + { + 'name': 'y', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + }, + { + 'name': 'label', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'truthy', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + 'spec': { + 'properties': [ + { + 'name': 'getNumber', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'getVoid', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [] + } + }, + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + ] + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'NumberTypeAnnotation' + } + } + } + ] + } + }, + { + 'name': 'getStringFromAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + ] + } + }, + { + 'name': 'getStringFromNullableAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } + }, + { + 'name': 'getStringFromReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + ] + } + }, + { + 'name': 'getStringFromNullableReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_WITH_ALIAS 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY2_WITH_ALIAS 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY_WITH_UNION_AND_TOUPLE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ARRAY2_WITH_UNION_AND_TOUPLE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_BASIC_ARRAY 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + }, + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_BASIC_ARRAY2 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + }, + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_BASIC_PARAM_TYPES 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'passBool', + 'optional': true, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'passNumber', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'passString', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + }, + { + 'name': 'passStringish', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_CALLBACK 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getValueWithCallback', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'callback', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'value', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'arr', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + } + ] + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_COMPLEX_ARRAY 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + } + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_COMPLEX_ARRAY2 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'StringTypeAnnotation' + } + } + } + } + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_COMPLEX_OBJECTS 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getObject', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + } + } + ] + } + }, + { + 'name': 'getReadOnlyObject', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + } + } + ] + } + }, + { + 'name': 'getObject2', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + } + } + ] + } + }, + { + 'name': 'getObjectInArray', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ArrayTypeAnnotation', + 'elementType': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + } + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'const1', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + } + ] + } + } + ] + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_COMPLEX_OBJECTS_WITH_NULLABLE_KEY 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getConstants', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'isTesting', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'reactNativeVersion', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'major', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + }, + { + 'name': 'minor', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + }, + { + 'name': 'patch', + 'optional': true, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + }, + { + 'name': 'prerelease', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + } + ] + } + }, + { + 'name': 'forceTouchAvailable', + 'optional': false, + 'typeAnnotation': { + 'type': 'BooleanTypeAnnotation' + } + }, + { + 'name': 'osVersion', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'systemName', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + }, + { + 'name': 'interfaceIdiom', + 'optional': false, + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + ] + }, + 'params': [] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_FLOAT_AND_INT32 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getInt', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'Int32TypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'Int32TypeAnnotation' + } + } + ] + } + }, + { + 'name': 'getFloat', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'FloatTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'FloatTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_NESTED_ALIASES 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': { + 'Bar': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'z', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + ] + }, + 'Foo': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'bar1', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'Bar' + } + }, + { + 'name': 'bar2', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'Bar' + } + } + ] + } + }, + 'spec': { + 'properties': [ + { + 'name': 'foo1', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'Foo' + }, + 'params': [ + { + 'name': 'x', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'Foo' + } + } + ] + } + }, + { + 'name': 'foo2', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'x', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'Foo' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_NULLABLE_PARAM 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'voidFunc', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'VoidTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'StringTypeAnnotation' + } + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_OBJECT_WITH_OBJECT_DEFINED_IN_FILE_AS_PROPERTY 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': { + 'DisplayMetricsAndroid': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'width', + 'optional': false, + 'typeAnnotation': { + 'type': 'NumberTypeAnnotation' + } + } + ] + } + }, + 'spec': { + 'properties': [ + { + 'name': 'getConstants', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'Dimensions', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'windowPhysicalPixels', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'DisplayMetricsAndroid' + } + } + ] + } + } + ] + }, + 'params': [] + } + }, + { + 'name': 'getConstants2', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'Dimensions', + 'optional': false, + 'typeAnnotation': { + 'type': 'ObjectTypeAnnotation', + 'properties': [ + { + 'name': 'windowPhysicalPixels', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'DisplayMetricsAndroid' + } + } + ] + } + } + ] + }, + 'params': [] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_PROMISE 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getValueWithPromise', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'PromiseTypeAnnotation' + }, + 'params': [] + } + }, + { + 'name': 'getValueWithPromiseDefinedSomewhereElse', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'PromiseTypeAnnotation' + }, + 'params': [] + } + }, + { + 'name': 'getValueWithPromiseObjDefinedSomewhereElse', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'PromiseTypeAnnotation' + }, + 'params': [] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_ROOT_TAG 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getRootTag', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'ReservedTypeAnnotation', + 'name': 'RootTag' + }, + 'params': [ + { + 'name': 'rootTag', + 'optional': false, + 'typeAnnotation': { + 'type': 'ReservedTypeAnnotation', + 'name': 'RootTag' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_SIMPLE_OBJECT 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getObject', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + }, + 'params': [ + { + 'name': 'o', + 'optional': false, + 'typeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; + +exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_UNSAFE_OBJECT 1`] = ` +"{ + 'modules': { + 'NativeSampleTurboModule': { + 'type': 'NativeModule', + 'aliases': {}, + 'spec': { + 'properties': [ + { + 'name': 'getUnsafeObject', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + }, + 'params': [ + { + 'name': 'o', + 'optional': false, + 'typeAnnotation': { + 'type': 'GenericObjectTypeAnnotation' + } + } + ] + } + } + ] + }, + 'moduleNames': [ + 'SampleTurboModule' + ] + } + } +}" +`; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-e2e-test.js b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-e2e-test.js new file mode 100644 index 00000000000000..99b7702f5fd640 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-e2e-test.js @@ -0,0 +1,1242 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import type { + NativeModuleReturnTypeAnnotation, + NativeModuleBaseTypeAnnotation, + NativeModuleSchema, + NativeModuleParamTypeAnnotation, +} from '../../../../CodegenSchema'; + +const {parseString} = require('../../index.js'); +const {unwrapNullable} = require('../utils'); +const { + UnsupportedTypeScriptGenericParserError, + UnsupportedTypeScriptTypeAnnotationParserError, + UnnamedFunctionParamParserError, + IncorrectlyParameterizedTypeScriptGenericParserError, +} = require('../errors'); +const invariant = require('invariant'); + +type PrimitiveTypeAnnotationType = + | 'StringTypeAnnotation' + | 'NumberTypeAnnotation' + | 'Int32TypeAnnotation' + | 'DoubleTypeAnnotation' + | 'FloatTypeAnnotation' + | 'BooleanTypeAnnotation'; + +const PRIMITIVES: $ReadOnlyArray<[string, PrimitiveTypeAnnotationType]> = [ + ['string', 'StringTypeAnnotation'], + ['number', 'NumberTypeAnnotation'], + ['Int32', 'Int32TypeAnnotation'], + ['Double', 'DoubleTypeAnnotation'], + ['Float', 'FloatTypeAnnotation'], + ['boolean', 'BooleanTypeAnnotation'], +]; + +const RESERVED_FUNCTION_VALUE_TYPE_NAME: $ReadOnlyArray<'RootTag'> = [ + 'RootTag', +]; + +const MODULE_NAME = 'NativeFoo'; + +const TYPE_ALIAS_DECLARATIONS = ` +type Animal = { + name: string; +}; + +type AnimalPointer = Animal; +`; + +function expectAnimalTypeAliasToExist(module: NativeModuleSchema) { + const animalAlias = module.aliases.Animal; + + expect(animalAlias).not.toBe(null); + invariant(animalAlias != null, ''); + expect(animalAlias.type).toBe('ObjectTypeAnnotation'); + expect(animalAlias.properties.length).toBe(1); + expect(animalAlias.properties[0].name).toBe('name'); + expect(animalAlias.properties[0].optional).toBe(false); + + const [typeAnnotation, nullable] = unwrapNullable( + animalAlias.properties[0].typeAnnotation, + ); + + expect(typeAnnotation.type).toBe('StringTypeAnnotation'); + expect(nullable).toBe(false); +} + +describe('TypeScript Module Parser', () => { + describe('Parameter Parsing', () => { + it("should fail parsing when a method has an parameter of type 'any'", () => { + const parser = () => + parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + export interface Spec extends TurboModule { + useArg(arg: any): void; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(parser).toThrow(UnsupportedTypeScriptTypeAnnotationParserError); + }); + + it('should fail parsing when a function param type is unamed', () => { + const parser = () => + parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + export interface Spec extends TurboModule { + useArg(boolean): void; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(parser).toThrow(UnnamedFunctionParamParserError); + }); + + [ + {nullable: false, optional: false}, + {nullable: false, optional: true}, + {nullable: true, optional: false}, + {nullable: true, optional: true}, + ].forEach(({nullable, optional}) => { + const PARAM_TYPE_DESCRIPTION = + nullable && optional + ? 'a nullable and optional' + : nullable + ? 'a nullable' + : optional + ? 'an optional' + : 'a required'; + + function annotateArg(paramName: string, paramType: string) { + if (nullable && optional) { + return `${paramName}?: ${paramType} | null | void`; + } + if (nullable) { + return `${paramName}: ${paramType} | null | void`; + } + if (optional) { + return `${paramName}?: ${paramType}`; + } + return `${paramName}: ${paramType}`; + } + + function parseParamType( + paramName: string, + paramType: string, + ): [NativeModuleParamTypeAnnotation, NativeModuleSchema] { + const module = parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + + ${TYPE_ALIAS_DECLARATIONS} + + export interface Spec extends TurboModule { + useArg(${annotateArg(paramName, paramType)}): void; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(module.spec.properties[0]).not.toBe(null); + const param = unwrapNullable( + module.spec.properties[0].typeAnnotation, + )[0].params[0]; + expect(param).not.toBe(null); + expect(param.name).toBe(paramName); + expect(param.optional).toBe(optional); + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable(param.typeAnnotation); + expect(isParamTypeAnnotationNullable).toBe(nullable); + + return [paramTypeAnnotation, module]; + } + + describe( + (nullable && optional + ? 'Nullable and Optional' + : nullable + ? 'Nullable' + : optional + ? 'Optional' + : 'Required') + ' Parameter', + () => { + it(`should not parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Function'`, () => { + expect(() => parseParamType('arg', 'Function')).toThrow( + UnsupportedTypeScriptGenericParserError, + ); + }); + + describe('Primitive types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} primitive parameter of type '${FLOW_TYPE}'`, () => { + const [paramTypeAnnotation] = parseParamType('arg', FLOW_TYPE); + expect(paramTypeAnnotation.type).toBe(PARSED_TYPE_NAME); + }); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Object'`, () => { + const [paramTypeAnnotation] = parseParamType('arg', 'Object'); + expect(paramTypeAnnotation.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + describe('Reserved Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of reserved type '${FLOW_TYPE}'`, () => { + const [paramTypeAnnotation] = parseParamType('arg', FLOW_TYPE); + + expect(paramTypeAnnotation.type).toBe('ReservedTypeAnnotation'); + invariant( + paramTypeAnnotation.type === 'ReservedTypeAnnotation', + 'Param must be a Reserved type', + ); + + expect(paramTypeAnnotation.name).toBe(FLOW_TYPE); + }); + }); + }); + + describe('Array Types', () => { + it(`should not parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array'`, () => { + expect(() => parseParamType('arg', 'Array')).toThrow( + IncorrectlyParameterizedTypeScriptGenericParserError, + ); + }); + + function parseParamArrayElementType( + paramName: string, + paramType: string, + ): [NativeModuleBaseTypeAnnotation, NativeModuleSchema] { + const [paramTypeAnnotation, module] = parseParamType( + paramName, + `Array<${paramType}>`, + ); + + expect(paramTypeAnnotation.type).toBe('ArrayTypeAnnotation'); + invariant(paramTypeAnnotation.type === 'ArrayTypeAnnotation', ''); + + expect(paramTypeAnnotation.elementType).not.toBe(null); + invariant(paramTypeAnnotation.elementType != null, ''); + const [elementType, isElementTypeNullable] = + unwrapNullable( + paramTypeAnnotation.elementType, + ); + expect(isElementTypeNullable).toBe(false); + return [elementType, module]; + } + + // TODO: Do we support nullable element types? + + describe('Primitive Element Types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseParamArrayElementType( + 'arg', + FLOW_TYPE, + ); + expect(elementType.type).toBe(PARSED_TYPE_NAME); + }); + }); + }); + + describe('Reserved Element Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseParamArrayElementType( + 'arg', + FLOW_TYPE, + ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant(elementType.type === 'ReservedTypeAnnotation', ''); + + expect(elementType.name).toBe(FLOW_TYPE); + }); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array'`, () => { + const [elementType] = parseParamArrayElementType('arg', 'Object'); + expect(elementType.type).toBe('GenericObjectTypeAnnotation'); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of some array of an alias`, () => { + const [elementType, module] = parseParamArrayElementType( + 'arg', + 'Animal', + ); + expect(elementType.type).toBe('TypeAliasTypeAnnotation'); + invariant(elementType.type === 'TypeAliasTypeAnnotation', ''); + + expect(elementType.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter of type 'Array<{foo: string | null | void}>'`, () => { + const [elementType] = parseParamArrayElementType( + 'arg', + '{foo: string | null | void}', + ); + expect(elementType).not.toBe(null); + + expect(elementType.type).toBe('ObjectTypeAnnotation'); + invariant(elementType.type === 'ObjectTypeAnnotation', ''); + + const {properties} = elementType; + invariant(properties != null, ''); + + expect(properties).not.toBe(null); + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + expect(properties[0].typeAnnotation).not.toBe(null); + + const [typeAnnotation, isPropertyNullable] = unwrapNullable( + properties[0].typeAnnotation, + ); + + expect(typeAnnotation.type).toBe('StringTypeAnnotation'); + expect(isPropertyNullable).toBe(true); + expect(properties[0].optional).toBe(false); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of some type alias`, () => { + const [paramTypeAnnotation, module] = parseParamType( + 'arg', + 'Animal', + ); + expect(paramTypeAnnotation.type).toBe('TypeAliasTypeAnnotation'); + invariant( + paramTypeAnnotation.type === 'TypeAliasTypeAnnotation', + '', + ); + + expect(paramTypeAnnotation.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of some type alias that points to another type alias`, () => { + const [paramTypeAnnotation, module] = parseParamType( + 'arg', + 'AnimalPointer', + ); + expect(paramTypeAnnotation.type).toBe('TypeAliasTypeAnnotation'); + invariant( + paramTypeAnnotation.type === 'TypeAliasTypeAnnotation', + '', + ); + + expect(paramTypeAnnotation.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of some type alias that points to another nullable type alias`, () => { + const module = parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + + type Animal = { + name: string, + } | null | void; + + type AnimalPointer = Animal; + + export interface Spec extends TurboModule { + useArg(${annotateArg('arg', 'AnimalPointer')}): void; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(module.spec.properties[0]).not.toBe(null); + const param = unwrapNullable( + module.spec.properties[0].typeAnnotation, + )[0].params[0]; + expect(param.name).toBe('arg'); + expect(param.optional).toBe(optional); + + // The TypeAliasAnnotation is called Animal, and is nullable + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable(param.typeAnnotation); + expect(paramTypeAnnotation.type).toBe('TypeAliasTypeAnnotation'); + invariant( + paramTypeAnnotation.type === 'TypeAliasTypeAnnotation', + '', + ); + expect(paramTypeAnnotation.name).toBe('Animal'); + expect(isParamTypeAnnotationNullable).toBe(true); + + // The Animal type alias RHS is valid, and non-null + expectAnimalTypeAliasToExist(module); + }); + + [ + {nullable: false, optional: false}, + {nullable: false, optional: true}, + {nullable: true, optional: false}, + {nullable: true, optional: true}, + ].forEach(({nullable: isPropNullable, optional: isPropOptional}) => { + const PROP_TYPE_DESCRIPTION = + isPropNullable && isPropOptional + ? 'a nullable and optional' + : isPropNullable + ? 'a nullable' + : isPropOptional + ? 'an optional' + : 'a required'; + + function annotateProp(propName: string, propType: string) { + if (isPropNullable && isPropOptional) { + return `${propName}?: ${propType} | null | void`; + } + if (isPropNullable) { + return `${propName}: ${propType} | null | void`; + } + if (isPropOptional) { + return `${propName}?: ${propType}`; + } + return `${propName}: ${propType}`; + } + + function parseParamTypeObjectLiteralProp( + propName: string, + propType: string, + ): [ + $ReadOnly<{ + name: string, + optional: boolean, + typeAnnotation: NativeModuleBaseTypeAnnotation, + }>, + NativeModuleSchema, + ] { + const [paramTypeAnnotation, module] = parseParamType( + 'arg', + `{${annotateProp(propName, propType)}}`, + ); + + expect(paramTypeAnnotation.type).toBe('ObjectTypeAnnotation'); + invariant( + paramTypeAnnotation.type === 'ObjectTypeAnnotation', + '', + ); + + const {properties} = paramTypeAnnotation; + + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties.length).toBe(1); + expect(properties[0].name).toBe(propName); + expect(properties[0].optional).toBe(isPropOptional); + + const [propertyTypeAnnotation, isPropertyTypeAnnotationNullable] = + unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation).not.toBe(null); + expect(isPropertyTypeAnnotationNullable).toBe(isPropNullable); + + return [ + { + ...properties[0], + typeAnnotation: propertyTypeAnnotation, + }, + module, + ]; + } + + describe( + (isPropNullable && isPropOptional + ? 'Nullable and Optional' + : isPropNullable + ? 'Nullable' + : isPropOptional + ? 'Optional' + : 'Required') + ' Property', + () => { + describe('Props with Primitive Types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of primitive type '${FLOW_TYPE}'`, () => { + const [prop] = parseParamTypeObjectLiteralProp( + 'prop', + FLOW_TYPE, + ); + expect(prop.typeAnnotation.type).toBe(PARSED_TYPE_NAME); + }); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Object'`, () => { + const [prop] = parseParamTypeObjectLiteralProp( + 'prop', + 'Object', + ); + expect(prop.typeAnnotation.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + describe('Props with Reserved Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of reserved type '${FLOW_TYPE}'`, () => { + const [prop] = parseParamTypeObjectLiteralProp( + 'prop', + FLOW_TYPE, + ); + expect(prop.typeAnnotation.type).toBe( + 'ReservedTypeAnnotation', + ); + invariant( + prop.typeAnnotation.type === 'ReservedTypeAnnotation', + '', + ); + + expect(prop.typeAnnotation.name).toBe(FLOW_TYPE); + }); + }); + }); + + describe('Props with Array Types', () => { + it(`should not parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array`, () => { + expect(() => + parseParamTypeObjectLiteralProp('prop', 'Array'), + ).toThrow( + IncorrectlyParameterizedTypeScriptGenericParserError, + ); + }); + + function parseArrayElementType( + propName: string, + arrayElementType: string, + ): [NativeModuleBaseTypeAnnotation, NativeModuleSchema] { + const [property, module] = parseParamTypeObjectLiteralProp( + 'propName', + `Array<${arrayElementType}>`, + ); + expect(property.typeAnnotation.type).toBe( + 'ArrayTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === 'ArrayTypeAnnotation', + '', + ); + + const {elementType: nullableElementType} = + property.typeAnnotation; + expect(nullableElementType).not.toBe(null); + invariant(nullableElementType != null, ''); + + const [elementType, isElementTypeNullable] = + unwrapNullable( + nullableElementType, + ); + + expect(isElementTypeNullable).toBe(false); + + return [elementType, module]; + } + + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + FLOW_TYPE, + ); + + expect(elementType.type).toBe(PARSED_TYPE_NAME); + }); + }); + + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + FLOW_TYPE, + ); + + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant( + elementType.type === 'ReservedTypeAnnotation', + '', + ); + expect(elementType.name).toBe(FLOW_TYPE); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + 'Object', + ); + expect(elementType.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type of some array of an alias`, () => { + const [elementType, module] = parseArrayElementType( + 'prop', + 'Animal', + ); + + expect(elementType.type).toBe('TypeAliasTypeAnnotation'); + invariant( + elementType.type === 'TypeAliasTypeAnnotation', + '', + ); + + expect(elementType.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of 'Array<{foo: string | null | void}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + '{foo: string | null | void}', + ); + + expect(elementType.type).toBe('ObjectTypeAnnotation'); + invariant(elementType.type === 'ObjectTypeAnnotation', ''); + + const {properties} = elementType; + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + expect(properties[0].typeAnnotation).not.toBe(null); + + const [ + propertyTypeAnnotation, + isPropertyTypeAnnotationNullable, + ] = unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation.type).toBe( + 'StringTypeAnnotation', + ); + expect(isPropertyTypeAnnotationNullable).toBe(true); + expect(properties[0].optional).toBe(false); + }); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type '{foo: string | null | void}'`, () => { + const [property] = parseParamTypeObjectLiteralProp( + 'prop', + '{foo: string | null | void}', + ); + + expect(property.typeAnnotation.type).toBe( + 'ObjectTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === 'ObjectTypeAnnotation', + '', + ); + + const {properties} = property.typeAnnotation; + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + + const [ + propertyTypeAnnotation, + isPropertyTypeAnnotationNullable, + ] = unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation.type).toBe( + 'StringTypeAnnotation', + ); + expect(isPropertyTypeAnnotationNullable).toBe(true); + expect(properties[0].optional).toBe(false); + }); + + it(`should parse methods that have ${PARAM_TYPE_DESCRIPTION} parameter type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of some type alias`, () => { + const [property, module] = parseParamTypeObjectLiteralProp( + 'prop', + 'Animal', + ); + + expect(property.typeAnnotation.type).toBe( + 'TypeAliasTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === 'TypeAliasTypeAnnotation', + '', + ); + + expect(property.typeAnnotation.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + }, + ); + }); + }, + ); + }); + }); + + describe('Return Parsing', () => { + it('should parse methods that have a return type of void', () => { + const module = parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + export interface Spec extends TurboModule { + useArg(): void; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(module.spec.properties[0]).not.toBe(null); + + const [functionTypeAnnotation, isFunctionTypeAnnotationNullable] = + unwrapNullable(module.spec.properties[0].typeAnnotation); + expect(isFunctionTypeAnnotationNullable).toBe(false); + + const [returnTypeAnnotation, isReturnTypeAnnotationNullable] = + unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); + expect(returnTypeAnnotation.type).toBe('VoidTypeAnnotation'); + expect(isReturnTypeAnnotationNullable).toBe(false); + }); + + [true, false].forEach(IS_RETURN_TYPE_NULLABLE => { + const RETURN_TYPE_DESCRIPTION = IS_RETURN_TYPE_NULLABLE + ? 'a nullable' + : 'a non-nullable'; + const annotateRet = (retType: string) => + IS_RETURN_TYPE_NULLABLE ? `${retType} | null | void` : retType; + + function parseReturnType( + flowType: string, + ): [NativeModuleReturnTypeAnnotation, NativeModuleSchema] { + const module = parseModule(` + import type {TurboModule} from 'RCTExport'; + import * as TurboModuleRegistry from 'TurboModuleRegistry'; + + ${TYPE_ALIAS_DECLARATIONS} + + export interface Spec extends TurboModule { + useArg(): ${annotateRet(flowType)}; + } + export default TurboModuleRegistry.get('Foo'); + `); + + expect(module.spec.properties[0]).not.toBe(null); + const [functionTypeAnnotation, isFunctionTypeAnnotationNullable] = + unwrapNullable(module.spec.properties[0].typeAnnotation); + expect(isFunctionTypeAnnotationNullable).toBe(false); + + const [returnTypeAnnotation, isReturnTypeAnnotationNullable] = + unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); + expect(isReturnTypeAnnotationNullable).toBe(IS_RETURN_TYPE_NULLABLE); + + return [returnTypeAnnotation, module]; + } + + describe( + IS_RETURN_TYPE_NULLABLE ? 'Nullable Returns' : 'Non-Nullable Returns', + () => { + ['Promise', 'Promise<{}>'].forEach(promiseFlowType => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type '${promiseFlowType}'`, () => { + const [returnTypeAnnotation] = parseReturnType(promiseFlowType); + expect(returnTypeAnnotation.type).toBe('PromiseTypeAnnotation'); + }); + }); + + describe('Primitive Types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} primitive return of type '${FLOW_TYPE}'`, () => { + const [returnTypeAnnotation] = parseReturnType(FLOW_TYPE); + expect(returnTypeAnnotation.type).toBe(PARSED_TYPE_NAME); + }); + }); + }); + + describe('Reserved Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} reserved return of type '${FLOW_TYPE}'`, () => { + const [returnTypeAnnotation] = parseReturnType(FLOW_TYPE); + expect(returnTypeAnnotation.type).toBe( + 'ReservedTypeAnnotation', + ); + invariant( + returnTypeAnnotation.type === 'ReservedTypeAnnotation', + '', + ); + expect(returnTypeAnnotation.name).toBe(FLOW_TYPE); + }); + }); + }); + + describe('Array Types', () => { + it(`should not parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array'`, () => { + expect(() => parseReturnType('Array')).toThrow( + IncorrectlyParameterizedTypeScriptGenericParserError, + ); + }); + + function parseArrayElementReturnType( + flowType: string, + ): [NativeModuleBaseTypeAnnotation, NativeModuleSchema] { + const [returnTypeAnnotation, module] = parseReturnType( + 'Array' + (flowType != null ? `<${flowType}>` : ''), + ); + expect(returnTypeAnnotation.type).toBe('ArrayTypeAnnotation'); + invariant( + returnTypeAnnotation.type === 'ArrayTypeAnnotation', + '', + ); + + const arrayTypeAnnotation = returnTypeAnnotation; + + const {elementType} = arrayTypeAnnotation; + expect(elementType).not.toBe(null); + invariant(elementType != null, ''); + + const [elementTypeAnnotation, isElementTypeAnnotation] = + unwrapNullable(elementType); + expect(isElementTypeAnnotation).toBe(false); + + return [elementTypeAnnotation, module]; + } + + // TODO: Do we support nullable element types? + + describe('Primitive Element Types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementReturnType(FLOW_TYPE); + expect(elementType.type).toBe(PARSED_TYPE_NAME); + }); + }); + }); + + describe('Reserved Element Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementReturnType(FLOW_TYPE); + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant(elementType.type === 'ReservedTypeAnnotation', ''); + + expect(elementType.name).toBe(FLOW_TYPE); + }); + }); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array'`, () => { + const [elementType] = parseArrayElementReturnType('Object'); + expect(elementType.type).toBe('GenericObjectTypeAnnotation'); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of some array of an alias`, () => { + const [elementType, module] = + parseArrayElementReturnType('Animal'); + expect(elementType.type).toBe('TypeAliasTypeAnnotation'); + invariant(elementType.type === 'TypeAliasTypeAnnotation', ''); + expect(elementType.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<{foo: string | null | void}>'`, () => { + const [elementType] = parseArrayElementReturnType( + '{foo: string | null | void}', + ); + expect(elementType.type).toBe('ObjectTypeAnnotation'); + invariant(elementType.type === 'ObjectTypeAnnotation', ''); + + const {properties} = elementType; + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + expect(properties[0].typeAnnotation).not.toBe(null); + + const [propertyTypeAnnotation, isPropertyTypeAnnotationNullable] = + unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation.type).toBe('StringTypeAnnotation'); + expect(isPropertyTypeAnnotationNullable).toBe(true); + expect(properties[0].optional).toBe(false); + }); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of some type alias`, () => { + const [returnTypeAnnotation, module] = parseReturnType('Animal'); + expect(returnTypeAnnotation.type).toBe('TypeAliasTypeAnnotation'); + invariant( + returnTypeAnnotation.type === 'TypeAliasTypeAnnotation', + '', + ); + expect(returnTypeAnnotation.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should not parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Function'`, () => { + expect(() => parseReturnType('Function')).toThrow( + UnsupportedTypeScriptGenericParserError, + ); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Object'`, () => { + const [returnTypeAnnotation] = parseReturnType('Object'); + expect(returnTypeAnnotation.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + describe('Object Literals Types', () => { + // TODO: Inexact vs exact object literals? + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an empty object literal`, () => { + const [returnTypeAnnotation] = parseReturnType('{}'); + expect(returnTypeAnnotation.type).toBe('ObjectTypeAnnotation'); + invariant( + returnTypeAnnotation.type === 'ObjectTypeAnnotation', + '', + ); + + // Validate properties of object literal + expect(returnTypeAnnotation.properties).not.toBe(null); + expect(returnTypeAnnotation.properties?.length).toBe(0); + }); + + [ + {nullable: false, optional: false}, + {nullable: false, optional: true}, + {nullable: true, optional: false}, + {nullable: true, optional: true}, + ].forEach(({nullable, optional}) => { + const PROP_TYPE_DESCRIPTION = + nullable && optional + ? 'a nullable and optional' + : nullable + ? 'a nullable' + : optional + ? 'an optional' + : 'a required'; + + function annotateProp(propName: string, propType: string) { + if (nullable && optional) { + return `${propName}?: ${propType} | null | void`; + } + if (nullable) { + return `${propName}: ${propType} | null | void`; + } + if (optional) { + return `${propName}?: ${propType}`; + } + return `${propName}: ${propType}`; + } + + function parseObjectLiteralReturnTypeProp( + propName: string, + propType: string, + ): [ + $ReadOnly<{ + name: string, + optional: boolean, + typeAnnotation: NativeModuleBaseTypeAnnotation, + }>, + NativeModuleSchema, + ] { + const [returnTypeAnnotation, module] = parseReturnType( + `{${annotateProp(propName, propType)}}`, + ); + expect(returnTypeAnnotation.type).toBe('ObjectTypeAnnotation'); + invariant( + returnTypeAnnotation.type === 'ObjectTypeAnnotation', + '', + ); + + const properties = returnTypeAnnotation.properties; + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties.length).toBe(1); + + // Validate property + const property = properties[0]; + expect(property.name).toBe(propName); + expect(property.optional).toBe(optional); + + const [ + propertyTypeAnnotation, + isPropertyTypeAnnotationNullable, + ] = unwrapNullable(property.typeAnnotation); + + expect(propertyTypeAnnotation).not.toBe(null); + expect(isPropertyTypeAnnotationNullable).toBe(nullable); + return [ + { + ...property, + typeAnnotation: propertyTypeAnnotation, + }, + module, + ]; + } + + describe( + (nullable && optional + ? 'Nullable and Optional' + : nullable + ? 'Nullable' + : optional + ? 'Optional' + : 'Required') + ' Property', + () => { + /** + * TODO: Fill out props in promise + */ + + describe('Props with Primitive Types', () => { + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of primitive type '${FLOW_TYPE}'`, () => { + const [property] = parseObjectLiteralReturnTypeProp( + 'prop', + FLOW_TYPE, + ); + expect(property.typeAnnotation.type).toBe( + PARSED_TYPE_NAME, + ); + }); + }); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Object'`, () => { + const [property] = parseObjectLiteralReturnTypeProp( + 'prop', + 'Object', + ); + + expect(property.typeAnnotation.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + describe('Props with Reserved Types', () => { + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of reserved type '${FLOW_TYPE}'`, () => { + const [property] = parseObjectLiteralReturnTypeProp( + 'prop', + FLOW_TYPE, + ); + + expect(property.typeAnnotation.type).toBe( + 'ReservedTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === + 'ReservedTypeAnnotation', + '', + ); + + expect(property.typeAnnotation.name).toBe(FLOW_TYPE); + }); + }); + }); + + describe('Props with Array Types', () => { + it(`should not parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array`, () => { + expect(() => + parseObjectLiteralReturnTypeProp('prop', 'Array'), + ).toThrow( + IncorrectlyParameterizedTypeScriptGenericParserError, + ); + }); + + function parseArrayElementType( + propName: string, + arrayElementType: string, + ): [NativeModuleBaseTypeAnnotation, NativeModuleSchema] { + const [property, module] = + parseObjectLiteralReturnTypeProp( + propName, + `Array<${arrayElementType}>`, + ); + expect(property.name).toBe(propName); + expect(property.typeAnnotation.type).toBe( + 'ArrayTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === 'ArrayTypeAnnotation', + '', + ); + + const {elementType: nullableElementType} = + property.typeAnnotation; + expect(nullableElementType).not.toBe(null); + invariant(nullableElementType != null, ''); + + const [elementType, isElementTypeNullable] = + unwrapNullable( + nullableElementType, + ); + expect(isElementTypeNullable).toBe(false); + + return [elementType, module]; + } + + PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + FLOW_TYPE, + ); + expect(elementType.type).toBe(PARSED_TYPE_NAME); + }); + }); + + RESERVED_FUNCTION_VALUE_TYPE_NAME.forEach(FLOW_TYPE => { + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<${FLOW_TYPE}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + FLOW_TYPE, + ); + expect(elementType.type).toBe('ReservedTypeAnnotation'); + invariant( + elementType.type === 'ReservedTypeAnnotation', + '', + ); + + expect(elementType.name).toBe(FLOW_TYPE); + }); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + 'Object', + ); + expect(elementType).not.toBe(null); + expect(elementType.type).toBe( + 'GenericObjectTypeAnnotation', + ); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type of some array of an aliase`, () => { + const [elementType, module] = parseArrayElementType( + 'prop', + 'Animal', + ); + expect(elementType.type).toBe('TypeAliasTypeAnnotation'); + invariant( + elementType.type === 'TypeAliasTypeAnnotation', + '', + ); + expect(elementType.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of type 'Array<{foo: string | null | void}>'`, () => { + const [elementType] = parseArrayElementType( + 'prop', + '{foo: string | null | void}', + ); + expect(elementType.type).toBe('ObjectTypeAnnotation'); + invariant( + elementType.type === 'ObjectTypeAnnotation', + '', + ); + + const {properties} = elementType; + invariant(properties != null, ''); + expect(properties).not.toBe(null); + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + expect(properties[0].optional).toBe(false); + + const [ + propertyTypeAnnotation, + isPropertyTypeAnnotationNullable, + ] = unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation.type).toBe( + 'StringTypeAnnotation', + ); + expect(isPropertyTypeAnnotationNullable).toBe(true); + }); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of '{foo: string | null | void}'`, () => { + const [property] = parseObjectLiteralReturnTypeProp( + 'prop', + '{foo: string | null | void}', + ); + + expect(property.typeAnnotation.type).toBe( + 'ObjectTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === 'ObjectTypeAnnotation', + '', + ); + + const {properties} = property.typeAnnotation; + + expect(properties).not.toBe(null); + invariant(properties != null, ''); + + expect(properties[0]).not.toBe(null); + expect(properties[0].name).toBe('foo'); + expect(properties[0].optional).toBe(false); + + const [ + propertyTypeAnnotation, + isPropertyTypeAnnotationNullable, + ] = unwrapNullable(properties[0].typeAnnotation); + + expect(propertyTypeAnnotation.type).toBe( + 'StringTypeAnnotation', + ); + expect(isPropertyTypeAnnotationNullable).toBe(true); + }); + + it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of an object literal with ${PROP_TYPE_DESCRIPTION} prop of some type alias`, () => { + const [property, module] = parseObjectLiteralReturnTypeProp( + 'prop', + 'Animal', + ); + + expect(property.typeAnnotation.type).toBe( + 'TypeAliasTypeAnnotation', + ); + invariant( + property.typeAnnotation.type === + 'TypeAliasTypeAnnotation', + '', + ); + + expect(property.typeAnnotation.name).toBe('Animal'); + expectAnimalTypeAliasToExist(module); + }); + }, + ); + }); + }); + }, + ); + }); + }); +}); + +function parseModule(source: string) { + const schema = parseString(source, `${MODULE_NAME}.ts`); + const module = schema.modules.NativeFoo; + invariant( + module.type === 'NativeModule', + "'nativeModules' in Spec NativeFoo shouldn't be null", + ); + return module; +} diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js new file mode 100644 index 00000000000000..371e6f7d9c6b9d --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js @@ -0,0 +1,45 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @emails oncall+react_native + * @flow strict-local + * @format + */ + +'use strict'; + +const TypeScriptParser = require('../../index.js'); +const fixtures = require('../__test_fixtures__/fixtures.js'); +const failureFixtures = require('../__test_fixtures__/failures.js'); +jest.mock('fs', () => ({ + readFileSync: filename => fixtures[filename] || failureFixtures[filename], +})); + +describe('RN Codegen TypeScript Parser', () => { + Object.keys(fixtures) + .sort() + .forEach(fixtureName => { + it(`can generate fixture ${fixtureName}`, () => { + const schema = TypeScriptParser.parseModuleFixture(fixtureName); + const serializedSchema = JSON.stringify(schema, null, 2).replace( + /"/g, + "'", + ); + + expect(serializedSchema).toMatchSnapshot(); + }); + }); + + Object.keys(failureFixtures) + .sort() + .forEach(fixtureName => { + it(`Fails with error message ${fixtureName}`, () => { + expect(() => { + TypeScriptParser.parseModuleFixture(fixtureName); + }).toThrowErrorMatchingSnapshot(); + }); + }); +}); diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/errors.js b/packages/react-native-codegen/src/parsers/typescript/modules/errors.js new file mode 100644 index 00000000000000..357135d787578f --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/errors.js @@ -0,0 +1,331 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +const invariant = require('invariant'); +const {ParserError} = require('../errors'); + +class MisnamedModuleTypeScriptInterfaceParserError extends ParserError { + constructor(hasteModuleName: string, id: $FlowFixMe) { + super( + hasteModuleName, + id, + `All TypeScript interfaces extending TurboModule must be called 'Spec'. Please rename TypeScript interface '${id.name}' to 'Spec'.`, + ); + } +} + +class ModuleTypeScriptInterfaceNotFoundParserError extends ParserError { + constructor(hasteModuleName: string, ast: $FlowFixMe) { + super( + hasteModuleName, + ast, + 'No TypeScript interfaces extending TurboModule were detected in this NativeModule spec.', + ); + } +} + +class MoreThanOneModuleTypeScriptInterfaceParserError extends ParserError { + constructor( + hasteModuleName: string, + flowModuleInterfaces: $ReadOnlyArray<$FlowFixMe>, + names: $ReadOnlyArray, + ) { + const finalName = names[names.length - 1]; + const allButLastName = names.slice(0, -1); + const quote = (x: string) => `'${x}'`; + + const nameStr = + allButLastName.map(quote).join(', ') + ', and ' + quote(finalName); + + super( + hasteModuleName, + flowModuleInterfaces, + `Every NativeModule spec file must declare exactly one NativeModule TypeScript interface. This file declares ${names.length}: ${nameStr}. Please remove the extraneous TypeScript interface declarations.`, + ); + } +} + +class UnsupportedModulePropertyParserError extends ParserError { + constructor( + hasteModuleName: string, + propertyValue: $FlowFixMe, + propertyName: string, + invalidPropertyValueType: string, + ) { + super( + hasteModuleName, + propertyValue, + `TypeScript interfaces extending TurboModule must only contain 'FunctionTypeAnnotation's. Property '${propertyName}' refers to a '${invalidPropertyValueType}'.`, + ); + } +} + +class UnsupportedTypeScriptTypeAnnotationParserError extends ParserError { + +typeAnnotationType: string; + constructor(hasteModuleName: string, typeAnnotation: $FlowFixMe) { + super( + hasteModuleName, + typeAnnotation, + `TypeScript type annotation '${typeAnnotation.type}' is unsupported in NativeModule specs.`, + ); + + this.typeAnnotationType = typeAnnotation.type; + } +} + +class UnsupportedTypeScriptGenericParserError extends ParserError { + +genericName: string; + constructor(hasteModuleName: string, genericTypeAnnotation: $FlowFixMe) { + const genericName = genericTypeAnnotation.typeName.name; + super( + hasteModuleName, + genericTypeAnnotation, + `Unrecognized generic type '${genericName}' in NativeModule spec.`, + ); + + this.genericName = genericName; + } +} + +class IncorrectlyParameterizedTypeScriptGenericParserError extends ParserError { + +genericName: string; + +numTypeParameters: number; + + constructor(hasteModuleName: string, genericTypeAnnotation: $FlowFixMe) { + if (genericTypeAnnotation.typeParameters == null) { + super( + hasteModuleName, + genericTypeAnnotation, + `Generic '${genericTypeAnnotation.typeName.name}' must have type parameters.`, + ); + return; + } + + if ( + genericTypeAnnotation.typeParameters.type === + 'TypeParameterInstantiation' && + genericTypeAnnotation.typeParameters.params.length !== 1 + ) { + super( + hasteModuleName, + genericTypeAnnotation.typeParameters, + `Generic '${genericTypeAnnotation.typeName.name}' must have exactly one type parameter.`, + ); + return; + } + + invariant( + false, + "Couldn't create IncorrectlyParameterizedFlowGenericParserError", + ); + } +} + +/** + * Array parsing errors + */ + +class UnsupportedArrayElementTypeAnnotationParserError extends ParserError { + constructor( + hasteModuleName: string, + arrayElementTypeAST: $FlowFixMe, + arrayType: 'Array' | 'ReadonlyArray', + invalidArrayElementType: string, + ) { + super( + hasteModuleName, + arrayElementTypeAST, + `${arrayType} element types cannot be '${invalidArrayElementType}'.`, + ); + } +} + +/** + * Object parsing errors + */ + +class UnsupportedObjectPropertyTypeAnnotationParserError extends ParserError { + constructor( + hasteModuleName: string, + propertyAST: $FlowFixMe, + invalidPropertyType: string, + ) { + let message = `'ObjectTypeAnnotation' cannot contain '${invalidPropertyType}'.`; + + super(hasteModuleName, propertyAST, message); + } +} + +class UnsupportedObjectPropertyValueTypeAnnotationParserError extends ParserError { + constructor( + hasteModuleName: string, + propertyValueAST: $FlowFixMe, + propertyName: string, + invalidPropertyValueType: string, + ) { + super( + hasteModuleName, + propertyValueAST, + `Object property '${propertyName}' cannot have type '${invalidPropertyValueType}'.`, + ); + } +} + +/** + * Function parsing errors + */ + +class UnnamedFunctionParamParserError extends ParserError { + constructor(functionParam: $FlowFixMe, hasteModuleName: string) { + super( + hasteModuleName, + functionParam, + 'All function parameters must be named.', + ); + } +} + +class UnsupportedFunctionParamTypeAnnotationParserError extends ParserError { + constructor( + hasteModuleName: string, + flowParamTypeAnnotation: $FlowFixMe, + paramName: string, + invalidParamType: string, + ) { + super( + hasteModuleName, + flowParamTypeAnnotation, + `Function parameter '${paramName}' cannot have type '${invalidParamType}'.`, + ); + } +} + +class UnsupportedFunctionReturnTypeAnnotationParserError extends ParserError { + constructor( + hasteModuleName: string, + flowReturnTypeAnnotation: $FlowFixMe, + invalidReturnType: string, + ) { + super( + hasteModuleName, + flowReturnTypeAnnotation, + `Function return cannot have type '${invalidReturnType}'.`, + ); + } +} + +class UnusedModuleTypeScriptInterfaceParserError extends ParserError { + constructor(hasteModuleName: string, flowInterface: $FlowFixMe) { + super( + hasteModuleName, + flowInterface, + "Unused NativeModule spec. Please load the NativeModule by calling TurboModuleRegistry.get('').", + ); + } +} + +class MoreThanOneModuleRegistryCallsParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpressions: $FlowFixMe, + numCalls: number, + ) { + super( + hasteModuleName, + flowCallExpressions, + `Every NativeModule spec file must contain exactly one NativeModule load. This file contains ${numCalls}. Please simplify this spec file, splitting it as necessary, to remove the extraneous loads.`, + ); + } +} + +class UntypedModuleRegistryCallParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpression: $FlowFixMe, + methodName: string, + moduleName: string, + ) { + super( + hasteModuleName, + flowCallExpression, + `Please type this NativeModule load: TurboModuleRegistry.${methodName}('${moduleName}').`, + ); + } +} + +class IncorrectModuleRegistryCallTypeParameterParserError extends ParserError { + constructor( + hasteModuleName: string, + flowTypeArguments: $FlowFixMe, + methodName: string, + moduleName: string, + ) { + super( + hasteModuleName, + flowTypeArguments, + `Please change these type arguments to reflect TurboModuleRegistry.${methodName}('${moduleName}').`, + ); + } +} + +class IncorrectModuleRegistryCallArityParserError extends ParserError { + constructor( + hasteModuleName: string, + flowCallExpression: $FlowFixMe, + methodName: string, + incorrectArity: number, + ) { + super( + hasteModuleName, + flowCallExpression, + `Please call TurboModuleRegistry.${methodName}() with exactly one argument. Detected ${incorrectArity}.`, + ); + } +} + +class IncorrectModuleRegistryCallArgumentTypeParserError extends ParserError { + constructor( + hasteModuleName: string, + flowArgument: $FlowFixMe, + methodName: string, + type: string, + ) { + const a = /[aeiouy]/.test(type.toLowerCase()) ? 'an' : 'a'; + super( + hasteModuleName, + flowArgument, + `Please call TurboModuleRegistry.${methodName}() with a string literal. Detected ${a} '${type}'`, + ); + } +} + +module.exports = { + IncorrectlyParameterizedTypeScriptGenericParserError, + MisnamedModuleTypeScriptInterfaceParserError, + ModuleTypeScriptInterfaceNotFoundParserError, + MoreThanOneModuleTypeScriptInterfaceParserError, + UnnamedFunctionParamParserError, + UnsupportedArrayElementTypeAnnotationParserError, + UnsupportedTypeScriptGenericParserError, + UnsupportedTypeScriptTypeAnnotationParserError, + UnsupportedFunctionParamTypeAnnotationParserError, + UnsupportedFunctionReturnTypeAnnotationParserError, + UnsupportedModulePropertyParserError, + UnsupportedObjectPropertyTypeAnnotationParserError, + UnsupportedObjectPropertyValueTypeAnnotationParserError, + UnusedModuleTypeScriptInterfaceParserError, + MoreThanOneModuleRegistryCallsParserError, + UntypedModuleRegistryCallParserError, + IncorrectModuleRegistryCallTypeParameterParserError, + IncorrectModuleRegistryCallArityParserError, + IncorrectModuleRegistryCallArgumentTypeParserError, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/index.js b/packages/react-native-codegen/src/parsers/typescript/modules/index.js new file mode 100644 index 00000000000000..d0e395e31ac007 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/index.js @@ -0,0 +1,800 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import type { + NamedShape, + NativeModuleAliasMap, + NativeModuleArrayTypeAnnotation, + NativeModuleBaseTypeAnnotation, + NativeModuleFunctionTypeAnnotation, + NativeModuleParamTypeAnnotation, + NativeModulePropertyShape, + NativeModuleSchema, + Nullable, +} from '../../../CodegenSchema.js'; + +import type {TypeDeclarationMap} from '../utils.js'; +import type {ParserErrorCapturer} from '../utils'; +import type {NativeModuleTypeAnnotation} from '../../../CodegenSchema.js'; + +const { + resolveTypeAnnotation, + getTypes, + visit, + isModuleRegistryCall, +} = require('../utils.js'); +const {unwrapNullable, wrapNullable} = require('./utils'); +const { + IncorrectlyParameterizedTypeScriptGenericParserError, + MisnamedModuleTypeScriptInterfaceParserError, + ModuleTypeScriptInterfaceNotFoundParserError, + MoreThanOneModuleTypeScriptInterfaceParserError, + UnnamedFunctionParamParserError, + UnsupportedArrayElementTypeAnnotationParserError, + UnsupportedTypeScriptGenericParserError, + UnsupportedTypeScriptTypeAnnotationParserError, + UnsupportedFunctionParamTypeAnnotationParserError, + UnsupportedFunctionReturnTypeAnnotationParserError, + UnsupportedModulePropertyParserError, + UnsupportedObjectPropertyTypeAnnotationParserError, + UnsupportedObjectPropertyValueTypeAnnotationParserError, + UnusedModuleTypeScriptInterfaceParserError, + MoreThanOneModuleRegistryCallsParserError, + UntypedModuleRegistryCallParserError, + IncorrectModuleRegistryCallTypeParameterParserError, + IncorrectModuleRegistryCallArityParserError, + IncorrectModuleRegistryCallArgumentTypeParserError, +} = require('./errors.js'); + +const invariant = require('invariant'); + +function nullGuard(fn: () => T): ?T { + return fn(); +} + +function translateArrayTypeAnnotation( + hasteModuleName: string, + types: TypeDeclarationMap, + aliasMap: {...NativeModuleAliasMap}, + cxxOnly: boolean, + tsArrayType: 'Array' | 'ReadonlyArray', + tsElementType: $FlowFixMe, + nullable: $FlowFixMe, +): Nullable { + try { + /** + * TODO(T72031674): Migrate all our NativeModule specs to not use + * invalid Array ElementTypes. Then, make the elementType a required + * parameter. + */ + const [elementType, isElementTypeNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + tsElementType, + types, + aliasMap, + /** + * TODO(T72031674): Ensure that all ParsingErrors that are thrown + * while parsing the array element don't get captured and collected. + * Why? If we detect any parsing error while parsing the element, + * we should default it to null down the line, here. This is + * the correct behaviour until we migrate all our NativeModule specs + * to be parseable. + */ + nullGuard, + cxxOnly, + ), + ); + + if (elementType.type === 'VoidTypeAnnotation') { + throw new UnsupportedArrayElementTypeAnnotationParserError( + hasteModuleName, + tsElementType, + tsArrayType, + 'void', + ); + } + + if (elementType.type === 'PromiseTypeAnnotation') { + throw new UnsupportedArrayElementTypeAnnotationParserError( + hasteModuleName, + tsElementType, + tsArrayType, + 'Promise', + ); + } + + if (elementType.type === 'FunctionTypeAnnotation') { + throw new UnsupportedArrayElementTypeAnnotationParserError( + hasteModuleName, + tsElementType, + tsArrayType, + 'FunctionTypeAnnotation', + ); + } + + const finalTypeAnnotation: NativeModuleArrayTypeAnnotation< + Nullable, + > = { + type: 'ArrayTypeAnnotation', + elementType: wrapNullable(isElementTypeNullable, elementType), + }; + + return wrapNullable(nullable, finalTypeAnnotation); + } catch (ex) { + return wrapNullable(nullable, { + type: 'ArrayTypeAnnotation', + }); + } +} + +function translateTypeAnnotation( + hasteModuleName: string, + /** + * TODO(T108222691): Use flow-types for @babel/parser + */ + typeScriptTypeAnnotation: $FlowFixMe, + types: TypeDeclarationMap, + aliasMap: {...NativeModuleAliasMap}, + tryParse: ParserErrorCapturer, + cxxOnly: boolean, +): Nullable { + const {nullable, typeAnnotation, typeAliasResolutionStatus} = + resolveTypeAnnotation(typeScriptTypeAnnotation, types); + + switch (typeAnnotation.type) { + case 'TSArrayType': { + return translateArrayTypeAnnotation( + hasteModuleName, + types, + aliasMap, + cxxOnly, + 'Array', + typeAnnotation.elementType, + nullable, + ); + } + case 'TSTypeOperator': { + if ( + typeAnnotation.operator === 'readonly' && + typeAnnotation.typeAnnotation.type === 'TSArrayType' + ) { + return translateArrayTypeAnnotation( + hasteModuleName, + types, + aliasMap, + cxxOnly, + 'ReadonlyArray', + typeAnnotation.typeAnnotation.elementType, + nullable, + ); + } else { + throw new UnsupportedTypeScriptGenericParserError( + hasteModuleName, + typeAnnotation, + ); + } + } + case 'TSTypeReference': { + switch (typeAnnotation.typeName.name) { + case 'RootTag': { + return wrapNullable(nullable, { + type: 'ReservedTypeAnnotation', + name: 'RootTag', + }); + } + case 'Promise': { + assertGenericTypeAnnotationHasExactlyOneTypeParameter( + hasteModuleName, + typeAnnotation, + ); + + return wrapNullable(nullable, { + type: 'PromiseTypeAnnotation', + }); + } + case 'Array': + case 'ReadonlyArray': { + assertGenericTypeAnnotationHasExactlyOneTypeParameter( + hasteModuleName, + typeAnnotation, + ); + + return translateArrayTypeAnnotation( + hasteModuleName, + types, + aliasMap, + cxxOnly, + typeAnnotation.type, + typeAnnotation.typeParameters.params[0], + nullable, + ); + } + case 'Readonly': { + assertGenericTypeAnnotationHasExactlyOneTypeParameter( + hasteModuleName, + typeAnnotation, + ); + + const [paramType, isParamNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typeAnnotation.typeParameters.params[0], + types, + aliasMap, + tryParse, + cxxOnly, + ), + ); + + return wrapNullable(nullable || isParamNullable, paramType); + } + case 'Stringish': { + return wrapNullable(nullable, { + type: 'StringTypeAnnotation', + }); + } + case 'Int32': { + return wrapNullable(nullable, { + type: 'Int32TypeAnnotation', + }); + } + case 'Double': { + return wrapNullable(nullable, { + type: 'DoubleTypeAnnotation', + }); + } + case 'Float': { + return wrapNullable(nullable, { + type: 'FloatTypeAnnotation', + }); + } + case 'UnsafeObject': + case 'Object': { + return wrapNullable(nullable, { + type: 'GenericObjectTypeAnnotation', + }); + } + default: { + throw new UnsupportedTypeScriptGenericParserError( + hasteModuleName, + typeAnnotation, + ); + } + } + } + case 'TSTypeLiteral': { + const objectTypeAnnotation = { + type: 'ObjectTypeAnnotation', + // $FlowFixMe[missing-type-arg] + properties: (typeAnnotation.members: Array<$FlowFixMe>) + .map>>( + property => { + return tryParse(() => { + if (property.type !== 'TSPropertySignature') { + throw new UnsupportedObjectPropertyTypeAnnotationParserError( + hasteModuleName, + property, + property.type, + ); + } + + const {optional = false, key} = property; + + const [propertyTypeAnnotation, isPropertyNullable] = + unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + property.typeAnnotation.typeAnnotation, + types, + aliasMap, + tryParse, + cxxOnly, + ), + ); + + if (propertyTypeAnnotation.type === 'FunctionTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.typeAnnotation.typeAnnotation, + property.key, + propertyTypeAnnotation.type, + ); + } + + if (propertyTypeAnnotation.type === 'VoidTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.typeAnnotation.typeAnnotation, + property.key, + 'void', + ); + } + + if (propertyTypeAnnotation.type === 'PromiseTypeAnnotation') { + throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( + hasteModuleName, + property.typeAnnotation.typeAnnotation, + property.key, + 'Promise', + ); + } + + return { + name: key.name, + optional, + typeAnnotation: wrapNullable( + isPropertyNullable, + propertyTypeAnnotation, + ), + }; + }); + }, + ) + .filter(Boolean), + }; + + if (!typeAliasResolutionStatus.successful) { + return wrapNullable(nullable, objectTypeAnnotation); + } + + /** + * All aliases RHS are required. + */ + aliasMap[typeAliasResolutionStatus.aliasName] = objectTypeAnnotation; + + /** + * Nullability of type aliases is transitive. + * + * Consider this case: + * + * type Animal = ?{ + * name: string, + * }; + * + * type B = Animal + * + * export interface Spec extends TurboModule { + * +greet: (animal: B) => void; + * } + * + * In this case, we follow B to Animal, and then Animal to ?{name: string}. + * + * We: + * 1. Replace `+greet: (animal: B) => void;` with `+greet: (animal: ?Animal) => void;`, + * 2. Pretend that Animal = {name: string}. + * + * Why do we do this? + * 1. In ObjC, we need to generate a struct called Animal, not B. + * 2. This design is simpler than managing nullability within both the type alias usage, and the type alias RHS. + * 3. What does it mean for a C++ struct, which is what this type alias RHS will generate, to be nullable? ¯\_(ツ)_/¯ + * Nullability is a concept that only makes sense when talking about instances (i.e: usages) of the C++ structs. + * Hence, it's better to manage nullability within the actual TypeAliasTypeAnnotation nodes, and not the + * associated ObjectTypeAnnotations. + */ + return wrapNullable(nullable, { + type: 'TypeAliasTypeAnnotation', + name: typeAliasResolutionStatus.aliasName, + }); + } + case 'TSBooleanKeyword': { + return wrapNullable(nullable, { + type: 'BooleanTypeAnnotation', + }); + } + case 'TSNumberKeyword': { + return wrapNullable(nullable, { + type: 'NumberTypeAnnotation', + }); + } + case 'TSVoidKeyword': { + return wrapNullable(nullable, { + type: 'VoidTypeAnnotation', + }); + } + case 'TSStringKeyword': { + return wrapNullable(nullable, { + type: 'StringTypeAnnotation', + }); + } + case 'TSFunctionType': { + return wrapNullable( + nullable, + translateFunctionTypeAnnotation( + hasteModuleName, + typeAnnotation, + types, + aliasMap, + tryParse, + cxxOnly, + ), + ); + } + case 'TSUnknownKeyword': { + if (cxxOnly) { + return wrapNullable(nullable, { + type: 'MixedTypeAnnotation', + }); + } + // Fallthrough + } + default: { + throw new UnsupportedTypeScriptTypeAnnotationParserError( + hasteModuleName, + typeAnnotation, + ); + } + } +} + +function assertGenericTypeAnnotationHasExactlyOneTypeParameter( + moduleName: string, + /** + * TODO(T108222691): Use flow-types for @babel/parser + */ + typeAnnotation: $FlowFixMe, +) { + if (typeAnnotation.typeParameters == null) { + throw new IncorrectlyParameterizedTypeScriptGenericParserError( + moduleName, + typeAnnotation, + ); + } + + invariant( + typeAnnotation.typeParameters.type === 'TSTypeParameterInstantiation', + "assertGenericTypeAnnotationHasExactlyOneTypeParameter: Type parameters must be an AST node of type 'TSTypeParameterInstantiation'", + ); + + if (typeAnnotation.typeParameters.params.length !== 1) { + throw new IncorrectlyParameterizedTypeScriptGenericParserError( + moduleName, + typeAnnotation, + ); + } +} + +function translateFunctionTypeAnnotation( + hasteModuleName: string, + // TODO(T108222691): Use flow-types for @babel/parser + typescriptFunctionTypeAnnotation: $FlowFixMe, + types: TypeDeclarationMap, + aliasMap: {...NativeModuleAliasMap}, + tryParse: ParserErrorCapturer, + cxxOnly: boolean, +): NativeModuleFunctionTypeAnnotation { + type Param = NamedShape>; + const params: Array = []; + + for (const typeScriptParam of (typescriptFunctionTypeAnnotation.parameters: $ReadOnlyArray<$FlowFixMe>)) { + const parsedParam = tryParse(() => { + if (typeScriptParam.typeAnnotation == null) { + throw new UnnamedFunctionParamParserError( + typeScriptParam, + hasteModuleName, + ); + } + + const paramName = typeScriptParam.name; + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typeScriptParam.typeAnnotation.typeAnnotation, + types, + aliasMap, + tryParse, + cxxOnly, + ), + ); + + if (paramTypeAnnotation.type === 'VoidTypeAnnotation') { + throw new UnsupportedFunctionParamTypeAnnotationParserError( + hasteModuleName, + typeScriptParam.typeAnnotation, + paramName, + 'void', + ); + } + + if (paramTypeAnnotation.type === 'PromiseTypeAnnotation') { + throw new UnsupportedFunctionParamTypeAnnotationParserError( + hasteModuleName, + typeScriptParam.typeAnnotation, + paramName, + 'Promise', + ); + } + + return { + name: typeScriptParam.name, + optional: Boolean(typeScriptParam.optional), + typeAnnotation: wrapNullable( + isParamTypeAnnotationNullable, + paramTypeAnnotation, + ), + }; + }); + + if (parsedParam != null) { + params.push(parsedParam); + } + } + + const [returnTypeAnnotation, isReturnTypeAnnotationNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typescriptFunctionTypeAnnotation.typeAnnotation.typeAnnotation, + types, + aliasMap, + tryParse, + cxxOnly, + ), + ); + + if (!cxxOnly && returnTypeAnnotation.type === 'FunctionTypeAnnotation') { + throw new UnsupportedFunctionReturnTypeAnnotationParserError( + hasteModuleName, + typescriptFunctionTypeAnnotation.returnType, + 'FunctionTypeAnnotation', + ); + } + + return { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: wrapNullable( + isReturnTypeAnnotationNullable, + returnTypeAnnotation, + ), + params, + }; +} + +function buildPropertySchema( + hasteModuleName: string, + // TODO(T108222691): Use flow-types for @babel/parser + property: $FlowFixMe, + types: TypeDeclarationMap, + aliasMap: {...NativeModuleAliasMap}, + tryParse: ParserErrorCapturer, + cxxOnly: boolean, +): NativeModulePropertyShape { + let nullable = false; + let {key} = property; + let value = + property.type === 'TSMethodSignature' ? property : property.typeAnnotation; + + const methodName: string = key.name; + + ({nullable, typeAnnotation: value} = resolveTypeAnnotation(value, types)); + + if (value.type !== 'TSFunctionType' && value.type !== 'TSMethodSignature') { + throw new UnsupportedModulePropertyParserError( + hasteModuleName, + property.value, + property.key.name, + value.type, + ); + } + + return { + name: methodName, + optional: Boolean(property.optional), + typeAnnotation: wrapNullable( + nullable, + translateFunctionTypeAnnotation( + hasteModuleName, + value, + types, + aliasMap, + tryParse, + cxxOnly, + ), + ), + }; +} + +function isModuleInterface(node: $FlowFixMe) { + return ( + node.type === 'TSInterfaceDeclaration' && + node.extends.length === 1 && + node.extends[0].type === 'TSExpressionWithTypeArguments' && + node.extends[0].expression.name === 'TurboModule' + ); +} + +function buildModuleSchema( + hasteModuleName: string, + /** + * TODO(T108222691): Use flow-types for @babel/parser + */ + ast: $FlowFixMe, + tryParse: ParserErrorCapturer, +): NativeModuleSchema { + const types = getTypes(ast); + const moduleSpecs = (Object.values(types): $ReadOnlyArray<$FlowFixMe>).filter( + isModuleInterface, + ); + + if (moduleSpecs.length === 0) { + throw new ModuleTypeScriptInterfaceNotFoundParserError( + hasteModuleName, + ast, + ); + } + + if (moduleSpecs.length > 1) { + throw new MoreThanOneModuleTypeScriptInterfaceParserError( + hasteModuleName, + moduleSpecs, + moduleSpecs.map(node => node.id.name), + ); + } + + const [moduleSpec] = moduleSpecs; + + if (moduleSpec.id.name !== 'Spec') { + throw new MisnamedModuleTypeScriptInterfaceParserError( + hasteModuleName, + moduleSpec.id, + ); + } + + // Parse Module Names + const moduleName = tryParse((): string => { + const callExpressions = []; + visit(ast, { + CallExpression(node) { + if (isModuleRegistryCall(node)) { + callExpressions.push(node); + } + }, + }); + + if (callExpressions.length === 0) { + throw new UnusedModuleTypeScriptInterfaceParserError( + hasteModuleName, + moduleSpec, + ); + } + + if (callExpressions.length > 1) { + throw new MoreThanOneModuleRegistryCallsParserError( + hasteModuleName, + callExpressions, + callExpressions.length, + ); + } + + const [callExpression] = callExpressions; + const {typeParameters} = callExpression; + const methodName = callExpression.callee.property.name; + + if (callExpression.arguments.length !== 1) { + throw new IncorrectModuleRegistryCallArityParserError( + hasteModuleName, + callExpression, + methodName, + callExpression.arguments.length, + ); + } + + if (callExpression.arguments[0].type !== 'StringLiteral') { + const {type} = callExpression.arguments[0]; + throw new IncorrectModuleRegistryCallArgumentTypeParserError( + hasteModuleName, + callExpression.arguments[0], + methodName, + type, + ); + } + + const $moduleName = callExpression.arguments[0].value; + + if (typeParameters == null) { + throw new UntypedModuleRegistryCallParserError( + hasteModuleName, + callExpression, + methodName, + $moduleName, + ); + } + + if ( + typeParameters.type !== 'TSTypeParameterInstantiation' || + typeParameters.params.length !== 1 || + typeParameters.params[0].type !== 'TSTypeReference' || + typeParameters.params[0].typeName.name !== 'Spec' + ) { + throw new IncorrectModuleRegistryCallTypeParameterParserError( + hasteModuleName, + typeParameters, + methodName, + $moduleName, + ); + } + + return $moduleName; + }); + + const moduleNames = moduleName == null ? [] : [moduleName]; + + // Some module names use platform suffix to indicate platform-exclusive modules. + // Eventually this should be made explicit in the Flow type itself. + // Also check the hasteModuleName for platform suffix. + // Note: this shape is consistent with ComponentSchema. + let cxxOnly = false; + const excludedPlatforms = []; + const namesToValidate = [...moduleNames, hasteModuleName]; + namesToValidate.forEach(name => { + if (name.endsWith('Android')) { + excludedPlatforms.push('iOS'); + } else if (name.endsWith('IOS')) { + excludedPlatforms.push('android'); + } else if (name.endsWith('Cxx')) { + cxxOnly = true; + excludedPlatforms.push('iOS', 'android'); + } + }); + + // $FlowFixMe[missing-type-arg] + return (moduleSpec.body.body: $ReadOnlyArray<$FlowFixMe>) + .filter( + property => + property.type === 'TSMethodSignature' || + property.type === 'TSPropertySignature', + ) + .map(property => { + const aliasMap: {...NativeModuleAliasMap} = {}; + + return tryParse(() => ({ + aliasMap: aliasMap, + propertyShape: buildPropertySchema( + hasteModuleName, + property, + types, + aliasMap, + tryParse, + cxxOnly, + ), + })); + }) + .filter(Boolean) + .reduce( + (moduleSchema: NativeModuleSchema, {aliasMap, propertyShape}) => { + return { + type: 'NativeModule', + aliases: {...moduleSchema.aliases, ...aliasMap}, + spec: { + properties: [...moduleSchema.spec.properties, propertyShape], + }, + moduleNames: moduleSchema.moduleNames, + excludedPlatforms: moduleSchema.excludedPlatforms, + }; + }, + { + type: 'NativeModule', + aliases: {}, + spec: {properties: []}, + moduleNames: moduleNames, + excludedPlatforms: + excludedPlatforms.length !== 0 ? [...excludedPlatforms] : undefined, + }, + ); +} + +module.exports = { + buildModuleSchema, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/schema.js b/packages/react-native-codegen/src/parsers/typescript/modules/schema.js new file mode 100644 index 00000000000000..4e3fda6bea4a90 --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/schema.js @@ -0,0 +1,28 @@ +/** + * 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. + * + * @format + * @flow strict + */ + +'use strict'; + +import type {SchemaType, NativeModuleSchema} from '../../../CodegenSchema.js'; + +function wrapModuleSchema( + nativeModuleSchema: NativeModuleSchema, + hasteModuleName: string, +): SchemaType { + return { + modules: { + [hasteModuleName]: nativeModuleSchema, + }, + }; +} + +module.exports = { + wrapModuleSchema, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/utils.js b/packages/react-native-codegen/src/parsers/typescript/modules/utils.js new file mode 100644 index 00000000000000..b013f76c8ce59e --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/modules/utils.js @@ -0,0 +1,45 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +'use strict'; + +import type { + NativeModuleTypeAnnotation, + Nullable, +} from '../../../CodegenSchema.js'; + +function unwrapNullable<+T: NativeModuleTypeAnnotation>( + x: Nullable, +): [T, boolean] { + if (x.type === 'NullableTypeAnnotation') { + return [x.typeAnnotation, true]; + } + + return [x, false]; +} + +function wrapNullable<+T: NativeModuleTypeAnnotation>( + nullable: boolean, + typeAnnotation: T, +): Nullable { + if (!nullable) { + return typeAnnotation; + } + + return { + type: 'NullableTypeAnnotation', + typeAnnotation, + }; +} + +module.exports = { + unwrapNullable, + wrapNullable, +}; diff --git a/packages/react-native-codegen/src/parsers/typescript/utils.js b/packages/react-native-codegen/src/parsers/typescript/utils.js new file mode 100644 index 00000000000000..685e6b50390beb --- /dev/null +++ b/packages/react-native-codegen/src/parsers/typescript/utils.js @@ -0,0 +1,227 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +'use strict'; + +const {ParserError} = require('./errors'); + +/** + * TODO(T108222691): Use flow-types for @babel/parser + */ +export type TypeDeclarationMap = {[declarationName: string]: $FlowFixMe}; + +function getTypes(ast: $FlowFixMe): TypeDeclarationMap { + return ast.body.reduce((types, node) => { + if (node.type === 'ExportNamedDeclaration' && node.exportKind === 'type') { + if ( + node.declaration.type === 'TSTypeAliasDeclaration' || + node.declaration.type === 'TSInterfaceDeclaration' + ) { + types[node.declaration.id.name] = node.declaration; + } + } else if ( + node.type === 'TSTypeAliasDeclaration' || + node.type === 'TSInterfaceDeclaration' + ) { + types[node.id.name] = node; + } + + return types; + }, {}); +} + +// $FlowFixMe[unclear-type] Use flow-types for @babel/parser +export type ASTNode = Object; + +const invariant = require('invariant'); + +type TypeAliasResolutionStatus = + | $ReadOnly<{ + successful: true, + aliasName: string, + }> + | $ReadOnly<{ + successful: false, + }>; + +function resolveTypeAnnotation( + // TODO(T108222691): Use flow-types for @babel/parser + typeAnnotation: $FlowFixMe, + types: TypeDeclarationMap, +): { + nullable: boolean, + typeAnnotation: $FlowFixMe, + typeAliasResolutionStatus: TypeAliasResolutionStatus, +} { + invariant( + typeAnnotation != null, + 'resolveTypeAnnotation(): typeAnnotation cannot be null', + ); + + let node = + typeAnnotation.type === 'TSTypeAnnotation' + ? typeAnnotation.typeAnnotation + : typeAnnotation; + let nullable = false; + let typeAliasResolutionStatus: TypeAliasResolutionStatus = { + successful: false, + }; + + for (;;) { + // Check for optional type in union e.g. T | null | undefined + if ( + node.type === 'TSUnionType' && + node.types.some( + t => t.type === 'TSNullKeyword' || t.type === 'TSUndefinedKeyword', + ) + ) { + node = node.types.filter( + t => t.type !== 'TSNullKeyword' && t.type !== 'TSUndefinedKeyword', + )[0]; + nullable = true; + } else if (node.type === 'TSTypeReference') { + typeAliasResolutionStatus = { + successful: true, + aliasName: node.typeName.name, + }; + const resolvedTypeAnnotation = types[node.typeName.name]; + if (resolvedTypeAnnotation == null) { + break; + } + + invariant( + resolvedTypeAnnotation.type === 'TSTypeAliasDeclaration', + `GenericTypeAnnotation '${node.typeName.name}' must resolve to a TSTypeAliasDeclaration. Instead, it resolved to a '${resolvedTypeAnnotation.type}'`, + ); + + node = resolvedTypeAnnotation.typeAnnotation; + } else { + break; + } + } + + return { + nullable: nullable, + typeAnnotation: node, + typeAliasResolutionStatus, + }; +} + +function getValueFromTypes(value: ASTNode, types: TypeDeclarationMap): ASTNode { + if (value.type === 'TSTypeReference' && types[value.typeName.name]) { + return getValueFromTypes(types[value.typeName.name], types); + } + + if (value.type === 'TSTypeAliasDeclaration') { + return value.typeAnnotation; + } + + return value; +} + +export type ParserErrorCapturer = (fn: () => T) => ?T; + +function createParserErrorCapturer(): [ + Array, + ParserErrorCapturer, +] { + const errors = []; + function guard(fn: () => T): ?T { + try { + return fn(); + } catch (error) { + if (!(error instanceof ParserError)) { + throw error; + } + errors.push(error); + + return null; + } + } + + return [errors, guard]; +} + +// TODO(T108222691): Use flow-types for @babel/parser +function visit( + astNode: $FlowFixMe, + visitor: { + [type: string]: (node: $FlowFixMe) => void, + }, +) { + const queue = [astNode]; + while (queue.length !== 0) { + let item = queue.shift(); + + if (!(typeof item === 'object' && item != null)) { + continue; + } + + if ( + typeof item.type === 'string' && + typeof visitor[item.type] === 'function' + ) { + // Don't visit any children + visitor[item.type](item); + } else if (Array.isArray(item)) { + queue.push(...item); + } else { + queue.push(...Object.values(item)); + } + } +} + +// TODO(T108222691): Use flow-types for @babel/parser +function isModuleRegistryCall(node: $FlowFixMe): boolean { + if (node.type !== 'CallExpression') { + return false; + } + + const callExpression = node; + + if (callExpression.callee.type !== 'MemberExpression') { + return false; + } + + const memberExpression = callExpression.callee; + if ( + !( + memberExpression.object.type === 'Identifier' && + memberExpression.object.name === 'TurboModuleRegistry' + ) + ) { + return false; + } + + if ( + !( + memberExpression.property.type === 'Identifier' && + (memberExpression.property.name === 'get' || + memberExpression.property.name === 'getEnforcing') + ) + ) { + return false; + } + + if (memberExpression.computed) { + return false; + } + + return true; +} + +module.exports = { + getValueFromTypes, + resolveTypeAnnotation, + createParserErrorCapturer, + getTypes, + visit, + isModuleRegistryCall, +}; diff --git a/packages/react-native-gradle-plugin/BUCK b/packages/react-native-gradle-plugin/BUCK new file mode 100644 index 00000000000000..8fd38289431bdb --- /dev/null +++ b/packages/react-native-gradle-plugin/BUCK @@ -0,0 +1,23 @@ +load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace") + +yarn_workspace( + name = "yarn-workspace", + srcs = glob( + ["**/*.js"], + exclude = [ + "**/__fixtures__/**", + "**/__flowtests__/**", + "**/__mocks__/**", + "**/__server_snapshot_tests__/**", + "**/__tests__/**", + "**/node_modules/**", + "**/node_modules/.bin/**", + "**/.*", + "**/.*/**", + "**/.*/.*", + "**/*.xcodeproj/**", + "**/*.xcworkspace/**", + ], + ), + visibility = ["PUBLIC"], +) diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts index 6320a994ad4051..7ba884ae58f528 100644 --- a/packages/react-native-gradle-plugin/build.gradle.kts +++ b/packages/react-native-gradle-plugin/build.gradle.kts @@ -1,15 +1,16 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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 org.gradle.api.internal.classpath.ModuleRegistry +import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.configurationcache.extensions.serviceOf plugins { - kotlin("jvm") version "1.5.31" + kotlin("jvm") version "1.6.10" id("java-gradle-plugin") } @@ -27,15 +28,40 @@ gradlePlugin { } } +group = "com.facebook.react" + dependencies { implementation(gradleApi()) - implementation("com.android.tools.build:gradle:4.2.2") + implementation("com.android.tools.build:gradle:7.2.1") + implementation("com.google.code.gson:gson:2.8.9") + implementation("com.google.guava:guava:31.0.1-jre") + implementation("com.squareup:javapoet:1.13.0") testImplementation("junit:junit:4.13.2") testRuntimeOnly( - files( - serviceOf().getModule("gradle-tooling-api-builders").classpath.asFiles.first() - ) - ) + files( + serviceOf() + .getModule("gradle-tooling-api-builders") + .classpath + .asFiles + .first())) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType { + kotlinOptions { jvmTarget = JavaVersion.VERSION_11.majorVersion } +} + +tasks.withType().configureEach { + testLogging { + exceptionFormat = TestExceptionFormat.FULL + showExceptions = true + showCauses = true + showStackTraces = true + } } diff --git a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae884..41d9927a4d4fb3 100644 Binary files a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar and b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties index fbce071a31a26b..92f06b50fd65b4 100644 --- a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/packages/react-native-gradle-plugin/package.json b/packages/react-native-gradle-plugin/package.json index 88e40ce9c39cb8..5b9389ed331649 100644 --- a/packages/react-native-gradle-plugin/package.json +++ b/packages/react-native-gradle-plugin/package.json @@ -1,6 +1,6 @@ { "name": "react-native-gradle-plugin", - "version": "0.0.3", + "version": "0.70.0", "description": "⚛️ Gradle Plugin for React Native", "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-gradle-plugin", "repository": { @@ -23,8 +23,6 @@ "src/main", "README.md" ], - "dependencies": { - "react-native-codegen": "*" - }, + "dependencies": {}, "devDependencies": {} } diff --git a/packages/react-native-gradle-plugin/settings.gradle.kts b/packages/react-native-gradle-plugin/settings.gradle.kts index 7e74af1ef9702a..8daf82d475afec 100644 --- a/packages/react-native-gradle-plugin/settings.gradle.kts +++ b/packages/react-native-gradle-plugin/settings.gradle.kts @@ -1,13 +1,16 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. */ pluginManagement { - repositories { - gradlePluginPortal() - google() - } + repositories { + mavenCentral() + google() + gradlePluginPortal() + } } + +rootProject.name = "react-native-gradle-plugin" diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/JavaGenerator.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/JavaGenerator.java deleted file mode 100644 index feed3fc21e0c35..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/JavaGenerator.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.TypeData; -import com.facebook.react.codegen.generator.resolver.ResolvedType; -import com.facebook.react.codegen.generator.resolver.TypeResolver; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.TypeSpec; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Given a react-native-codegen JSON schema, generate a set of .java files for React Native. The - * generator is isolated to a single schema, and a single Java package output. - */ -public final class JavaGenerator { - public static final String LICENSE_HEADER = - "/*\n" - + " * Copyright (c) Facebook, Inc. and its affiliates.\n" - + " *\n" - + " * This source code is licensed under the MIT license found in the\n" - + " * LICENSE file in the root directory of this source tree.\n" - + " *\n" - + " * Generated by react-native-codegen JavaGenerator.\n" - + " *\n" - + " * @" - + "generated\n" - + " * @" - + "nolint\n" - + " */\n\n"; - private final File mSchemaFile; - private final String mJavaPackageName; - private final File mOutputDir; - - public JavaGenerator(final File schemaFile, final String javaPackageName, final File outputDir) { - mSchemaFile = schemaFile; - mJavaPackageName = javaPackageName; - mOutputDir = outputDir; - } - - public void build() throws CodegenException, FileNotFoundException, IOException { - // Step 1: Given a schema JSON, collect all types. - final TypeData typeData = SchemaJsonParser.parse(mSchemaFile); - - // Step 2: Resolve each type, then collect those that produce a class or interface (TypeSpec). - final List typeSpecsToWrite = - typeData.getAllTypes().stream() - .map( - t -> { - final ResolvedType resolvedType = - TypeResolver.resolveType(typeData.getType(t), typeData, false); - final TypeSpec spec = resolvedType.getGeneratedCode(mJavaPackageName); - return spec; - }) - .filter(f -> f != null) - .collect(Collectors.toList()); - - // Step 3: Write all of the TypeSpec's into the output directory. - for (final TypeSpec typeSpec : typeSpecsToWrite) { - writeTypeSpecToFile(typeSpec); - } - } - - private final void writeTypeSpecToFile(final TypeSpec typeSpec) - throws CodegenException, IOException { - JavaFile file = JavaFile.builder(mJavaPackageName, typeSpec).skipJavaLangImports(true).build(); - - // Instead of using JavaFile.writeTo() API, manage the output files ourselves because - // JavaFile.addFileComment() does not support "block comment" style. - // See https://github.com/square/javapoet/issues/682#issuecomment-512238075. - Path outputDirPath = new File(mOutputDir, "java").toPath(); - - if (Files.exists(outputDirPath) && !Files.isDirectory(outputDirPath)) { - throw new CodegenException( - "Output path " + outputDirPath + " exists but is not a directory."); - } - - if (!mJavaPackageName.isEmpty()) { - for (String packageComponent : mJavaPackageName.split("\\.")) { - outputDirPath = outputDirPath.resolve(packageComponent); - } - Files.createDirectories(outputDirPath); - } - - Path outputPath = outputDirPath.resolve(typeSpec.name + ".java"); - try (Writer writer = new OutputStreamWriter(Files.newOutputStream(outputPath), UTF_8)) { - writer.write(LICENSE_HEADER + file.toString()); - } - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/SchemaJsonParser.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/SchemaJsonParser.java deleted file mode 100644 index 422317a787341c..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/SchemaJsonParser.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator; - -import com.facebook.react.codegen.generator.model.AliasType; -import com.facebook.react.codegen.generator.model.AnyType; -import com.facebook.react.codegen.generator.model.ArrayType; -import com.facebook.react.codegen.generator.model.BooleanType; -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.DoubleType; -import com.facebook.react.codegen.generator.model.FloatType; -import com.facebook.react.codegen.generator.model.FunctionType; -import com.facebook.react.codegen.generator.model.GenericObjectType; -import com.facebook.react.codegen.generator.model.Int32Type; -import com.facebook.react.codegen.generator.model.NativeModuleType; -import com.facebook.react.codegen.generator.model.NullableType; -import com.facebook.react.codegen.generator.model.NumberType; -import com.facebook.react.codegen.generator.model.ObjectType; -import com.facebook.react.codegen.generator.model.PromiseType; -import com.facebook.react.codegen.generator.model.ReservedFunctionValueType; -import com.facebook.react.codegen.generator.model.StringType; -import com.facebook.react.codegen.generator.model.Type; -import com.facebook.react.codegen.generator.model.TypeData; -import com.facebook.react.codegen.generator.model.TypeId; -import com.facebook.react.codegen.generator.model.VoidType; -import com.google.common.base.CaseFormat; -import com.google.common.collect.ImmutableList; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -public final class SchemaJsonParser { - private final TypeData mTypeData = new TypeData(); - - public static TypeData parse(final File schemaFile) - throws CodegenException, FileNotFoundException, IOException { - final SchemaJsonParser parser = new SchemaJsonParser(); - return parser.buildTypeData(schemaFile); - } - - private TypeData buildTypeData(final File schemaFile) - throws CodegenException, FileNotFoundException, IOException { - final JsonParser parser = new JsonParser(); - final JsonElement rootElement = parser.parse(new FileReader(schemaFile)); - - final Map> collection = new HashMap<>(); - - if (rootElement.isJsonObject()) { - final JsonObject root = rootElement.getAsJsonObject(); - final JsonObject modules = root.getAsJsonObject("modules"); - modules - .entrySet() - .forEach( - entry -> { - final String jsModuleName = entry.getKey(); - final JsonObject jsModule = entry.getValue().getAsJsonObject(); - final String jsModuleType = jsModule.get("type").getAsString(); - - if (!"NativeModule".equals(jsModuleType)) { - return; - } - - if (jsModule.has("excludedPlatforms")) { - final JsonArray excludedPlatforms = jsModule.getAsJsonArray("excludedPlatforms"); - for (JsonElement p : excludedPlatforms) { - if (p.getAsString().equals("android")) { - // This module is not for Android. - return; - } - } - } - - final Type parsedType = - parseNativeModule( - // TODO (T71955395): NativeModule spec type name does not - // exist in the schema. For now assume it's "Spec". - // The final type name will be the output class name. - TypeId.of(jsModuleName, jsModuleName + "Spec"), jsModule); - mTypeData.addType(parsedType); - }); - } - - return mTypeData; - } - - // Parse type information from a JSON "typeAnnotation" node. - private Type parseTypeAnnotation(final TypeId typeId, final JsonObject originalTypeAnnotation) { - JsonObject typeAnnotation = originalTypeAnnotation; - String type = typeAnnotation.get("type").getAsString(); - boolean nullable = false; - Type parsedType = null; - - if (type.equals(NullableType.TYPE_NAME)) { - nullable = true; - typeAnnotation = typeAnnotation.get("typeAnnotation").getAsJsonObject(); - type = typeAnnotation.get("type").getAsString(); - } - - switch (type) { - case AliasType.TYPE_NAME: - parsedType = parseAliasTypeAnnotation(typeId, typeAnnotation); - break; - case AnyType.TYPE_NAME: - parsedType = new AnyType(typeId); - break; - case ArrayType.TYPE_NAME: - parsedType = parseArrayTypeAnnotation(typeId, typeAnnotation); - break; - case BooleanType.TYPE_NAME: - parsedType = new BooleanType(typeId); - break; - case DoubleType.TYPE_NAME: - parsedType = new DoubleType(typeId); - break; - case FloatType.TYPE_NAME: - parsedType = new FloatType(typeId); - break; - case FunctionType.TYPE_NAME: - parsedType = parseFunctionTypeAnnotation(typeId, typeAnnotation); - break; - case GenericObjectType.TYPE_NAME: - parsedType = new GenericObjectType(typeId); - break; - case Int32Type.TYPE_NAME: - parsedType = new Int32Type(typeId); - break; - case NumberType.TYPE_NAME: - // Use double type for generic numbers. - parsedType = new DoubleType(typeId); - break; - case ObjectType.TYPE_NAME: - parsedType = parseObjectTypeAnnotation(typeId, typeAnnotation); - break; - case PromiseType.TYPE_NAME: - parsedType = new PromiseType(typeId); - break; - case ReservedFunctionValueType.TYPE_NAME: - parsedType = parseReservedFunctionValueTypeAnnotation(typeId, typeAnnotation); - break; - case StringType.TYPE_NAME: - parsedType = new StringType(typeId); - break; - case VoidType.TYPE_NAME: - return VoidType.VOID; - default: - throw new CodegenException("Found invalid type annotation: " + type); - } - - final Type finalType = maybeCreateNullableType(nullable, parsedType); - mTypeData.addType(finalType); - return finalType; - } - - private NativeModuleType parseNativeModule(final TypeId typeId, final JsonObject json) { - final JsonObject aliases = json.getAsJsonObject("aliases"); - final JsonArray properties = json.getAsJsonObject("spec").getAsJsonArray("properties"); - - final ImmutableList collectedAliases = - ImmutableList.copyOf( - aliases.entrySet().stream() - .map( - entry -> { - final String typeName = entry.getKey(); - final JsonObject typeAnnotation = entry.getValue().getAsJsonObject(); - // The alias name is the type name that other types can refer to. - return parseTypeAnnotation( - TypeId.of(typeId.moduleName, typeName), typeAnnotation); - }) - .collect(Collectors.toList())); - - ImmutableList.Builder collectedPropertiesBuilder = - new ImmutableList.Builder<>(); - properties.forEach( - p -> { - final JsonObject node = p.getAsJsonObject(); - final String name = node.get("name").getAsString(); - final JsonObject typeAnnotation = node.getAsJsonObject("typeAnnotation"); - final boolean optional = node.get("optional").getAsBoolean(); - final TypeId propertyTypeId = - TypeId.expandOf(typeId, CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, name)); - collectedPropertiesBuilder.add( - new NativeModuleType.Property( - name, parseTypeAnnotation(propertyTypeId, typeAnnotation), optional)); - }); - - return new NativeModuleType(typeId, collectedAliases, collectedPropertiesBuilder.build()); - } - - private Type parseAliasTypeAnnotation(final TypeId typeId, final JsonObject typeAnnotation) { - // For now, assume the alias lives inside the same file. - return new AliasType( - typeId, TypeId.of(typeId.moduleName, typeAnnotation.get("name").getAsString())); - } - - private Type parseArrayTypeAnnotation(final TypeId typeId, final JsonObject typeAnnotation) { - final JsonObject elementTypeAnnotation = typeAnnotation.getAsJsonObject("elementType"); - final TypeId elementTypeId = TypeId.expandOf(typeId, "ElementType"); - // TODO (T71847026): Some array types are missing elementType annotation. - final Type elementType = - elementTypeAnnotation != null - ? parseTypeAnnotation(elementTypeId, elementTypeAnnotation) - : new AnyType(elementTypeId); - return new ArrayType(typeId, elementType); - } - - private Type parseFunctionTypeAnnotation(final TypeId typeId, final JsonObject typeAnnotation) { - final JsonArray params = typeAnnotation.getAsJsonArray("params"); - - ImmutableList.Builder paramsList = new ImmutableList.Builder<>(); - - for (int i = 0; i < params.size(); i++) { - final JsonElement p = params.get(i); - final JsonObject node = p.getAsJsonObject(); - final String name = node.get("name").getAsString(); - paramsList.add( - FunctionType.createArgument( - name, - parseTypeAnnotation( - TypeId.expandOf(typeId, CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, name)), - node.getAsJsonObject("typeAnnotation")))); - } - - final JsonObject returnTypeAnnotation = typeAnnotation.getAsJsonObject("returnTypeAnnotation"); - final Type returnType = - parseTypeAnnotation(TypeId.expandOf(typeId, "ReturnType"), returnTypeAnnotation); - - return new FunctionType(typeId, paramsList.build(), returnType); - } - - private Type parseObjectTypeAnnotation(final TypeId typeId, final JsonObject typeAnnotation) { - final JsonArray properties = typeAnnotation.getAsJsonArray("properties"); - - ImmutableList.Builder propertiesList = new ImmutableList.Builder<>(); - properties.forEach( - p -> { - final JsonObject node = p.getAsJsonObject(); - final String name = node.get("name").getAsString(); - final boolean optional = node.get("optional").getAsBoolean(); - final JsonObject propertyTypeAnnotation = node.getAsJsonObject("typeAnnotation"); - final TypeId propertyTypeId = - TypeId.expandOf(typeId, CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, name)); - final Type propertyType = parseTypeAnnotation(propertyTypeId, propertyTypeAnnotation); - propertiesList.add(new ObjectType.Property(name, propertyType, optional)); - }); - - return new ObjectType(typeId, propertiesList.build()); - } - - private Type parseReservedFunctionValueTypeAnnotation( - final TypeId typeId, final JsonObject typeAnnotation) { - return new ReservedFunctionValueType( - typeId, - ReservedFunctionValueType.ReservedName.valueOf(typeAnnotation.get("name").getAsString())); - } - - private Type maybeCreateNullableType(final boolean nullable, final Type original) { - if (!nullable || original instanceof VoidType) { - return original; - } - return new NullableType(TypeId.of(original.getTypeId()), original); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AliasType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AliasType.java deleted file mode 100644 index 4114dc52c834a7..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AliasType.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class AliasType extends Type { - public static final String TYPE_NAME = "TypeAliasTypeAnnotation"; - - public final TypeId referredTypeId; - - public AliasType(final TypeId typeId, final TypeId referredTypeId) { - super(typeId); - this.referredTypeId = referredTypeId; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AnyType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AnyType.java deleted file mode 100644 index ce22b2044752d4..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/AnyType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class AnyType extends Type { - public static final String TYPE_NAME = "AnyTypeAnnotation"; - - public AnyType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ArrayType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ArrayType.java deleted file mode 100644 index 536a082e5a834c..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ArrayType.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class ArrayType extends Type { - public static final String TYPE_NAME = "ArrayTypeAnnotation"; - - public final Type elementType; - - public ArrayType(final TypeId typeId, final Type elementType) { - super(typeId); - this.elementType = elementType; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/BooleanType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/BooleanType.java deleted file mode 100644 index c5f8b9be17b5b1..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/BooleanType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class BooleanType extends Type { - public static final String TYPE_NAME = "BooleanTypeAnnotation"; - - public BooleanType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/CodegenException.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/CodegenException.java deleted file mode 100644 index 0b0ff3c8680e58..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/CodegenException.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public class CodegenException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public CodegenException(final String message) { - super(message); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/DoubleType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/DoubleType.java deleted file mode 100644 index ddfa0616334b4f..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/DoubleType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class DoubleType extends NumberType { - public static final String TYPE_NAME = "DoubleTypeAnnotation"; - - public DoubleType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FloatType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FloatType.java deleted file mode 100644 index 6698735501c5d6..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FloatType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class FloatType extends NumberType { - public static final String TYPE_NAME = "FloatTypeAnnotation"; - - public FloatType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FunctionType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FunctionType.java deleted file mode 100644 index d664d747534604..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/FunctionType.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public final class FunctionType extends Type { - public static final String TYPE_NAME = "FunctionTypeAnnotation"; - - public static class ArgumentType { - public final String name; - public final Type type; - - // Note: Function argument is not optional. - // TODO (T71926678): Revisit if optional should be supported. - private ArgumentType(String name, Type type) { - this.name = name; - this.type = type; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ArgumentType that = (ArgumentType) o; - return Objects.equals(this.name, that.name) && Objects.equals(this.type, that.type); - } - - @Override - public int hashCode() { - return Objects.hash(name, type); - } - - @Override - public String toString() { - return name + ": " + type; - } - } - - public static ArgumentType createArgument(String name, Type type) { - return new ArgumentType(name, type); - } - - public final List parameters; - public final Type returnType; - - public FunctionType( - final TypeId typeId, final List parameters, final Type returnType) { - super(typeId); - this.parameters = Collections.unmodifiableList(parameters); - this.returnType = returnType; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass() || !super.equals(o)) { - return false; - } - - final FunctionType that = (FunctionType) o; - return Objects.equals(this.parameters, that.parameters) - && Objects.equals(this.returnType, that.returnType); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), parameters, returnType); - } - - @Override - public String toString() { - return "(" + returnType + ")" + this.getTypeId() + "(" + parameters + ")"; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/GenericObjectType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/GenericObjectType.java deleted file mode 100644 index ce4a2b05eef877..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/GenericObjectType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class GenericObjectType extends Type { - public static final String TYPE_NAME = "GenericObjectTypeAnnotation"; - - public GenericObjectType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Int32Type.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Int32Type.java deleted file mode 100644 index 4639d392397a18..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Int32Type.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class Int32Type extends NumberType { - public static final String TYPE_NAME = "Int32TypeAnnotation"; - - public Int32Type(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NativeModuleType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NativeModuleType.java deleted file mode 100644 index 2f3a41034ff53f..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NativeModuleType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.Collections; -import java.util.List; - -public final class NativeModuleType extends Type { - public static String TYPE_NAME = ""; // Not an actual type in the schema. - - public final List aliases; - public final List properties; - - public static class Property { - public final String name; - public final FunctionType type; - public final boolean optional; - - public Property(final String name, final Type type, final boolean optional) { - assertType(type, FunctionType.class); - this.name = name; - this.type = (FunctionType) type; - this.optional = optional; - } - - @Override - public String toString() { - return name + ": " + (this.optional ? "?" : "") + type; - } - } - - public NativeModuleType( - final TypeId typeId, final List aliases, final List properties) { - super(typeId); - this.aliases = Collections.unmodifiableList(aliases); - this.properties = Collections.unmodifiableList(properties); - } - - @Override - public String toString() { - return getTypeId() + "\n aliases: " + aliases + "\n properties: " + properties; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NullableType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NullableType.java deleted file mode 100644 index 51809250d204da..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NullableType.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class NullableType extends Type { - public static final String TYPE_NAME = "NullableTypeAnnotation"; - - public final Type innerType; - - public NullableType(final TypeId typeId, final Type innerType) { - super(typeId); - this.innerType = innerType; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NumberType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NumberType.java deleted file mode 100644 index 382e06846d6ab5..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/NumberType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public abstract class NumberType extends Type { - public static final String TYPE_NAME = "NumberTypeAnnotation"; - - public NumberType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ObjectType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ObjectType.java deleted file mode 100644 index 3c1fcabd512aff..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ObjectType.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.Collections; -import java.util.List; - -public final class ObjectType extends Type { - public static final String TYPE_NAME = "ObjectTypeAnnotation"; - - public static class Property { - public final String name; - public final Type type; - public final boolean optional; - - public Property(String name, Type type, boolean optional) { - this.name = name; - this.type = type; - this.optional = optional; - } - - @Override - public String toString() { - return (optional ? "?" : "") + name + ": " + type; - } - } - - public final List properties; - - public ObjectType(final TypeId typeId, final List properties) { - super(typeId); - this.properties = Collections.unmodifiableList(properties); - } - - @Override - public String toString() { - return getTypeId() + " -> " + properties; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/PromiseType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/PromiseType.java deleted file mode 100644 index c243cae7d73a1e..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/PromiseType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class PromiseType extends Type { - public static final String TYPE_NAME = "PromiseTypeAnnotation"; - - public PromiseType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ReservedFunctionValueType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ReservedFunctionValueType.java deleted file mode 100644 index c1f755ed118f82..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/ReservedFunctionValueType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class ReservedFunctionValueType extends Type { - public static final String TYPE_NAME = "ReservedFunctionValueTypeAnnotation"; - - public enum ReservedName { - RootTag, - } - - public ReservedName reservedName; - - public ReservedFunctionValueType(final TypeId typeId, ReservedName reservedName) { - super(typeId); - this.reservedName = reservedName; - } - - @Override - public String toString() { - return mTypeId + "(" + reservedName.toString() + ")"; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/StringType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/StringType.java deleted file mode 100644 index 39ba374a0fc81a..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/StringType.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class StringType extends Type { - public static final String TYPE_NAME = "StringTypeAnnotation"; - - public StringType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Type.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Type.java deleted file mode 100644 index b6151d20ed9bda..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/Type.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.Objects; - -public abstract class Type { - public static String TYPE_NAME = ""; - - protected final TypeId mTypeId; - - public static void assertType( - final Type type, final Class expectedTypeClass) { - if (!expectedTypeClass.isInstance(type)) { - throw new IllegalStateException( - "Expected: " + expectedTypeClass.getName() + " but found: " + type.getClass().getName()); - } - } - - public Type(final TypeId typeId) { - mTypeId = typeId; - } - - public TypeId getTypeId() { - return mTypeId; - } - - @Override - public String toString() { - return mTypeId.toString(); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final Type type = (Type) o; - return Objects.equals(mTypeId, type.mTypeId); - } - - @Override - public int hashCode() { - return Objects.hash(mTypeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeData.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeData.java deleted file mode 100644 index 91a58f51062f71..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeData.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import javax.annotation.Nullable; - -/** A collection of all types information based on the parsed schema. */ -public final class TypeData { - private final Map mTypes = new HashMap<>(); - - public void addType(final TypeId typeId, final Type type) throws IllegalStateException { - if (getType(typeId) != null) { - throw new IllegalStateException("Found duplicated TypeId: " + typeId + " for: " + type); - } - mTypes.put(typeId, type); - } - - public void addType(final Type type) { - addType(type.getTypeId(), type); - } - - public @Nullable Type getType(final TypeId typeId) { - return mTypes.get(typeId); - } - - public Set getAllTypes() { - return mTypes.keySet(); - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - mTypes.forEach( - (k, v) -> { - builder.append(v.toString()); - builder.append("\n"); - }); - return builder.toString(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeId.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeId.java deleted file mode 100644 index ef9831c5256281..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/TypeId.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -import java.util.Objects; -import javax.annotation.Nullable; - -/** Represents the fully qualified name for a Flow type. */ -public final class TypeId { - public final String moduleName; - public final String typeName; - - private static final String EMPTY_TYPE_NAME = ""; - - private TypeId(final String moduleName, final String typeName) { - this.moduleName = moduleName; - this.typeName = typeName; - } - - public static TypeId of(final String moduleName) { - return new TypeId(moduleName, EMPTY_TYPE_NAME); - } - - public static TypeId of(final String moduleName, @Nullable final String typeName) { - if (typeName == null) { - return TypeId.of(moduleName); - } - - if (moduleName.equals(typeName)) { - return TypeId.of(moduleName); - } - - return new TypeId(moduleName, typeName); - } - - public static TypeId of(final TypeId typeId) { - return of(typeId.moduleName, typeId.typeName); - } - - public static TypeId expandOf(final TypeId typeId, String suffix) { - return of(typeId.moduleName, typeId.typeName + suffix); - } - - @Override - public String toString() { - return String.format( - "", - moduleName, EMPTY_TYPE_NAME.equals(typeName) ? "\"\"" : typeName); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final TypeId typeId = (TypeId) o; - return Objects.equals(moduleName, typeId.moduleName) - && Objects.equals(typeName, typeId.typeName); - } - - @Override - public int hashCode() { - return Objects.hash(moduleName, typeName); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/VoidType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/VoidType.java deleted file mode 100644 index 29ea494d7f2ff2..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/model/VoidType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.model; - -public final class VoidType extends Type { - public static final String TYPE_NAME = "VoidTypeAnnotation"; - public static final VoidType VOID = new VoidType(TypeId.of("")); - - private VoidType(final TypeId typeId) { - super(typeId); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AliasResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AliasResolvedType.java deleted file mode 100644 index 6720ef76e38efc..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AliasResolvedType.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.AliasType; -import com.facebook.react.codegen.generator.model.AnyType; -import com.facebook.react.codegen.generator.model.Type; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import javax.annotation.Nullable; - -public final class AliasResolvedType extends ResolvedType { - - private AliasResolvedType(final AliasType type, final boolean nullable) { - super(type, nullable); - throw new UnsupportedOperationException(); - } - - public static ResolvedType create( - final AliasType type, final TypeData typeData, final boolean nullable) { - Type referredType = typeData.getType(type.referredTypeId); - if (referredType != null) { - return resolveType(referredType, typeData, nullable); - } - return resolveType(new AnyType(type.getTypeId()), typeData, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - throw new UnsupportedOperationException(); - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - throw new UnsupportedOperationException(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/Annotations.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/Annotations.java deleted file mode 100644 index 4025b545ef75bf..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/Annotations.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.squareup.javapoet.AnnotationSpec; -import javax.annotation.Nullable; - -public class Annotations { - public static final AnnotationSpec OVERRIDE = AnnotationSpec.builder(Override.class).build(); - public static final AnnotationSpec NULLABLE = AnnotationSpec.builder(Nullable.class).build(); -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AnyResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AnyResolvedType.java deleted file mode 100644 index e9fc8dc335b5f4..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/AnyResolvedType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.AnyType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class AnyResolvedType extends ResolvedType { - - private AnyResolvedType(final AnyType type, final boolean nullable) { - super(type, nullable); - } - - public static AnyResolvedType create( - final AnyType type, final TypeData typeData, final boolean nullable) { - return new AnyResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - switch (typeContext) { - case FUNCTION_ARGUMENT: - return TypeUtils.makeNullable(ReactClassNames.REACT_READABLE_MAP, mNullable); - case FUNCTION_RETURN: - return TypeUtils.makeNullable(ReactClassNames.REACT_WRITABLE_MAP, mNullable); - default: - return TypeUtils.makeNullable(TypeName.OBJECT, mNullable); - } - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ArrayResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ArrayResolvedType.java deleted file mode 100644 index b6a7d3b7854c43..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ArrayResolvedType.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.ArrayType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.ArrayTypeName; -import com.squareup.javapoet.TypeName; - -public final class ArrayResolvedType extends ResolvedType { - - private final ResolvedType mElementResolvedType; - - private ArrayResolvedType(final ArrayType type, final TypeData typeData, final boolean nullable) { - super(type, nullable); - mElementResolvedType = resolveType(mType.elementType, typeData, nullable); - } - - public static ArrayResolvedType create( - final ArrayType type, final TypeData typeData, final boolean nullable) { - return new ArrayResolvedType(type, typeData, nullable); - } - - public ResolvedType getElementResolvedType() { - return mElementResolvedType; - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - switch (typeContext) { - case FUNCTION_ARGUMENT: - return TypeUtils.makeNullable(ReactClassNames.REACT_READABLE_ARRAY, mNullable); - case FUNCTION_RETURN: - return TypeUtils.makeNullable(ReactClassNames.REACT_WRITABLE_ARRAY, mNullable); - default: - return TypeUtils.makeNullable( - ArrayTypeName.of(mElementResolvedType.getNativeType(typeContext)), mNullable); - } - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/BooleanResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/BooleanResolvedType.java deleted file mode 100644 index 75ac0a77ce5f8b..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/BooleanResolvedType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.BooleanType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class BooleanResolvedType extends ResolvedType { - - private BooleanResolvedType(final BooleanType type, final boolean nullable) { - super(type, nullable); - } - - public static BooleanResolvedType create( - final BooleanType type, final TypeData typeData, final boolean nullable) { - return new BooleanResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - return TypeUtils.makeNullable(TypeName.BOOLEAN, mNullable); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ClassNames.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ClassNames.java deleted file mode 100644 index 5a76753ed2bf22..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ClassNames.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import java.util.Map; - -/** Names of Java classes required by generated code. */ -public class ClassNames { - - // Java standard classes - public static final TypeName STRING = ClassName.get(String.class); - - public static final ParameterizedTypeName CONSTANTS_MAP = - ParameterizedTypeName.get(ClassName.get(Map.class), ClassNames.STRING, ClassName.OBJECT); -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java deleted file mode 100644 index 7896494eebb2f4..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/FunctionResolvedType.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.FunctionType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.AnnotationSpec; -import com.squareup.javapoet.CodeBlock; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.ParameterSpec; -import com.squareup.javapoet.TypeName; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import javax.lang.model.element.Modifier; - -public final class FunctionResolvedType extends ResolvedType { - private final Map mResolvedArgTypes; - private final ResolvedType mResolvedReturnType; - - private FunctionResolvedType( - final FunctionType type, final TypeData typeData, final boolean nullable) { - super(type, nullable); - mResolvedReturnType = resolveType(type.returnType, typeData, nullable); - mResolvedArgTypes = - Collections.unmodifiableMap( - type.parameters.stream() - .collect( - Collectors.toMap( - item -> item.name, item -> resolveType(item.type, typeData, false)))); - } - - public static FunctionResolvedType create( - final FunctionType type, final TypeData typeData, final boolean nullable) { - return new FunctionResolvedType(type, typeData, nullable); - } - - public ResolvedType getResolvedReturnType() { - return mResolvedReturnType; - } - - public Map getResolvedArgTypes() { - return mResolvedArgTypes; - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - return TypeUtils.makeNullable(ReactClassNames.REACT_CALLBACK, mNullable); - } - - public MethodSpec getGeneratedMethodWithReactAnnotation(String methodName) { - TypeName resolvedReturnTypeName = - mResolvedReturnType.getNativeType(NativeTypeContext.FUNCTION_RETURN); - - boolean isReturnTypePromise = resolvedReturnTypeName == ReactClassNames.REACT_PROMISE; - TypeName returnTypeName = isReturnTypePromise ? TypeName.VOID : resolvedReturnTypeName; - - MethodSpec.Builder methodBuilder = - MethodSpec.methodBuilder(methodName).addModifiers(Modifier.PUBLIC); - methodBuilder.returns(returnTypeName); - - if (!mNullable) { - methodBuilder.addModifiers(Modifier.ABSTRACT); - } else { - String returnStatement = getFalsyReturnStatement(returnTypeName); - if (returnStatement != null) { - CodeBlock.Builder methodBody = CodeBlock.builder(); - methodBody.addStatement(returnStatement); - methodBuilder.addCode(methodBody.build()); - } - } - - mResolvedArgTypes - .entrySet() - .forEach( - e -> { - String argName = e.getKey(); - ResolvedType argResolvedType = e.getValue(); - methodBuilder.addParameter( - ParameterSpec.builder( - argResolvedType.getNativeType(NativeTypeContext.FUNCTION_ARGUMENT), - argName) - .build()); - }); - - AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(ReactClassNames.REACT_METHOD); - - // Special case: Promise inserts additional method arg at the end. - if (isReturnTypePromise) { - methodBuilder.addParameter( - ParameterSpec.builder(ReactClassNames.REACT_PROMISE, "promise").build()); - } else if (!TypeName.VOID.equals(returnTypeName)) { - // A non-promise non-void return type means the method is synchronous. - annotationBuilder.addMember("isBlockingSynchronousMethod", "$L", true); - } - - // React methods need special `@ReactMethod` annotation for now. - methodBuilder.addAnnotation(annotationBuilder.build()); - - // TODO(T82242829) Add @DoNotStrip annotation - - return methodBuilder.build(); - } - - private static @Nullable String getFalsyReturnStatement(TypeName returnType) { - // TODO: Handle nullable falsy return. - if (returnType == TypeName.BOOLEAN) { - return "return false"; - } else if (returnType == TypeName.DOUBLE) { - return "return 0.0"; - } else if (returnType == ClassNames.STRING - || returnType == ReactClassNames.REACT_WRITABLE_ARRAY - || returnType == ReactClassNames.REACT_WRITABLE_MAP) { - return "return null"; - } - - return null; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/GenericObjectResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/GenericObjectResolvedType.java deleted file mode 100644 index 84b98eb9698e14..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/GenericObjectResolvedType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.GenericObjectType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class GenericObjectResolvedType extends ResolvedType { - - private GenericObjectResolvedType(final GenericObjectType type, final boolean nullable) { - super(type, nullable); - } - - public static GenericObjectResolvedType create( - final GenericObjectType type, final TypeData typeData, final boolean nullable) { - return new GenericObjectResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - switch (typeContext) { - case FUNCTION_ARGUMENT: - return TypeUtils.makeNullable(ReactClassNames.REACT_READABLE_MAP, mNullable); - case FUNCTION_RETURN: - return TypeUtils.makeNullable(ReactClassNames.REACT_WRITABLE_MAP, mNullable); - default: - break; - } - - throw new CodegenException( - "Unsupported GenericObjectType: " + mType + " - typeContext: " + typeContext); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NativeModuleResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NativeModuleResolvedType.java deleted file mode 100644 index 0022209dbf2004..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NativeModuleResolvedType.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.NativeModuleType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.CodeBlock; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.ParameterSpec; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import javax.lang.model.element.Modifier; - -public final class NativeModuleResolvedType extends ResolvedType { - private final Map mResolvedAliasTypes; - private final Map mResolvedPropertyTypes; - - private NativeModuleResolvedType( - final NativeModuleType type, final TypeData typeData, final boolean nullable) { - super(type, nullable); - mResolvedAliasTypes = - Collections.unmodifiableMap( - type.aliases.stream() - .collect( - Collectors.toMap( - item -> item.getTypeId().typeName, - item -> resolveType(item, typeData, false)))); - mResolvedPropertyTypes = - Collections.unmodifiableMap( - type.properties.stream() - .collect( - Collectors.toMap( - item -> item.name, - // TODO: Optional Object property is not necessarily nullable. - item -> { - final ResolvedType resolvedType = - resolveType(item.type, typeData, item.optional); - TypeUtils.assertCondition( - resolvedType instanceof FunctionResolvedType, - "NativeModules can only contain methods. Constants like '" - + item.name - + "' must be declared in the return type of the 'getConstants()' method."); - return (FunctionResolvedType) resolvedType; - }))); - } - - public static NativeModuleResolvedType create( - final NativeModuleType type, final TypeData typeData, final boolean nullable) { - return new NativeModuleResolvedType(type, typeData, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - throw new UnsupportedOperationException( - "NativeModuleType cannot be referred to by other types."); - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - final TypeSpec.Builder classBuilder = - TypeSpec.classBuilder(mType.getTypeId().typeName) - .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT) - .superclass(ReactClassNames.REACT_CONTEXT_BASE_JAVA_MODULE) - .addSuperinterface(ReactClassNames.REACT_MODULE_WITH_SPEC) - .addSuperinterface(ReactClassNames.REACT_TURBOMODULE); - - final MethodSpec.Builder constructorBuilder = - MethodSpec.constructorBuilder() - .addModifiers(Modifier.PUBLIC) - .addParameter( - ParameterSpec.builder(ReactClassNames.REACT_APPLICATION_CONTEXT, "reactContext") - .build()) - .addStatement("super($N)", "reactContext"); - classBuilder.addMethod(constructorBuilder.build()); - - mResolvedPropertyTypes.forEach( - (name, resolvedType) -> { - if (name.equals("getConstants")) { - classBuilder.addMethod(generateGetTypedExportedConstantsMethod()); - classBuilder.addMethod(generateGetConstantsMethod(resolvedType)); - } else { - classBuilder.addMethod( - ((FunctionResolvedType) resolvedType).getGeneratedMethodWithReactAnnotation(name)); - } - }); - - return classBuilder.build(); - } - - // For now, getConstants() needs a runtime check to ensure the object return value has the - // required properties. In the future, the method should return the specific object type that - // can be verified during build time. - private static MethodSpec generateGetConstantsMethod(final FunctionResolvedType resolvedType) { - final ResolvedType resolvedReturnType = resolvedType.getResolvedReturnType(); - TypeUtils.assertCondition( - resolvedReturnType instanceof ObjectResolvedType, - "getConstants() method must return an exact object. Found: " + resolvedType.mType); - - final ParameterizedTypeName returnType = - ParameterizedTypeName.get(ClassName.get(Map.class), ClassNames.STRING, ClassName.OBJECT); - return MethodSpec.methodBuilder("getConstants") - .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addAnnotation(Annotations.OVERRIDE) - .returns(returnType.annotated(Annotations.NULLABLE)) - .addCode( - getConstantsMethodBody( - returnType, ((ObjectResolvedType) resolvedReturnType).getResolvedPropertyTypes())) - .build(); - } - - private static MethodSpec generateGetTypedExportedConstantsMethod() { - return MethodSpec.methodBuilder("getTypedExportedConstants") - .addModifiers(Modifier.PROTECTED, Modifier.ABSTRACT) - .returns(ClassNames.CONSTANTS_MAP) - .build(); - } - - private static CodeBlock getConstantsMethodBody( - final ParameterizedTypeName returnType, final Map constantsTypes) { - final CodeBlock.Builder methodBody = CodeBlock.builder(); - - final Map>> constantsByNullability = - constantsTypes.entrySet().stream() - .collect(Collectors.partitioningBy(entry -> entry.getValue().mNullable)); - - final String constantsVariableName = "constants"; - final String obligatoryFlowConstantsVariableName = "obligatoryFlowConstants"; - final String optionalFlowConstantsVariableName = "optionalFlowConstants"; - final TypeName setOfStringsType = - ParameterizedTypeName.get(ClassName.get(Set.class), ClassNames.STRING); - final TypeName hashsetType = ClassName.get(HashSet.class); - - methodBody.addStatement( - "$T $N = $N()", - returnType, - constantsVariableName, - generateGetTypedExportedConstantsMethod().name); - - // Enable all of this for internal (debug) builds only. - methodBody.beginControlFlow( - "if ($1T.DEBUG || $1T.IS_INTERNAL_BUILD)", ReactClassNames.REACT_BUILD_CONFIG); - { - final List obligatoryConstants = - constantsByNullability.get(false).stream() - .map(Map.Entry::getKey) - .sorted() - .collect(Collectors.toList()); - addVariableDeclaration( - methodBody, - obligatoryFlowConstantsVariableName, - obligatoryConstants, - setOfStringsType, - hashsetType); - - final List optionalConstants = - constantsByNullability.get(true).stream() - .map(Map.Entry::getKey) - .sorted() - .collect(Collectors.toList()); - addVariableDeclaration( - methodBody, - optionalFlowConstantsVariableName, - optionalConstants, - setOfStringsType, - hashsetType); - - final String undeclaredConstantsVariableName = "undeclaredConstants"; - - methodBody - .addStatement( - "$T $N = new $T<>($N.keySet())", - setOfStringsType, - undeclaredConstantsVariableName, - hashsetType, - constantsVariableName) - .addStatement( - "$N.removeAll($N)", - undeclaredConstantsVariableName, - obligatoryFlowConstantsVariableName) - .addStatement( - "$N.removeAll($N)", - undeclaredConstantsVariableName, - optionalFlowConstantsVariableName); - methodBody.add( - checkForConstantsFulfillmentBlock( - undeclaredConstantsVariableName, - "Native Module Flow doesn\'t declare constants: %s")); - - methodBody - .addStatement( - "$N = $N", undeclaredConstantsVariableName, obligatoryFlowConstantsVariableName) - .addStatement( - "$N.removeAll($N.keySet())", undeclaredConstantsVariableName, constantsVariableName); - methodBody.add( - checkForConstantsFulfillmentBlock( - undeclaredConstantsVariableName, "Native Module doesn\'t fill in constants: %s")); - } - methodBody.endControlFlow(); - methodBody.addStatement("return $N", constantsVariableName); - - return methodBody.build(); - } - - private static void addVariableDeclaration( - final CodeBlock.Builder builder, - final String variableName, - final List values, - final TypeName varType, - final TypeName actualType) { - if (values.isEmpty()) { - builder.addStatement("$T $N = new $T<>()", varType, variableName, actualType); - } else { - builder.add( - "$T $N = new $T<>($T.asList(\n", - varType, - variableName, - actualType, - ClassName.get(Arrays.class)); - builder.indent().indent(); - - int constantsToAdd = values.size(); - for (final String constantName : values) { - builder.add("\"$L\"", constantName); - if (--constantsToAdd > 0) { - builder.add(","); - } - builder.add("\n"); - } - - builder.unindent().unindent(); - builder.addStatement("))"); - } - } - - private static CodeBlock checkForConstantsFulfillmentBlock( - final String undeclaredConstantsVariableName, final String formatString) { - return CodeBlock.builder() - .beginControlFlow("if (!$N.isEmpty())", undeclaredConstantsVariableName) - .addStatement( - "throw new IllegalStateException(String.format(\"" + formatString + "\", $N))", - undeclaredConstantsVariableName) - .endControlFlow() - .build(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NullableResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NullableResolvedType.java deleted file mode 100644 index b5dd2fee1ea7d3..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NullableResolvedType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.NullableType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import javax.annotation.Nullable; - -public final class NullableResolvedType extends ResolvedType { - - private NullableResolvedType(final NullableType type, final boolean nullable) { - super(type, nullable); - throw new UnsupportedOperationException(); - } - - public static ResolvedType create( - final NullableType type, final TypeData typeData, final boolean nullable) { - return resolveType(type.innerType, typeData, true); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - throw new UnsupportedOperationException(); - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - throw new UnsupportedOperationException(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NumberResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NumberResolvedType.java deleted file mode 100644 index 6a9576efe7cabb..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/NumberResolvedType.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.DoubleType; -import com.facebook.react.codegen.generator.model.FloatType; -import com.facebook.react.codegen.generator.model.Int32Type; -import com.facebook.react.codegen.generator.model.NumberType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class NumberResolvedType extends ResolvedType { - - private NumberResolvedType(final NumberType type, final boolean nullable) { - super(type, nullable); - } - - public static NumberResolvedType create( - final NumberType type, final TypeData typeData, final boolean nullable) { - return new NumberResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - if (mType instanceof Int32Type) { - return TypeUtils.makeNullable(TypeName.INT, mNullable); - } - if (mType instanceof FloatType) { - return TypeUtils.makeNullable(TypeName.FLOAT, mNullable); - } - if (mType instanceof DoubleType) { - return TypeUtils.makeNullable(TypeName.DOUBLE, mNullable); - } - throw new CodegenException("Unsupported NumberType: " + mType.getClass()); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ObjectResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ObjectResolvedType.java deleted file mode 100644 index 54a9cb09eeec28..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ObjectResolvedType.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.ObjectType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; -import javax.annotation.Nullable; - -public final class ObjectResolvedType extends ResolvedType { - private final Map mResolvedPropertyTypes; - - private ObjectResolvedType( - final ObjectType type, final TypeData typeData, final boolean nullable) { - super(type, nullable); - mResolvedPropertyTypes = - Collections.unmodifiableMap( - type.properties.stream() - .collect( - Collectors.toMap( - item -> item.name, - // TODO: Optional Object property is not necessarily nullable. - item -> resolveType(item.type, typeData, item.optional)))); - } - - public static ObjectResolvedType create( - final ObjectType type, final TypeData typeData, final boolean nullable) { - return new ObjectResolvedType(type, typeData, nullable); - } - - public Map getResolvedPropertyTypes() { - return mResolvedPropertyTypes; - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - // TODO: It should return its own class type. - // However, the NativeModule system only supports built-in ReadableMap/WritableMap for now. - switch (typeContext) { - case FUNCTION_ARGUMENT: - return TypeUtils.makeNullable(ReactClassNames.REACT_READABLE_MAP, mNullable); - case FUNCTION_RETURN: - return TypeUtils.makeNullable(ReactClassNames.REACT_WRITABLE_MAP, mNullable); - default: - break; - } - - throw new CodegenException( - "Unsupported ObjectType: " + mType + " - typeContext: " + typeContext); - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - // TODO: Object type should produce is own class to represent its shape. - // However, the NativeModule system only supports built-in ReadableMap/WritableMap for now. - return null; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/PromiseResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/PromiseResolvedType.java deleted file mode 100644 index 0c575ff08a2646..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/PromiseResolvedType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.PromiseType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class PromiseResolvedType extends ResolvedType { - - private PromiseResolvedType(final PromiseType type, final boolean nullable) { - super(type, nullable); - } - - public static PromiseResolvedType create( - final PromiseType type, final TypeData typeData, final boolean nullable) { - return new PromiseResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - return TypeUtils.makeNullable(ReactClassNames.REACT_PROMISE, mNullable); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReactClassNames.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReactClassNames.java deleted file mode 100644 index 2fca4df5dfde38..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReactClassNames.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.squareup.javapoet.ClassName; - -/** Names of React-specific Java classes required by generated code. */ -public class ReactClassNames { - - public static final ClassName REACT_APPLICATION_CONTEXT = - ClassName.bestGuess("com.facebook.react.bridge.ReactApplicationContext"); - public static final ClassName REACT_CALLBACK = - ClassName.bestGuess("com.facebook.react.bridge.Callback"); - public static final ClassName REACT_CONTEXT_BASE_JAVA_MODULE = - ClassName.bestGuess("com.facebook.react.bridge.ReactContextBaseJavaModule"); - public static final ClassName REACT_METHOD = - ClassName.bestGuess("com.facebook.react.bridge.ReactMethod"); - public static final ClassName REACT_MODULE_WITH_SPEC = - ClassName.bestGuess("com.facebook.react.bridge.ReactModuleWithSpec"); - public static final ClassName REACT_PROMISE = - ClassName.bestGuess("com.facebook.react.bridge.Promise"); - public static final ClassName REACT_READABLE_ARRAY = - ClassName.bestGuess("com.facebook.react.bridge.ReadableArray"); - public static final ClassName REACT_READABLE_MAP = - ClassName.bestGuess("com.facebook.react.bridge.ReadableMap"); - public static final ClassName REACT_WRITABLE_ARRAY = - ClassName.bestGuess("com.facebook.react.bridge.WritableArray"); - public static final ClassName REACT_WRITABLE_MAP = - ClassName.bestGuess("com.facebook.react.bridge.WritableMap"); - public static final ClassName REACT_BUILD_CONFIG = - ClassName.bestGuess("com.facebook.react.common.build.ReactBuildConfig"); - public static final ClassName REACT_TURBOMODULE = - ClassName.bestGuess("com.facebook.react.turbomodule.core.interfaces.TurboModule"); -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReservedFunctionValueResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReservedFunctionValueResolvedType.java deleted file mode 100644 index 3cd677cc70e53c..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ReservedFunctionValueResolvedType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.facebook.react.codegen.generator.model.DoubleType; -import com.facebook.react.codegen.generator.model.ReservedFunctionValueType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import javax.annotation.Nullable; - -public final class ReservedFunctionValueResolvedType - extends ResolvedType { - - private ReservedFunctionValueResolvedType( - final ReservedFunctionValueType type, final boolean nullable) { - super(type, nullable); - throw new UnsupportedOperationException(); - } - - public static ResolvedType create( - final ReservedFunctionValueType type, final TypeData typeData, final boolean nullable) { - switch (type.reservedName) { - case RootTag: - return resolveType(new DoubleType(type.getTypeId()), typeData, nullable); - default: - break; - } - - throw new CodegenException("Unsupported ReservedFunctionValueType: " + type); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - throw new UnsupportedOperationException(); - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - throw new UnsupportedOperationException(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ResolvedType.java deleted file mode 100644 index e9373ed5f56cc0..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/ResolvedType.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.Type; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import javax.annotation.Nullable; - -public abstract class ResolvedType { - /** Contexts native types can appear in. */ - public enum NativeTypeContext { - FUNCTION_ARGUMENT, - FUNCTION_RETURN, - DEFAULT, - } - - protected final T mType; - protected final boolean mNullable; - - protected ResolvedType(final T type, final boolean nullable) { - mType = type; - mNullable = nullable; - } - - protected static ResolvedType resolveType( - final Type type, final TypeData typeData, final boolean nullable) { - return TypeResolver.resolveType(type, typeData, nullable); - } - - public T getType() { - return mType; - } - - public boolean isNullable() { - return mNullable; - } - - /** The Java type generated for this type */ - public abstract TypeName getNativeType(NativeTypeContext typeContext); - - /** Generate code for this type itself, if applicable. */ - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - return null; - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/StringResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/StringResolvedType.java deleted file mode 100644 index c24711171028c7..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/StringResolvedType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.StringType; -import com.facebook.react.codegen.generator.model.TypeData; -import com.squareup.javapoet.TypeName; - -public final class StringResolvedType extends ResolvedType { - - private StringResolvedType(final StringType type, final boolean nullable) { - super(type, nullable); - } - - public static StringResolvedType create( - final StringType type, final TypeData typeData, final boolean nullable) { - return new StringResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - return TypeUtils.makeNullable(ClassNames.STRING, mNullable); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeResolver.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeResolver.java deleted file mode 100644 index 6b9b533876e34e..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeResolver.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.AliasType; -import com.facebook.react.codegen.generator.model.AnyType; -import com.facebook.react.codegen.generator.model.ArrayType; -import com.facebook.react.codegen.generator.model.BooleanType; -import com.facebook.react.codegen.generator.model.FunctionType; -import com.facebook.react.codegen.generator.model.GenericObjectType; -import com.facebook.react.codegen.generator.model.NativeModuleType; -import com.facebook.react.codegen.generator.model.NullableType; -import com.facebook.react.codegen.generator.model.NumberType; -import com.facebook.react.codegen.generator.model.ObjectType; -import com.facebook.react.codegen.generator.model.PromiseType; -import com.facebook.react.codegen.generator.model.ReservedFunctionValueType; -import com.facebook.react.codegen.generator.model.StringType; -import com.facebook.react.codegen.generator.model.Type; -import com.facebook.react.codegen.generator.model.TypeData; -import com.facebook.react.codegen.generator.model.VoidType; - -public final class TypeResolver { - public static ResolvedType resolveType( - final Type type, final TypeData typeData, final boolean nullable) { - - if (type instanceof AliasType) { - return AliasResolvedType.create((AliasType) type, typeData, nullable); - } - - if (type instanceof AnyType) { - return AnyResolvedType.create((AnyType) type, typeData, nullable); - } - - if (type instanceof ArrayType) { - return ArrayResolvedType.create((ArrayType) type, typeData, nullable); - } - - if (type instanceof BooleanType) { - return BooleanResolvedType.create((BooleanType) type, typeData, nullable); - } - - if (type instanceof FunctionType) { - return FunctionResolvedType.create((FunctionType) type, typeData, nullable); - } - - if (type instanceof GenericObjectType) { - return GenericObjectResolvedType.create((GenericObjectType) type, typeData, nullable); - } - - if (type instanceof NativeModuleType) { - return NativeModuleResolvedType.create((NativeModuleType) type, typeData, nullable); - } - - if (type instanceof NullableType) { - return NullableResolvedType.create((NullableType) type, typeData, nullable); - } - - if (type instanceof NumberType) { - return NumberResolvedType.create((NumberType) type, typeData, nullable); - } - - if (type instanceof ObjectType) { - return ObjectResolvedType.create((ObjectType) type, typeData, nullable); - } - - if (type instanceof PromiseType) { - return PromiseResolvedType.create((PromiseType) type, typeData, nullable); - } - - if (type instanceof ReservedFunctionValueType) { - return ReservedFunctionValueResolvedType.create( - (ReservedFunctionValueType) type, typeData, nullable); - } - - if (type instanceof StringType) { - return StringResolvedType.create((StringType) type, typeData, nullable); - } - - if (type instanceof VoidType) { - return VoidResolvedType.create((VoidType) type, typeData, nullable); - } - - throw new IllegalArgumentException("Unable to resolve unsupported type: " + type.getClass()); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeUtils.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeUtils.java deleted file mode 100644 index b8742b6f89e959..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/TypeUtils.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.CodegenException; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeVariableName; - -public class TypeUtils { - - public static TypeName getNativeClassName(TypeName className) { - while (className instanceof ParameterizedTypeName) { - className = ((ParameterizedTypeName) className).rawType; - } - - return (className instanceof TypeVariableName) ? TypeName.OBJECT : className.box(); - } - - public static TypeName makeNullable(final TypeName typeName, final boolean isNullable) { - if (isNullable) { - if (typeName.isPrimitive()) { - return typeName.box(); - } - if (!typeName.annotations.contains(Annotations.NULLABLE)) { - return typeName.annotated(Annotations.NULLABLE); - } - } - return typeName; - } - - public static void assertCondition(final boolean condition, final String errorMessage) - throws CodegenException { - if (!condition) { - throw new CodegenException(errorMessage); - } - } -} diff --git a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/VoidResolvedType.java b/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/VoidResolvedType.java deleted file mode 100644 index 0665ddf548a0ea..00000000000000 --- a/packages/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/resolver/VoidResolvedType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.codegen.generator.resolver; - -import com.facebook.react.codegen.generator.model.TypeData; -import com.facebook.react.codegen.generator.model.VoidType; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import javax.annotation.Nullable; - -public final class VoidResolvedType extends ResolvedType { - - private VoidResolvedType(final VoidType type, final boolean nullable) { - super(type, nullable); - } - - public static VoidResolvedType create( - final VoidType type, final TypeData typeData, final boolean nullable) { - return new VoidResolvedType(type, nullable); - } - - @Override - public TypeName getNativeType(final NativeTypeContext typeContext) { - return TypeName.VOID; - } - - @Override - public @Nullable TypeSpec getGeneratedCode(final String packageName) { - throw new UnsupportedOperationException(); - } -} diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/AndroidConfiguration.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/AndroidConfiguration.kt index 5babb8d50aa693..48fe2cccea4e12 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/AndroidConfiguration.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/AndroidConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index 51aa17a449304f..44f0e6b9933f81 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -29,13 +29,13 @@ abstract class ReactExtension @Inject constructor(project: Project) { val applyAppPlugin: Property = objects.property(Boolean::class.java).convention(false) /** - * The path to the react root folder. This is the path to the root folder where the `node_modules` - * folder is present. All the CLI commands will be invoked from this folder as working directory. + * The path to the root of your project. This is the path to where the `package.json` lives. All + * the CLI commands will be invoked from this folder as working directory. * - * Default: $projectDir/../../ + * Default: ${rootProject.dir}/../ */ - val reactRoot: DirectoryProperty = - objects.directoryProperty().convention(project.layout.projectDirectory.dir("../../")) + val root: DirectoryProperty = + objects.directoryProperty().convention(project.rootProject.layout.projectDirectory.dir("../")) /** * The path to the JS entry file. If not specified, the plugin will try to resolve it using a list @@ -45,7 +45,7 @@ abstract class ReactExtension @Inject constructor(project: Project) { /** * The path to the React Native CLI. If not specified, the plugin will try to resolve it looking - * for `react-native` CLI inside `node_modules` in [reactRoot]. + * for `react-native` CLI inside `node_modules` in [root]. */ val cliPath: Property = objects.property(String::class.java) @@ -56,9 +56,7 @@ abstract class ReactExtension @Inject constructor(project: Project) { val nodeExecutableAndArgs: ListProperty = objects.listProperty(String::class.java).convention(listOf("node")) - /** - * The command to use to invoke bundle. Default is `bundle` and will be invoked on [reactRoot]. - */ + /** The command to use to invoke bundle. Default is `bundle` and will be invoked on [root]. */ val bundleCommand: Property = objects.property(String::class.java).convention("bundle") /** @@ -143,9 +141,11 @@ abstract class ReactExtension @Inject constructor(project: Project) { /** Hermes Config */ - /** The command to use to invoke hermes. Default is `hermesc` for the correct OS. */ - val hermesCommand: Property = - objects.property(String::class.java).convention("node_modules/hermes-engine/%OS-BIN%/hermesc") + /** + * The command to use to invoke hermesc (the hermes compiler). Default is "", the plugin will + * autodetect it. + */ + val hermesCommand: Property = objects.property(String::class.java).convention("") /** Toggle Hermes for the whole build. Default: false */ val enableHermes: Property = objects.property(Boolean::class.java).convention(false) @@ -190,19 +190,27 @@ abstract class ReactExtension @Inject constructor(project: Project) { /** Codegen Config */ /** - * The path to the react-native-codegen folder. + * The path to the react-native-codegen NPM package folder. * - * Default: $projectDir/../../node_modules/react-native-codegen + * Default: ${rootProject.dir}/../node_modules/react-native-codegen */ val codegenDir: DirectoryProperty = - objects.directoryProperty().convention(reactRoot.dir("node_modules/react-native-codegen")) + objects.directoryProperty().convention(root.dir("node_modules/react-native-codegen")) + + /** + * The path to the react-native NPM package folder. + * + * Default: ${rootProject.dir}/../node_modules/react-native-codegen + */ + val reactNativeDir: DirectoryProperty = + objects.directoryProperty().convention(root.dir("node_modules/react-native")) /** * The root directory for all JS files for the app. * - * Default: $projectDir/../../ + * Default: [root] (i.e. ${rootProject.dir}/../) */ - val jsRootDir: DirectoryProperty = objects.directoryProperty().convention(reactRoot.get()) + val jsRootDir: DirectoryProperty = objects.directoryProperty().convention(root.get()) /** * The library name that will be used for the codegen artifacts. @@ -220,6 +228,38 @@ abstract class ReactExtension @Inject constructor(project: Project) { val codegenJavaPackageName: Property = objects.property(String::class.java).convention("com.facebook.fbreact.specs") - /** Whether the Java Generator (based on Javapoet) should be used or not. Default: false */ + /** + * Whether the Java Generator (based on Javapoet) should be used or not. Please note that this is + * currently deprecated as the Java generator is not supported anymore. Default: false + */ + @Deprecated( + level = DeprecationLevel.ERROR, + message = + "Please note that this is deprecated as the Java generator is not supported and react-native-codegen should be used instead.") val useJavaGenerator: Property = objects.property(Boolean::class.java).convention(false) + + /** + * The `reactRoot` property was confusing and should not be used. + * + * You should instead use either: + * - [root] to point to your root project (where the package.json lives) + * - [reactNativeDir] to point to the NPM package of react native. + * + * A valid configuration would look like: + * + * ``` + * react { + * root = rootProject.file("..") + * reactNativeDir = rootProject.file("../node_modules/react-native") + * } + * ``` + * + * Please also note that those are the default value and you most likely don't need those at all. + */ + @Deprecated( + "reactRoot was confusing and has been replace with root " + + "to point to your root project and reactNativeDir to point to " + + "the folder of the react-native NPM package", + replaceWith = ReplaceWith("reactNativeRoot")) + val reactRoot: DirectoryProperty = objects.directoryProperty() } diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index ce9743eb3981e8..22628fa94e893e 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,18 +14,40 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn import com.facebook.react.tasks.BuildCodegenCLITask import com.facebook.react.tasks.GenerateCodegenArtifactsTask import com.facebook.react.tasks.GenerateCodegenSchemaTask +import com.facebook.react.utils.JsonUtils import java.io.File +import kotlin.system.exitProcess import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.internal.jvm.Jvm class ReactPlugin : Plugin { override fun apply(project: Project) { + checkJvmVersion(project) val extension = project.extensions.create("react", ReactExtension::class.java, project) applyAppPlugin(project, extension) applyCodegenPlugin(project, extension) } + private fun checkJvmVersion(project: Project) { + val jvmVersion = Jvm.current()?.javaVersion?.majorVersion + if ((jvmVersion?.toIntOrNull() ?: 0) <= 8) { + project.logger.error( + """ + + ******************************************************************************** + + ERROR: requires JDK11 or higher. + Incompatible major version detected: '$jvmVersion' + + ******************************************************************************** + + """.trimIndent()) + exitProcess(1) + } + } + private fun applyAppPlugin(project: Project, config: ReactExtension) { project.afterEvaluate { if (config.applyAppPlugin.getOrElse(false)) { @@ -46,10 +68,10 @@ class ReactPlugin : Plugin { /** * A plugin to enable react-native-codegen in Gradle environment. See the Gradle API docs for more - * information: https://docs.gradle.org/6.5.1/javadoc/org/gradle/api/Project.html + * information: https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html */ private fun applyCodegenPlugin(project: Project, extension: ReactExtension) { - // 1. Set up build dir. + // First, we set up the output dir for the codegen. val generatedSrcDir = File(project.buildDir, "generated/source/codegen") val buildCodegenTask = @@ -59,32 +81,48 @@ class ReactPlugin : Plugin { it.bashWindowsHome.set(bashWindowsHome) } - // 2. Task: produce schema from JS files. + // We create the task to produce schema from JS files. val generateCodegenSchemaTask = project.tasks.register( - "generateCodegenSchemaFromJavaScript", GenerateCodegenSchemaTask::class.java) { + "generateCodegenSchemaFromJavaScript", GenerateCodegenSchemaTask::class.java) { it -> it.dependsOn(buildCodegenTask) - it.jsRootDir.set(extension.jsRootDir) it.nodeExecutableAndArgs.set(extension.nodeExecutableAndArgs) it.codegenDir.set(extension.codegenDir) it.generatedSrcDir.set(generatedSrcDir) + + // We're reading the package.json at configuration time to properly feed + // the `jsRootDir` @Input property of this task. Therefore, the + // parsePackageJson should be invoked here. + val parsedPackageJson = + extension.root.file("package.json").orNull?.asFile?.let { + JsonUtils.fromCodegenJson(it) + } + + val parsedJsRootDir = + parsedPackageJson?.codegenConfig?.jsSrcsDir?.let { relativePath -> + extension.root.dir(relativePath) + } + ?: extension.jsRootDir + + it.jsRootDir.set(parsedJsRootDir) } - // 3. Task: generate Java code from schema. + // We create the task to generate Java code from schema. val generateCodegenArtifactsTask = project.tasks.register( "generateCodegenArtifactsFromSchema", GenerateCodegenArtifactsTask::class.java) { it.dependsOn(generateCodegenSchemaTask) - it.reactRoot.set(extension.reactRoot) + it.reactNativeDir.set(extension.reactNativeDir) + it.deprecatedReactRoot.set(extension.reactRoot) it.nodeExecutableAndArgs.set(extension.nodeExecutableAndArgs) it.codegenDir.set(extension.codegenDir) - it.useJavaGenerator.set(extension.useJavaGenerator) + it.generatedSrcDir.set(generatedSrcDir) + it.packageJsonFile.set(extension.root.file("package.json")) it.codegenJavaPackageName.set(extension.codegenJavaPackageName) it.libraryName.set(extension.libraryName) - it.generatedSrcDir.set(generatedSrcDir) } - // 4. Add dependencies & generated sources to the project. + // We add dependencies & generated sources to the project. // Note: This last step needs to happen after the project has been evaluated. project.afterEvaluate { diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt index 20ca0336249542..60e7e60b0a65d3 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,9 +15,7 @@ import com.facebook.react.tasks.BundleJsAndAssetsTask import com.facebook.react.tasks.HermesBinaryTask import com.facebook.react.utils.detectedCliPath import com.facebook.react.utils.detectedEntryFile -import com.facebook.react.utils.detectedHermesCommand import java.io.File -import java.util.* import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.Copy @@ -27,7 +25,7 @@ private const val REACT_GROUP = "react" @Suppress("SpreadOperator") internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExtension) { - val targetName = variant.name.capitalize(Locale.ROOT) + val targetName = variant.name.replaceFirstChar { it.uppercase() } val targetPath = variant.dirName // React js bundle directories @@ -56,11 +54,9 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte it.group = REACT_GROUP it.description = "create JS bundle and assets for $targetName." - it.reactRoot = config.reactRoot.get().asFile + it.reactRoot = config.root.get().asFile it.sources = - fileTree(config.reactRoot) { fileTree -> - fileTree.setExcludes(config.inputExcludes.get()) - } + fileTree(config.root) { fileTree -> fileTree.setExcludes(config.inputExcludes.get()) } it.execCommand = execCommand it.bundleCommand = config.bundleCommand.get() it.devEnabled = !config.disableDevForVariant(variant) @@ -98,8 +94,8 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte it.group = REACT_GROUP it.description = "bundle hermes resources for $targetName" - it.reactRoot = config.reactRoot.get().asFile - it.hermesCommand = detectedHermesCommand(config) + it.root = config.root.get().asFile + it.hermesCommand = config.hermesCommand.get() it.hermesFlags = config.hermesFlagsForVariant(variant) it.jsBundleFile = jsBundleFile it.composeSourceMapsCommand = nodeExecutableAndArgs + config.composeSourceMapsPath.get() @@ -129,7 +125,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte // Android configuration variant.registerGeneratedResFolders(generatedResFolders) - val packageTask = + val packageTask: TaskProvider? = when (variant) { is ApplicationVariant -> variant.packageApplicationProvider is LibraryVariant -> variant.packageLibraryProvider @@ -157,11 +153,11 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte it.enabled = bundleEnabled } - packageTask.dependsOn(currentCopyResTask) + packageTask?.dependsOn(currentCopyResTask) preBundleTask.dependsOn(currentCopyResTask) } - packageTask.configure { + packageTask?.configure { if (config.enableVmCleanup.get()) { val libDir = "$buildDir/intermediates/transforms/" val targetVariant = ".*/transforms/[^/]*/${variant.name}/.*".toRegex() @@ -197,6 +193,8 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte it.into(jsBundleDirConfigValue.get()) } else { it.into(mergeAssetsTask.map { mergeFoldersTask -> mergeFoldersTask.outputDir.get() }) + // Workaround for Android Gradle Plugin 7.1 asset directory + it.into("$buildDir/intermediates/assets/${variant.name}/merge${targetName}Assets") } it.dependsOn(mergeAssetsTask) @@ -208,7 +206,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte // from Android plugin 4.1+. // This ensures to copy the bundle file before mergeResources task starts mergeResourcesTask.dependsOn(currentAssetsCopyTask) - packageTask.dependsOn(currentAssetsCopyTask) + packageTask?.dependsOn(currentAssetsCopyTask) preBundleTask.dependsOn(currentAssetsCopyTask) } @@ -225,30 +223,23 @@ private fun Project.cleanupVMFiles( // two separate HermesDebug and HermesRelease AARs, but until then we'll // kludge it by deleting the .so files out of the /transforms/ directory. fileTree(libDir) { - if (enableHermes) { - // For Hermes, delete all the libjsc* files - it.include("**/libjsc*.so") - - if (cleanup) { - // Reduce size by deleting the debugger/inspector - it.include("**/libhermes-inspector.so") - it.include("**/libhermes-executor-debug.so") - it.include("**/libhermes-executor-common-debug.so") - } else { - // Release libs take precedence and must be removed - // to allow debugging - it.include("**/libhermes-executor-release.so") - it.include("**/libhermes-executor-common-release.so") - } - } else { - // For JSC, delete all the libhermes* files - it.include("**/libhermes*.so") - // Delete the libjscexecutor from release build - if (cleanup) { - it.include("**/libjscexecutor.so") + if (enableHermes) { + // For Hermes, delete all the libjsc* files + it.include("**/libjsc*.so") + + if (cleanup) { + // Reduce size by deleting the debugger/inspector + it.include("**/libhermes-executor-debug.so") + } else { + // Release libs take precedence and must be removed + // to allow debugging + it.include("**/libhermes-executor-release.so") + } + } else { + // For JSC, delete all the libhermes* files + it.include("**/libhermes*.so") + } } - } - } .visit { visit -> val path = visit.file.absolutePath.replace(File.separatorChar, '/') if (path.matches(targetVariant) && visit.file.isFile) { @@ -258,4 +249,4 @@ private fun Project.cleanupVMFiles( } internal val BaseVariant.isRelease: Boolean - get() = name.toLowerCase(Locale.ROOT).contains("release") + get() = name.lowercase().contains("release") diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt new file mode 100644 index 00000000000000..26d7f08d95d3c7 --- /dev/null +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfig.kt @@ -0,0 +1,15 @@ +/* + * 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. + */ + +package com.facebook.react.model + +data class ModelCodegenConfig( + val name: String?, + val type: String?, + val jsSrcsDir: String?, + val android: ModelCodegenConfigAndroid? +) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt new file mode 100644 index 00000000000000..7619098a8dbc74 --- /dev/null +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.kt @@ -0,0 +1,10 @@ +/* + * 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. + */ + +package com.facebook.react.model + +data class ModelCodegenConfigAndroid(val javaPackageName: String?) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelPackageJson.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelPackageJson.kt new file mode 100644 index 00000000000000..96e2bd22d704fb --- /dev/null +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelPackageJson.kt @@ -0,0 +1,10 @@ +/* + * 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. + */ + +package com.facebook.react.model + +data class ModelPackageJson(val codegenConfig: ModelCodegenConfig?) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BuildCodegenCLITask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BuildCodegenCLITask.kt index 1b295cdec51058..9bc1ddba1734b9 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BuildCodegenCLITask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BuildCodegenCLITask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt index a00d3a6e28aef4..2e1a0b8be81900 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt index ad9434cf53c50c..f00bfad9143f46 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,33 +7,40 @@ package com.facebook.react.tasks -import com.facebook.react.codegen.generator.JavaGenerator -import com.facebook.react.utils.windowsAwareYarn -import org.gradle.api.GradleException +import com.facebook.react.utils.JsonUtils +import com.facebook.react.utils.windowsAwareCommandLine import org.gradle.api.file.Directory import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFile +import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider -import org.gradle.api.tasks.* +import org.gradle.api.tasks.Exec +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.OutputDirectory abstract class GenerateCodegenArtifactsTask : Exec() { - @get:Internal abstract val reactRoot: DirectoryProperty + @get:Internal abstract val reactNativeDir: DirectoryProperty @get:Internal abstract val codegenDir: DirectoryProperty @get:Internal abstract val generatedSrcDir: DirectoryProperty - @get:Input abstract val nodeExecutableAndArgs: ListProperty + @get:InputFile abstract val packageJsonFile: RegularFileProperty - @get:Input abstract val useJavaGenerator: Property + @get:Input abstract val nodeExecutableAndArgs: ListProperty @get:Input abstract val codegenJavaPackageName: Property @get:Input abstract val libraryName: Property + // We're keeping this just to fire a warning at the user should they use the `reactRoot` property. + @get:Internal abstract val deprecatedReactRoot: DirectoryProperty + @get:InputFile val combineJsToSchemaCli: Provider = codegenDir.file("lib/cli/combine/combine-js-to-schema-cli.js") @@ -46,28 +53,55 @@ abstract class GenerateCodegenArtifactsTask : Exec() { @get:OutputDirectory val generatedJniFiles: Provider = generatedSrcDir.dir("jni") override fun exec() { - setupCommandLine() + checkForDeprecatedProperty() + + val (resolvedLibraryName, resolvedCodegenJavaPackageName) = resolveTaskParameters() + setupCommandLine(resolvedLibraryName, resolvedCodegenJavaPackageName) super.exec() - if (useJavaGenerator.getOrElse(false)) { - // Use Java-based generator implementation to produce the source files, - // this will override the JS-based generator output (for the Java files only). - try { - JavaGenerator( - generatedSchemaFile.get().asFile, - codegenJavaPackageName.get(), - generatedSrcDir.get().asFile) - .build() - } catch (e: Exception) { - throw GradleException("Failed to generate Java from schema.", e) - } + } + + private fun checkForDeprecatedProperty() { + if (deprecatedReactRoot.isPresent) { + project.logger.error( + """ + ******************************************************************************** + The `reactRoot` property is deprecated and will be removed in + future versions of React Native. The property is currently ignored. + + You should instead use either: + - [root] to point to your root project (where the package.json lives) + - [reactNativeDir] to point to the NPM package of react native. + + You should be fine by just removing the `reactRoot` line entirely from + your build.gradle file. Otherwise a valid configuration would look like: + + react { + root = rootProject.file('..') + reactNativeDir = rootProject.file('../node_modules/react-native') + } + ******************************************************************************** + """.trimIndent()) } } - internal fun setupCommandLine() { + internal fun resolveTaskParameters(): Pair { + val parsedPackageJson = + if (packageJsonFile.isPresent && packageJsonFile.get().asFile.exists()) { + JsonUtils.fromCodegenJson(packageJsonFile.get().asFile) + } else { + null + } + val resolvedLibraryName = parsedPackageJson?.codegenConfig?.name ?: libraryName.get() + val resolvedCodegenJavaPackageName = + parsedPackageJson?.codegenConfig?.android?.javaPackageName ?: codegenJavaPackageName.get() + return resolvedLibraryName to resolvedCodegenJavaPackageName + } + + internal fun setupCommandLine(libraryName: String, codegenJavaPackageName: String) { commandLine( - windowsAwareYarn( + windowsAwareCommandLine( *nodeExecutableAndArgs.get().toTypedArray(), - reactRoot.file("scripts/generate-specs-cli.js").get().asFile.absolutePath, + reactNativeDir.file("scripts/generate-specs-cli.js").get().asFile.absolutePath, "--platform", "android", "--schemaPath", @@ -75,8 +109,8 @@ abstract class GenerateCodegenArtifactsTask : Exec() { "--outputDir", generatedSrcDir.get().asFile.absolutePath, "--libraryName", - libraryName.get(), + libraryName, "--javaPackageName", - codegenJavaPackageName.get())) + codegenJavaPackageName)) } } diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt index 59855d63e04119..ba2eeb2ffd1687 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,7 +7,7 @@ package com.facebook.react.tasks -import com.facebook.react.utils.windowsAwareYarn +import com.facebook.react.utils.windowsAwareCommandLine import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFile import org.gradle.api.provider.ListProperty @@ -29,7 +29,12 @@ abstract class GenerateCodegenSchemaTask : Exec() { @get:Input abstract val nodeExecutableAndArgs: ListProperty - @get:InputFiles val jsInputFiles = project.fileTree(jsRootDir) { it.include("**/*.js") } + @get:InputFiles + val jsInputFiles = + project.fileTree(jsRootDir) { + it.include("**/*.js") + it.exclude("**/generated/source/codegen/**/*") + } @get:OutputFile val generatedSchemaFile: Provider = generatedSrcDir.file("schema.json") @@ -49,7 +54,7 @@ abstract class GenerateCodegenSchemaTask : Exec() { internal fun setupCommandLine() { commandLine( - windowsAwareYarn( + windowsAwareCommandLine( *nodeExecutableAndArgs.get().toTypedArray(), codegenDir .file("lib/cli/combine/combine-js-to-schema-cli.js") diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt index d7866591c8eee3..3f9e635973847e 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,6 +7,7 @@ package com.facebook.react.tasks +import com.facebook.react.utils.detectOSAwareHermesCommand import com.facebook.react.utils.moveTo import com.facebook.react.utils.windowsAwareCommandLine import java.io.File @@ -19,7 +20,7 @@ import org.gradle.api.tasks.TaskAction open class HermesBinaryTask : DefaultTask() { - @get:Internal internal lateinit var reactRoot: File + @get:Internal internal lateinit var root: File @get:Input internal lateinit var hermesCommand: String @get:Input internal var hermesFlags: List = emptyList() @@ -33,8 +34,9 @@ open class HermesBinaryTask : DefaultTask() { @TaskAction fun run() { + val detectedHermesCommand = detectOSAwareHermesCommand(root, hermesCommand) val bytecodeTempFile = File("$jsBundleFile.hbc") - emitHermesBinary(outputFile = bytecodeTempFile) + emitHermesBinary(hermesCommand = detectedHermesCommand, outputFile = bytecodeTempFile) bytecodeTempFile.moveTo(jsBundleFile) if (hermesFlags.contains("-output-source-map")) { @@ -44,7 +46,7 @@ open class HermesBinaryTask : DefaultTask() { } } - private fun emitHermesBinary(outputFile: File) { + private fun emitHermesBinary(hermesCommand: String, outputFile: File) { project.exec { @Suppress("SpreadOperator") it.commandLine( @@ -60,7 +62,7 @@ open class HermesBinaryTask : DefaultTask() { private fun composeSourceMaps() { project.exec { - it.workingDir(reactRoot) + it.workingDir(root) @Suppress("SpreadOperator") it.commandLine( diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTask.kt index b7ffce9a3f7a21..fd0769b9023802 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt index ff81e8ceb06425..9fe06794aeabd5 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareBoostTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,6 +33,7 @@ abstract class PrepareBoostTask : DefaultTask() { it.from(project.file("src/main/jni/third-party/boost")) it.include( "Android.mk", + "CMakeLists.txt", "boost_${boostVersion.get()}/boost/**/*.hpp", "boost/boost/**/*.hpp", "asm/**/*.S") diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt index 6344b66f4299c5..f2320718872434 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareGlogTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -33,7 +33,7 @@ abstract class PrepareGlogTask : DefaultTask() { project.copy { it.from(glogPath) it.from(project.file("src/main/jni/third-party/glog/")) - it.include("glog-${glogVersion.get()}/src/**/*", "Android.mk", "config.h") + it.include("glog-${glogVersion.get()}/src/**/*", "Android.mk", "CMakeLists.txt", "config.h") it.duplicatesStrategy = DuplicatesStrategy.WARN it.includeEmptyDirs = false it.filesMatching("**/*.h.in") { matchedFile -> diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt index b4701df422330a..de742285bb64b3 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -42,6 +42,7 @@ abstract class PrepareJSCTask : DefaultTask() { it.from(soFiles) it.from(headerFiles) it.from(project.file("src/main/jni/third-party/jsc/Android.mk")) + it.from(project.file("src/main/jni/third-party/jsc/CMakeLists.txt")) it.filesMatching("**/*.h") { it.path = "JavaScriptCore/${it.name}" } it.includeEmptyDirs = false it.into(outputDir) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt index 416f77f17cdb56..f5faa9ff75b6bd 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTask.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -30,15 +30,14 @@ abstract class PrepareLibeventTask : DefaultTask() { fun taskAction() { project.copy { it -> it.from(libeventPath) - it.from(project.file("src/main/jni/third-party/libevent/Android.mk")) - it.from(project.file("src/main/jni/third-party/libevent/event-config.h")) - it.from(project.file("src/main/jni/third-party/libevent/evconfig-private.h")) + it.from(project.file("src/main/jni/third-party/libevent/")) it.include( "libevent-${libeventVersion.get()}-stable/*.c", "libevent-${libeventVersion.get()}-stable/*.h", "libevent-${libeventVersion.get()}-stable/include/**/*", "evconfig-private.h", "event-config.h", + "CMakeLists.txt", "Android.mk") it.eachFile { it.path = it.path.removePrefix("libevent-${libeventVersion.get()}-stable/") } it.includeEmptyDirs = false diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/FileUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/FileUtils.kt index 040fe0673bb0d9..28774b82359556 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/FileUtils.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/FileUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt new file mode 100644 index 00000000000000..4fa27510f484e1 --- /dev/null +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt @@ -0,0 +1,21 @@ +/* + * 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. + */ + +package com.facebook.react.utils + +import com.facebook.react.model.ModelPackageJson +import com.google.gson.Gson +import java.io.File + +object JsonUtils { + private val gsonConverter = Gson() + + fun fromCodegenJson(input: File): ModelPackageJson? = + input.bufferedReader().use { + runCatching { gsonConverter.fromJson(it, ModelPackageJson::class.java) }.getOrNull() + } +} diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt index d677d2d9591670..c4dfad637fc531 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,12 +7,18 @@ package com.facebook.react.utils -import java.util.* - object Os { fun isWindows(): Boolean = - System.getProperty("os.name")?.toLowerCase(Locale.ROOT)?.contains("windows") ?: false + System.getProperty("os.name")?.lowercase()?.contains("windows") ?: false + + fun isMac(): Boolean = System.getProperty("os.name")?.lowercase()?.contains("mac") ?: false + + fun isLinuxAmd64(): Boolean { + val osNameMatch = System.getProperty("os.name")?.lowercase()?.contains("linux") ?: false + val archMatch = System.getProperty("os.arch")?.lowercase()?.contains("amd64") ?: false + return osNameMatch && archMatch + } fun String.unixifyPath() = this.replace('\\', '/').replace(":", "").let { diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt index f94f3658234391..562ac7857c11da 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -11,8 +11,6 @@ package com.facebook.react.utils import com.facebook.react.ReactExtension import java.io.File -import java.util.* -import org.apache.tools.ant.taskdefs.condition.Os /** * Computes the entry file for React Native. The Algo follows this order: @@ -25,7 +23,7 @@ import org.apache.tools.ant.taskdefs.condition.Os */ internal fun detectedEntryFile(config: ReactExtension): File = detectEntryFile( - entryFile = config.entryFile.orNull?.asFile, reactRoot = config.reactRoot.get().asFile) + entryFile = config.entryFile.orNull?.asFile, reactRoot = config.root.get().asFile) /** * Computes the CLI location for React Native. The Algo follows this order: @@ -40,18 +38,21 @@ internal fun detectedCliPath( ): String = detectCliPath( projectDir = projectDir, - reactRoot = config.reactRoot.get().asFile, + reactRoot = config.root.get().asFile, preconfiguredCliPath = config.cliPath.orNull) /** * Computes the `hermesc` command location. The Algo follows this order: - * 1. The path provided by the `hermesCommand` config in the `reactApp` Gradle extension - * 2. The file located in `node_modules/hermes-engine/%OS-BIN%/hermesc` where `%OS-BIN%` is - * substituted with the correct OS arch. - * 3. Fails otherwise + * 1. The path provided by the `hermesCommand` config in the `react` Gradle extension + * 2. The file located in `node_modules/react-native/sdks/hermes/build/bin/hermesc`. This will be + * used if the user is building Hermes from source. + * 3. The file located in `node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc` where `%OS-BIN%` + * is substituted with the correct OS arch. This will be used if the user is using a precompiled + * hermes-engine package. + * 4. Fails otherwise */ internal fun detectedHermesCommand(config: ReactExtension): String = - detectOSAwareHermesCommand(config.hermesCommand.get()) + detectOSAwareHermesCommand(config.root.get().asFile, config.hermesCommand.get()) private fun detectEntryFile(entryFile: File?, reactRoot: File): File = when { @@ -68,7 +69,18 @@ private fun detectCliPath( ): String { // 1. preconfigured path if (preconfiguredCliPath != null) { - return File(projectDir, preconfiguredCliPath).toString() + val preconfiguredCliJsAbsolute = File(preconfiguredCliPath) + if (preconfiguredCliJsAbsolute.exists()) { + return preconfiguredCliJsAbsolute.absolutePath + } + val preconfiguredCliJsRelativeToReactRoot = File(reactRoot, preconfiguredCliPath) + if (preconfiguredCliJsRelativeToReactRoot.exists()) { + return preconfiguredCliJsRelativeToReactRoot.absolutePath + } + val preconfiguredCliJsRelativeToProject = File(projectDir, preconfiguredCliPath) + if (preconfiguredCliJsRelativeToProject.exists()) { + return preconfiguredCliJsRelativeToProject.absolutePath + } } // 2. node module path @@ -82,7 +94,10 @@ private fun detectCliPath( val nodeProcessOutput = nodeProcess.inputStream.use { it.bufferedReader().readText().trim() } if (nodeProcessOutput.isNotEmpty()) { - return nodeProcessOutput + val nodeModuleCliJs = File(nodeProcessOutput) + if (nodeModuleCliJs.exists()) { + return nodeModuleCliJs.absolutePath + } } // 3. cli.js in the root folder @@ -97,22 +112,73 @@ private fun detectCliPath( "This file typically resides in `node_modules/react-native/cli.js`") } -// Make sure not to inspect the Hermes config unless we need it, -// to avoid breaking any JSC-only setups. -private fun detectOSAwareHermesCommand(hermesCommand: String): String { - // If the project specifies a Hermes command, don't second guess it. - if (!hermesCommand.contains("%OS-BIN%")) { - return hermesCommand +/** + * Computes the `hermesc` command location. The Algo follows this order: + * 1. The path provided by the `hermesCommand` config in the `react` Gradle extension + * 2. The file located in `node_modules/react-native/sdks/hermes/build/bin/hermesc`. This will be + * used if the user is building Hermes from source. + * 3. The file located in `node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc` where `%OS-BIN%` + * is substituted with the correct OS arch. This will be used if the user is using a precompiled + * hermes-engine package. + * 4. Fails otherwise + */ +internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String): String { + // 1. If the project specifies a Hermes command, don't second guess it. + if (hermesCommand.isNotBlank()) { + val osSpecificHermesCommand = + if ("%OS-BIN%" in hermesCommand) { + hermesCommand.replace("%OS-BIN%", getHermesOSBin()) + } else { + hermesCommand + } + return osSpecificHermesCommand + // Execution on Windows fails with / as separator + .replace('/', File.separatorChar) + } + + // 2. If the project is building hermes-engine from source, use hermesc from there + val builtHermesc = + getBuiltHermescFile(projectRoot, System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR")) + if (builtHermesc.exists()) { + return builtHermesc.absolutePath } - // Execution on Windows fails with / as separator - return hermesCommand.replace("%OS-BIN%", getHermesOSBin()).replace('/', File.separatorChar) + // 3. If the react-native contains a pre-built hermesc, use it. + val prebuiltHermesPath = + HERMESC_IN_REACT_NATIVE_PATH.replace("%OS-BIN%", getHermesOSBin()) + // Execution on Windows fails with / as separator + .replace('/', File.separatorChar) + + val prebuiltHermes = File(projectRoot, prebuiltHermesPath) + if (prebuiltHermes.exists()) { + return prebuiltHermes.absolutePath + } + + error( + "Couldn't determine Hermesc location. " + + "Please set `react.hermesCommand` to the path of the hermesc binary file. " + + "node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc") } -private fun getHermesOSBin(): String { - if (Os.isFamily(Os.FAMILY_WINDOWS)) return "win64-bin" - if (Os.isFamily(Os.FAMILY_MAC)) return "osx-bin" - if (Os.isOs(null, "linux", "amd64", null)) return "linux64-bin" +/** + * Gets the location where Hermesc should be. If nothing is specified, built hermesc is assumed to + * be inside [HERMESC_BUILT_FROM_SOURCE_PATH]. Otherwise user can specify an override with + * [pathOverride], which is assumed to be an absolute path where Hermes source code is + * provided/built. + * + * @param projectRoot The root of the Project. + */ +internal fun getBuiltHermescFile(projectRoot: File, pathOverride: String?) = + if (!pathOverride.isNullOrBlank()) { + File(pathOverride, "build/bin/hermesc") + } else { + File(projectRoot, HERMESC_BUILT_FROM_SOURCE_PATH) + } + +internal fun getHermesOSBin(): String { + if (Os.isWindows()) return "win64-bin" + if (Os.isMac()) return "osx-bin" + if (Os.isLinuxAmd64()) return "linux64-bin" error( "OS not recognized. Please set project.react.hermesCommand " + "to the path of a working Hermes compiler.") @@ -121,5 +187,10 @@ private fun getHermesOSBin(): String { internal fun projectPathToLibraryName(projectPath: String): String = projectPath .split(':', '-', '_', '.') - .joinToString("") { it.capitalize(Locale.ROOT) } + .joinToString("") { token -> token.replaceFirstChar { it.uppercase() } } .plus("Spec") + +private const val HERMESC_IN_REACT_NATIVE_PATH = + "node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc" +private const val HERMESC_BUILT_FROM_SOURCE_PATH = + "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc" diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt index dc4f1ac01c8c08..fd557079f59dd5 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -14,13 +14,6 @@ internal fun windowsAwareCommandLine(vararg args: Any): List = args.toList() } -internal fun windowsAwareYarn(vararg args: Any): List = - if (Os.isWindows()) { - listOf("yarn.cmd") + args - } else { - listOf("yarn") + args - } - internal fun windowsAwareBashCommandLine( vararg args: String, bashWindowsHome: String? = null diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/AndroidConfigurationTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/AndroidConfigurationTest.kt index 34f799ed505339..3c91f35e5a5aa6 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/AndroidConfigurationTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/AndroidConfigurationTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -24,10 +24,11 @@ class AndroidConfigurationTest { project.configureDevPorts(androidExtension) - assertEquals("8081", debug?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("8081", debug?.resValues?.get("react_native_inspector_proxy_port")?.value) - assertEquals("8081", release?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("8081", release?.resValues?.get("react_native_inspector_proxy_port")?.value) + assertEquals("8081", debug?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals("8081", debug?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) + assertEquals("8081", release?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals( + "8081", release?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) } @Test @@ -42,10 +43,11 @@ class AndroidConfigurationTest { project.configureDevPorts(androidExtension) - assertEquals("42424", debug?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("42424", debug?.resValues?.get("react_native_inspector_proxy_port")?.value) - assertEquals("42424", release?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("42424", release?.resValues?.get("react_native_inspector_proxy_port")?.value) + assertEquals("42424", debug?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals("42424", debug?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) + assertEquals("42424", release?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals( + "42424", release?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) } @Test @@ -60,9 +62,10 @@ class AndroidConfigurationTest { project.configureDevPorts(androidExtension) - assertEquals("8081", debug?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("42424", debug?.resValues?.get("react_native_inspector_proxy_port")?.value) - assertEquals("8081", release?.resValues?.get("react_native_dev_server_port")?.value) - assertEquals("42424", release?.resValues?.get("react_native_inspector_proxy_port")?.value) + assertEquals("8081", debug?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals("42424", debug?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) + assertEquals("8081", release?.resValues?.get("integer/react_native_dev_server_port")?.value) + assertEquals( + "42424", release?.resValues?.get("integer/react_native_inspector_proxy_port")?.value) } } diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt index 602dd522f40960..39caba83bfaf92 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -20,7 +20,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(true) cliPath.set(".") @@ -36,7 +36,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } assertTrue(project.getTasksByName("bundleDebugJsAndAssets", false).isEmpty()) @@ -48,7 +48,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } assertTrue(project.getTasksByName("buildCodegenCLI", false).isNotEmpty()) diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/TestReactExtension.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/TestReactExtension.kt index e5c684b29caa7b..afc9ff358ea996 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/TestReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/TestReactExtension.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BuildCodegenCLITaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BuildCodegenCLITaskTest.kt index 240d0c11d24c6f..33db1357ebdf6b 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BuildCodegenCLITaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BuildCodegenCLITaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt index a9df6181d42a8f..a559b036422cdb 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -58,48 +58,45 @@ class GenerateCodegenArtifactsTaskTest { @Test fun generateCodegenSchema_simpleProperties_areInsideInput() { + val packageJsonFile = tempFolder.newFile("package.json") + val task = createTestTask { it.nodeExecutableAndArgs.set(listOf("npm", "help")) - it.useJavaGenerator.set(true) it.codegenJavaPackageName.set("com.example.test") it.libraryName.set("example-test") + it.packageJsonFile.set(packageJsonFile) } assertEquals(listOf("npm", "help"), task.nodeExecutableAndArgs.get()) - assertEquals(true, task.useJavaGenerator.get()) assertEquals("com.example.test", task.codegenJavaPackageName.get()) assertEquals("example-test", task.libraryName.get()) assertTrue(task.inputs.properties.containsKey("nodeExecutableAndArgs")) - assertTrue(task.inputs.properties.containsKey("useJavaGenerator")) assertTrue(task.inputs.properties.containsKey("codegenJavaPackageName")) assertTrue(task.inputs.properties.containsKey("libraryName")) } @Test @WithOs(OS.UNIX) - fun setupCommandLine_withoutJavaGenerator_willSetupCorrectly() { - val reactRoot = tempFolder.newFolder("node_modules/react-native/") + fun setupCommandLine_willSetupCorrectly() { + val reactNativeDir = tempFolder.newFolder("node_modules/react-native/") val codegenDir = tempFolder.newFolder("codegen") val outputDir = tempFolder.newFolder("output") val task = createTestTask { - it.reactRoot.set(reactRoot) + it.reactNativeDir.set(reactNativeDir) it.codegenDir.set(codegenDir) it.generatedSrcDir.set(outputDir) it.nodeExecutableAndArgs.set(listOf("--verbose")) - it.codegenJavaPackageName.set("com.example.test") - it.libraryName.set("example-test") } - task.setupCommandLine() + task.setupCommandLine("example-test", "com.example.test") assertEquals( listOf( - "yarn", "--verbose", - File(reactRoot, "scripts/generate-specs-cli.js").toString(), + File(reactNativeDir, "scripts/generate-specs-cli.js").toString(), "--platform", "android", "--schemaPath", @@ -113,4 +110,79 @@ class GenerateCodegenArtifactsTaskTest { ), task.commandLine.toMutableList()) } + + @Test + fun resolveTaskParameters_withConfigInPackageJson_usesIt() { + val packageJsonFile = + tempFolder.newFile("package.json").apply { + // language=JSON + writeText( + """ + { + "name": "@a/libray", + "codegenConfig": { + "name": "an-awesome-library", + "android": { + "javaPackageName": "com.awesome.package" + } + } + } + """.trimIndent()) + } + + val task = + createTestTask { + it.packageJsonFile.set(packageJsonFile) + it.codegenJavaPackageName.set("com.example.ignored") + it.libraryName.set("a-library-name-that-is-ignored") + } + + val (libraryName, javaPackageName) = task.resolveTaskParameters() + + assertEquals("an-awesome-library", libraryName) + assertEquals("com.awesome.package", javaPackageName) + } + + @Test + fun resolveTaskParameters_withConfigMissingInPackageJson_usesGradleOne() { + val packageJsonFile = + tempFolder.newFile("package.json").apply { + // language=JSON + writeText( + """ + { + "name": "@a/libray", + "codegenConfig": { + } + } + """.trimIndent()) + } + + val task = + createTestTask { + it.packageJsonFile.set(packageJsonFile) + it.codegenJavaPackageName.set("com.example.test") + it.libraryName.set("a-library-name-from-gradle") + } + + val (libraryName, javaPackageName) = task.resolveTaskParameters() + + assertEquals("a-library-name-from-gradle", libraryName) + assertEquals("com.example.test", javaPackageName) + } + + @Test + fun resolveTaskParameters_withMissingPackageJson_usesGradleOne() { + val task = + createTestTask { + it.packageJsonFile.set(File(tempFolder.root, "package.json")) + it.codegenJavaPackageName.set("com.example.test") + it.libraryName.set("a-library-name-from-gradle") + } + + val (libraryName, javaPackageName) = task.resolveTaskParameters() + + assertEquals("a-library-name-from-gradle", libraryName) + assertEquals("com.example.test", javaPackageName) + } } diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt index cb092dfc6ec9e4..68af7866b0470c 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -105,7 +105,6 @@ class GenerateCodegenSchemaTaskTest { assertEquals( listOf( - "yarn", "--verbose", File(codegenDir, "lib/cli/combine/combine-js-to-schema-cli.js").toString(), File(outputDir, "schema.json").toString(), diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTaskTest.kt index c207d6daae03a7..38394e3bf43177 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/ExtractJniAndHeadersTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt index ff9829de2b9408..d1ebb9c665f70f 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareBoostTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareGlogTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareGlogTaskTest.kt index 782bac3dce7430..ceb0c916e16dc3 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareGlogTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareGlogTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt index f420c80d00b93f..669664b881426c 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTaskTest.kt index 7a126edb6b9d6a..1bb571fa769b5d 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareLibeventTaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt index 33d4dacd3746ac..1b3e7cfcc4d8ad 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/TaskTestUtils.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/TaskTestUtils.kt index 57d247ee99fa90..04122985cad3be 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/TaskTestUtils.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/TaskTestUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt index cd1118331e31ab..beda3142cd30e6 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/FileUtilsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/FileUtilsTest.kt index be38dd6fa877b3..a47e6ed47b8891 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/FileUtilsTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/FileUtilsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt new file mode 100644 index 00000000000000..d52bd985ac03dd --- /dev/null +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt @@ -0,0 +1,92 @@ +/* + * 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. + */ + +package com.facebook.react.utils + +import org.intellij.lang.annotations.Language +import org.junit.Assert.* +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class JsonUtilsTest { + + @get:Rule val tempFolder = TemporaryFolder() + + @Test + fun withInvalidJson_returnsNull() { + val invalidJson = createJsonFile("""¯\_(ツ)_/¯""") + + assertNull(JsonUtils.fromCodegenJson(invalidJson)) + } + + @Test + fun withEmptyJson_returnsEmptyObject() { + val invalidJson = createJsonFile("""{}""") + + val parsed = JsonUtils.fromCodegenJson(invalidJson) + + assertNotNull(parsed) + assertNull(parsed?.codegenConfig) + } + + @Test + fun withOldJsonConfig_returnsAnEmptyLibrary() { + val oldJsonConfig = + createJsonFile( + """ + { + "name": "yet another npm package", + "codegenConfig": { + "libraries": [ + { + "name": "an awesome library", + "jsSrcsDir": "../js/", + "android": {} + } + ] + } + } + """.trimIndent()) + + val parsed = JsonUtils.fromCodegenJson(oldJsonConfig)!! + + assertNull(parsed.codegenConfig?.name) + assertNull(parsed.codegenConfig?.jsSrcsDir) + assertNull(parsed.codegenConfig?.android) + } + + @Test + fun withValidJson_parsesCorrectly() { + val validJson = + createJsonFile( + """ + { + "name": "yet another npm package", + "codegenConfig": { + "name": "an awesome library", + "jsSrcsDir": "../js/", + "android": { + "javaPackageName": "com.awesome.library" + }, + "ios": { + "other ios only keys": "which are ignored during parsing" + } + } + } + """.trimIndent()) + + val parsed = JsonUtils.fromCodegenJson(validJson)!! + + assertEquals("an awesome library", parsed.codegenConfig!!.name) + assertEquals("../js/", parsed.codegenConfig!!.jsSrcsDir) + assertEquals("com.awesome.library", parsed.codegenConfig!!.android!!.javaPackageName) + } + + private fun createJsonFile(@Language("JSON") input: String) = + tempFolder.newFile().apply { writeText(input) } +} diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt index 987a6d8416371f..78976ea70ce87d 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -21,20 +21,26 @@ class OsTest { @Test @WithOs(OS.UNIX) - fun isWindows_onUnix_returnsFalse() { + fun onUnix_checksOsCorrectly() { assertFalse(Os.isWindows()) + assertFalse(Os.isMac()) + assertFalse(Os.isLinuxAmd64()) } @Test @WithOs(OS.MAC) - fun isWindows_onMac_returnsTrue() { + fun onMac_checksOsCorrectly() { assertFalse(Os.isWindows()) + assertTrue(Os.isMac()) + assertFalse(Os.isLinuxAmd64()) } @Test @WithOs(OS.WIN) fun isWindows_onWindows_returnsTrue() { assertTrue(Os.isWindows()) + assertFalse(Os.isMac()) + assertFalse(Os.isLinuxAmd64()) } @Test diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt index 8c9b4434698dd0..6b45db541d125f 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -8,9 +8,13 @@ package com.facebook.react.utils import com.facebook.react.TestReactExtension +import com.facebook.react.tests.OS +import com.facebook.react.tests.OsRule +import com.facebook.react.tests.WithOs import java.io.File import org.gradle.testfixtures.ProjectBuilder import org.junit.Assert.* +import org.junit.Assume.assumeTrue import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -18,6 +22,7 @@ import org.junit.rules.TemporaryFolder class PathUtilsTest { @get:Rule val tempFolder = TemporaryFolder() + @get:Rule val osRule = OsRule() @Test fun detectedEntryFile_withProvidedVariable() { @@ -33,7 +38,7 @@ class PathUtilsTest { @Test fun detectedEntryFile_withAndroidEntryPoint() { val extension = TestReactExtension(ProjectBuilder.builder().build()) - extension.reactRoot.set(tempFolder.root) + extension.root.set(tempFolder.root) tempFolder.newFile("index.android.js") val actual = detectedEntryFile(extension) @@ -44,7 +49,7 @@ class PathUtilsTest { @Test fun detectedEntryFile_withDefaultEntryPoint() { val extension = TestReactExtension(ProjectBuilder.builder().build()) - extension.reactRoot.set(tempFolder.root) + extension.root.set(tempFolder.root) val actual = detectedEntryFile(extension) @@ -52,10 +57,47 @@ class PathUtilsTest { } @Test - fun detectedCliPath_withCliPathFromExtension() { + fun detectedCliPath_withCliPathFromExtensionAbsolute() { val project = ProjectBuilder.builder().build() val extension = TestReactExtension(project) - val expected = File(project.projectDir, "fake-cli.sh") + val expected = + File(project.projectDir, "abs/fake-cli.sh").apply { + parentFile.mkdirs() + writeText("") + } + extension.cliPath.set(project.projectDir.toString() + "/abs/fake-cli.sh") + + val actual = detectedCliPath(project.projectDir, extension) + + assertEquals(expected.toString(), actual) + } + + @Test + fun detectedCliPath_withCliPathFromExtensionInReactFolder() { + val project = ProjectBuilder.builder().build() + val extension = TestReactExtension(project) + val expected = + File(project.projectDir, "/react-root/fake-cli.sh").apply { + parentFile.mkdirs() + writeText("") + } + extension.cliPath.set("fake-cli.sh") + extension.root.set(File(project.projectDir.toString(), "react-root")) + + val actual = detectedCliPath(project.projectDir, extension) + + assertEquals(expected.toString(), actual) + } + + @Test + fun detectedCliPath_withCliPathFromExtensionInProjectFolder() { + val project = ProjectBuilder.builder().build() + val extension = TestReactExtension(project) + val expected = + File(project.projectDir, "fake-cli.sh").apply { + parentFile.mkdirs() + writeText("") + } extension.cliPath.set("fake-cli.sh") val actual = detectedCliPath(project.projectDir, extension) @@ -67,6 +109,7 @@ class PathUtilsTest { fun detectedCliPath_withCliPathFromExtensionInParentFolder() { val rootProject = ProjectBuilder.builder().build() val project = ProjectBuilder.builder().withParent(rootProject).build() + project.projectDir.mkdirs() val extension = TestReactExtension(project) val expected = File(rootProject.projectDir, "cli-in-root.sh").apply { writeText("#!/bin/bash") } extension.cliPath.set("../cli-in-root.sh") @@ -80,7 +123,7 @@ class PathUtilsTest { fun detectedCliPath_withCliFromNodeModules() { val project = ProjectBuilder.builder().build() val extension = TestReactExtension(project) - extension.reactRoot.set(tempFolder.root) + extension.root.set(tempFolder.root) val expected = File(tempFolder.root, "node_modules/react-native/cli.js").apply { parentFile.mkdirs() @@ -101,44 +144,102 @@ class PathUtilsTest { } @Test - fun detectedHermesCommand_withPathFromExtension() { - val extension = TestReactExtension(ProjectBuilder.builder().build()) - val expected = tempFolder.newFile("hermesc") - extension.hermesCommand.set(expected.toString()) + fun projectPathToLibraryName_withSimplePath() { + assertEquals("SampleSpec", projectPathToLibraryName(":sample")) + } - val actual = detectedHermesCommand(extension) + @Test + fun projectPathToLibraryName_withComplexPath() { + assertEquals("SampleAndroidAppSpec", projectPathToLibraryName(":sample:android:app")) + } - assertEquals(expected.toString(), actual) + @Test + fun projectPathToLibraryName_withKebabCase() { + assertEquals("SampleAndroidAppSpec", projectPathToLibraryName("sample-android-app")) } @Test - fun detectedHermesCommand_withOSSpecificBin() { - val extension = TestReactExtension(ProjectBuilder.builder().build()) + fun projectPathToLibraryName_withDotsAndUnderscores() { + assertEquals("SampleAndroidAppSpec", projectPathToLibraryName("sample_android.app")) + } - val actual = detectedHermesCommand(extension) + @Test + fun detectOSAwareHermesCommand_withProvidedCommand() { + assertEquals( + "./my-home/hermes", detectOSAwareHermesCommand(tempFolder.root, "./my-home/hermes")) + } - assertTrue(actual.startsWith("node_modules/hermes-engine/")) - assertTrue(actual.endsWith("hermesc")) - assertFalse(actual.contains("%OS-BIN%")) + @Test + fun detectOSAwareHermesCommand_withHermescBuiltLocally() { + // As we can't mock env variables, we skip this test if an override of the Hermes + // path has been provided. + assumeTrue(System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") == null) + + tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/") + val expected = + tempFolder.newFile( + "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc") + + assertEquals(expected.toString(), detectOSAwareHermesCommand(tempFolder.root, "")) } @Test - fun projectPathToLibraryName_withSimplePath() { - assertEquals("SampleSpec", projectPathToLibraryName(":sample")) + @WithOs(OS.MAC) + fun detectOSAwareHermesCommand_withBundledHermescInsideRN() { + tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/") + val expected = tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc") + + assertEquals(expected.toString(), detectOSAwareHermesCommand(tempFolder.root, "")) + } + + @Test(expected = IllegalStateException::class) + @WithOs(OS.MAC) + fun detectOSAwareHermesCommand_failsIfNotFound() { + detectOSAwareHermesCommand(tempFolder.root, "") } @Test - fun projectPathToLibraryName_withComplexPath() { - assertEquals("SampleAndroidAppSpec", projectPathToLibraryName(":sample:android:app")) + @WithOs(OS.MAC) + fun detectOSAwareHermesCommand_withProvidedCommand_takesPrecedence() { + tempFolder.newFolder("node_modules/react-native/sdks/hermes/build/bin/") + tempFolder.newFile("node_modules/react-native/sdks/hermes/build/bin/hermesc") + tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/") + tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc") + + assertEquals( + "./my-home/hermes", detectOSAwareHermesCommand(tempFolder.root, "./my-home/hermes")) } @Test - fun projectPathToLibraryName_withKebabCase() { - assertEquals("SampleAndroidAppSpec", projectPathToLibraryName("sample-android-app")) + @WithOs(OS.MAC) + fun detectOSAwareHermesCommand_withoutProvidedCommand_builtHermescTakesPrecedence() { + // As we can't mock env variables, we skip this test if an override of the Hermes + // path has been provided. + assumeTrue(System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") == null) + + tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/") + val expected = + tempFolder.newFile( + "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc") + tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/") + tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc") + + assertEquals(expected.toString(), detectOSAwareHermesCommand(tempFolder.root, "")) } @Test - fun projectPathToLibraryName_withDotsAndUnderscores() { - assertEquals("SampleAndroidAppSpec", projectPathToLibraryName("sample_android.app")) + fun getBuiltHermescFile_withoutOverride() { + assertEquals( + File( + tempFolder.root, + "node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"), + getBuiltHermescFile(tempFolder.root, "")) + } + + @Test + fun getBuiltHermescFile_withOverride() { + assertEquals( + File("/home/circleci/hermes/build/bin/hermesc"), + getBuiltHermescFile(tempFolder.root, "/home/circleci/hermes")) } } diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt index 90ac0063189bfd..8156ef029e7174 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -42,24 +42,6 @@ class TaskUtilsTest { assertEquals(listOf("cmd", "/c", "a", "b", "c"), windowsAwareCommandLine("a", "b", "c")) } - @Test - @WithOs(OS.MAC) - fun windowsAwareYarn_onMac_returnsTheList() { - assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c")) - } - - @Test - @WithOs(OS.UNIX) - fun windowsAwareYarn_onLinux_returnsTheList() { - assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c")) - } - - @Test - @WithOs(OS.WIN) - fun windowsAwareYarn_onWindows_prependsCmd() { - assertEquals(listOf("yarn.cmd", "a", "b", "c"), windowsAwareYarn("a", "b", "c")) - } - @Test @WithOs(OS.MAC) fun windowsAwareBashCommandLine_onMac_returnsTheList() { diff --git a/packages/rn-tester/.xcode.env b/packages/rn-tester/.xcode.env new file mode 100644 index 00000000000000..3d5782c71568d3 --- /dev/null +++ b/packages/rn-tester/.xcode.env @@ -0,0 +1,11 @@ +# This `.xcode.env` file is versioned and is used to source the environment +# used when running script phases inside Xcode. +# To customize your local environment, you can create an `.xcode.env.local` +# file that is not versioned. + +# NODE_BINARY variable contains the PATH to the node executable. +# +# Customize the NODE_BINARY variable here. +# For example, to use nvm with brew, add the following line +# . "$(brew --prefix nvm)/nvm.sh" --no-use +export NODE_BINARY=$(command -v node) diff --git a/packages/rn-tester/BUCK b/packages/rn-tester/BUCK index b62e80d495cff4..04c75fe503b596 100644 --- a/packages/rn-tester/BUCK +++ b/packages/rn-tester/BUCK @@ -1,3 +1,4 @@ +load("@fbsource//xplat/hermes/defs:hermes.bzl", "HERMES_BYTECODE_VERSION") load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native") load("//tools/build_defs:fb_xplat_platform_specific_rule.bzl", "fb_xplat_platform_specific_rule") load("//tools/build_defs:fb_xplat_resource.bzl", "fb_xplat_resource") @@ -11,8 +12,9 @@ load( "//tools/build_defs/oss:rn_defs.bzl", "APPLE", "YOGA_APPLE_TARGET", - "js_glob", + "js_library_glob", "make_resource_glob", + "react_fabric_component_plugin_provider", "react_module_plugin_providers", "rn_apple_library", "rn_extra_build_flags", @@ -44,10 +46,11 @@ yarn_workspace( rn_library( name = "rn-tester", - srcs = js_glob( + srcs = js_library_glob( [ "js", "NativeModuleExample", + "NativeComponentExample", "RCTTest", ], excludes = [ @@ -57,7 +60,12 @@ rn_library( "js/examples/WebSocket/websocket_test_server.js", ], ), - labels = ["supermodule:xplat/default/public.react_native.playground"], + codegen_components = True, + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.playground", + ], + native_component_spec_name = "AppSpecs", skip_processors = True, visibility = ["PUBLIC"], deps = [ @@ -75,6 +83,9 @@ fb_native.filegroup( [ "**/*NativeComponent.js", ], + exclude = [ + "NativeComponentExample/**/*", + ], ), visibility = ["PUBLIC"], ) @@ -120,7 +131,9 @@ fb_apple_test( "QuartzCore", "UIKit", ], - preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode(), + preprocessor_flags = get_objc_arc_preprocessor_flags() + [ + "-DHERMES_BYTECODE_VERSION={}".format(HERMES_BYTECODE_VERSION), + ] + get_preprocessor_flags_for_build_mode(), visibility = [ "//fbobjc/Libraries/FBReactKit:workspace", ], @@ -270,3 +283,41 @@ rn_apple_library( YOGA_APPLE_TARGET, ], ) + +rn_xplat_cxx_library2( + name = "NativeComponentExample", + plugins_only = True, + srcs = glob( + [ + "NativeComponentExample/ios/*.m", + "NativeComponentExample/ios/*.mm", + ], + ), + headers = glob( + [ + "NativeComponentExample/ios/*.h", + ], + ), + header_namespace = "", + compiler_flags = [ + "-fexceptions", + "-frtti", + "-std=c++17", + "-Wall", + ], + contacts = ["oncall+react_native@xmail.facebook.com"], + labels = [ + "pfh:ReactNative_CommonInfrastructurePlaceholder", + "supermodule:xplat/default/public.react_native.infra", + ], + plugins = [ + react_fabric_component_plugin_provider("RNTMyNativeView", "RNTMyNativeViewCls"), + ], + plugins_header = "RCTFabricComponentsPlugins.h", + reexport_all_header_dependencies = False, + visibility = ["PUBLIC"], + deps = [ + ":generated_components-AppSpecs", + "//xplat/js/react-native-github:RCTFabricComponentViewsBase", + ], +) diff --git a/packages/rn-tester/Gemfile b/packages/rn-tester/Gemfile index cefffcd9c8bdca..7bb000655cb646 100644 --- a/packages/rn-tester/Gemfile +++ b/packages/rn-tester/Gemfile @@ -1,5 +1,5 @@ # Gemfile source 'https://rubygems.org' -gem 'cocoapods', '= 1.11.2' +gem 'cocoapods', '= 1.11.3' gem 'rexml' diff --git a/packages/rn-tester/NativeComponentExample/MyNativeView.podspec b/packages/rn-tester/NativeComponentExample/MyNativeView.podspec index f3cf2720a2c98e..45aee537e34e43 100644 --- a/packages/rn-tester/NativeComponentExample/MyNativeView.podspec +++ b/packages/rn-tester/NativeComponentExample/MyNativeView.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -8,7 +8,7 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "../" "package.json"))) folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' boost_version = '1.76.0' boost_compiler_flags = '-Wno-documentation' @@ -19,12 +19,13 @@ Pod::Spec.new do |s| s.description = "my-native-view" s.homepage = "https://github.com/sota000/my-native-view.git" s.license = "MIT" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' -Wno-nullability-completeness' s.author = "Facebook, Inc. and its affiliates" s.source = { :git => "https://github.com/facebook/my-native-view.git", :tag => "#{s.version}" } s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\"" + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\"", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } s.source_files = "ios/**/*.{h,m,mm,cpp}" diff --git a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.h b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.h index dec55ba5638b3c..6d7adce1eabb5b 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.h +++ b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.mm b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.mm index a8d44c781d7cf4..7fe66d4050d776 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.mm +++ b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -7,10 +7,10 @@ #import "RNTMyNativeViewComponentView.h" -#import -#import -#import -#import +#import +#import +#import +#import #import "RCTFabricComponentsPlugins.h" diff --git a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm index 4257125e186bcd..83d8f231d4259d 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm +++ b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js index b45203adc1a780..373e6d22f856ad 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js index db8e64c12ffcb9..9efe4c3efe645b 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js b/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js index 2cb86684739e9b..60aae1100ada62 100644 --- a/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js +++ b/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -10,17 +10,25 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; +import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes'; + +export type ScreenshotManagerOptions = UnsafeObject; export interface Spec extends TurboModule { +getConstants: () => {||}; - takeSnapshot(id: string): Promise; + takeScreenshot( + id: string, + options: ScreenshotManagerOptions, + ): Promise; } const NativeModule = TurboModuleRegistry.get('ScreenshotManager'); - -export function takeSnapshot(id: string): Promise { +export function takeScreenshot( + id: string, + options: ScreenshotManagerOptions, +): Promise { if (NativeModule != null) { - return NativeModule.takeSnapshot(id); + return NativeModule.takeScreenshot(id, options); } return Promise.reject(); } diff --git a/packages/rn-tester/NativeModuleExample/Screenshot.h b/packages/rn-tester/NativeModuleExample/Screenshot.h index ddd38dab691b5c..fd264c995f6cf7 100644 --- a/packages/rn-tester/NativeModuleExample/Screenshot.h +++ b/packages/rn-tester/NativeModuleExample/Screenshot.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/NativeModuleExample/Screenshot.m b/packages/rn-tester/NativeModuleExample/Screenshot.m index ed61d0ac2886bc..ceb28ac6d0673c 100644 --- a/packages/rn-tester/NativeModuleExample/Screenshot.m +++ b/packages/rn-tester/NativeModuleExample/Screenshot.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -19,65 +19,69 @@ @implementation ScreenshotManager : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject) { - [self.bridge.uiManager - addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { - // Get view - UIView *view; - if (target == nil || [target isEqual:@"window"]) { - view = RCTKeyWindow(); - } else if ([target isKindOfClass:[NSNumber class]]) { - view = viewRegistry[target]; - if (!view) { - RCTLogError(@"No view found with reactTag: %@", target); - return; - } - } + [self.bridge.uiManager addUIBlock:^( + __unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { + // Get view + UIView *view; + if (target == nil || [target isEqual:@"window"]) { + view = RCTKeyWindow(); + } else if ([target isKindOfClass:[NSNumber class]]) { + view = viewRegistry[target]; + if (!view) { + RCTLogError(@"No view found with reactTag: %@", target); + return; + } + } - // Get options - CGSize size = [RCTConvert CGSize:options]; - NSString *format = [RCTConvert NSString:options[@"format"] ?: @"png"]; + // Get options + CGSize size = [RCTConvert CGSize:options]; + NSString *format = [RCTConvert NSString:options[@"format"] ?: @"png"]; - // Capture image - if (size.width < 0.1 || size.height < 0.1) { - size = view.bounds.size; - } - UIGraphicsBeginImageContextWithOptions(size, NO, 0); - BOOL success = [view drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + // Capture image + if (size.width < 0.1 || size.height < 0.1) { + size = view.bounds.size; + } - if (!success || !image) { - reject(RCTErrorUnspecified, @"Failed to capture view snapshot.", nil); - return; - } + UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat]; + UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size format:rendererFormat]; - // Convert image to data (on a background thread) - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSData *data; - if ([format isEqualToString:@"png"]) { - data = UIImagePNGRepresentation(image); - } else if ([format isEqualToString:@"jpeg"]) { - CGFloat quality = [RCTConvert CGFloat:options[@"quality"] ?: @1]; - data = UIImageJPEGRepresentation(image, quality); - } else { - RCTLogError(@"Unsupported image format: %@", format); - return; - } + __block BOOL success = NO; + UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { + success = [view drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES]; + }]; - // Save to a temp file - NSError *error = nil; - NSString *tempFilePath = RCTTempFilePath(format, &error); - if (tempFilePath) { - if ([data writeToFile:tempFilePath options:(NSDataWritingOptions)0 error:&error]) { - resolve(tempFilePath); - return; - } - } + if (!success || !image) { + reject(RCTErrorUnspecified, @"Failed to capture view snapshot.", nil); + return; + } + + // Convert image to data (on a background thread) + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSData *data; + if ([format isEqualToString:@"png"]) { + data = UIImagePNGRepresentation(image); + } else if ([format isEqualToString:@"jpeg"]) { + CGFloat quality = [RCTConvert CGFloat:options[@"quality"] ?: @1]; + data = UIImageJPEGRepresentation(image, quality); + } else { + RCTLogError(@"Unsupported image format: %@", format); + return; + } + + // Save to a temp file + NSError *error = nil; + NSString *tempFilePath = RCTTempFilePath(format, &error); + if (tempFilePath) { + if ([data writeToFile:tempFilePath options:(NSDataWritingOptions)0 error:&error]) { + resolve(tempFilePath); + return; + } + } - // If we reached here, something went wrong - reject(RCTErrorUnspecified, error.localizedDescription, error); - }); - }]; + // If we reached here, something went wrong + reject(RCTErrorUnspecified, error.localizedDescription, error); + }); + }]; } @end diff --git a/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec b/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec index 9d1b4cbf36b077..00cde709b2ffe5 100644 --- a/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec +++ b/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -8,7 +8,7 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "../package.json"))) folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' Pod::Spec.new do |s| s.name = "ScreenshotManager" @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.description = "ScreenshotManager" s.homepage = "https://github.com/facebook/react-native.git" s.license = "MIT" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.author = "Facebook, Inc. and its affiliates" s.source = { :git => "https://github.com/facebook/react-native.git", :tag => "#{s.version}" } @@ -25,7 +25,7 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,mm,swift}" s.requires_arc = true - s.dependency "React" + s.dependency "React-Core" s.dependency "RCT-Folly", folly_version # s.dependency "..." diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 239d7b4f1c71e6..d50d388be19208 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -1,36 +1,51 @@ require_relative '../../scripts/react_native_pods' source 'https://cdn.cocoapods.org/' -platform :ios, '11.0' +platform :ios, '12.4' # Temporary solution to suppress duplicated GUID error. # Can be removed once we move to generate files outside pod install. install! 'cocoapods', :deterministic_uuids => false USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1' +IN_CI = ENV['CI'] == 'true' + +@prefix_path = "../.." if USE_FRAMEWORKS puts "Installing pods with use_frameworks!" use_frameworks! end -if ENV['USE_HERMES'] == '1' - puts "Using Hermes engine" -end - -def pods() +def pods(options = {}, use_flipper: false) project 'RNTesterPods.xcodeproj' fabric_enabled = true - puts "Building RNTester with Fabric #{fabric_enabled ? "enabled" : "disabled"}." - prefix_path = "../.." - use_react_native!(path: prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: ENV['USE_HERMES'] == '1') - pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon" + # Hermes is now enabled by default. + # The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0). + hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1' + puts "Building RNTester with Fabric #{fabric_enabled ? "enabled" : "disabled"}.#{hermes_enabled ? " Using Hermes engine." : ""}" + + if ENV['RCT_NEW_ARCH_ENABLED'] == '1' + # Custom fabric component is only supported when using codegen discovery. + pod 'MyNativeView', :path => "NativeComponentExample" + end + + use_react_native!( + path: @prefix_path, + fabric_enabled: fabric_enabled, + hermes_enabled: hermes_enabled, + flipper_configuration: use_flipper ? FlipperConfiguration.enabled : FlipperConfiguration.disabled, + app_path: "#{Dir.pwd}", + config_file_dir: "#{Dir.pwd}/node_modules", + production: !ENV['PRODUCTION'].nil? + ) + pod 'ReactCommon/turbomodule/samples', :path => "#{@prefix_path}/ReactCommon" # Additional Pods which aren't included in the default Podfile - pod 'React-RCTPushNotification', :path => "#{prefix_path}/Libraries/PushNotificationIOS" - pod 'Yoga', :path => "#{prefix_path}/ReactCommon/yoga", :modular_headers => true + pod 'React-RCTPushNotification', :path => "#{@prefix_path}/Libraries/PushNotificationIOS" + pod 'Yoga', :path => "#{@prefix_path}/ReactCommon/yoga", :modular_headers => true # Additional Pods which are classed as unstable # RNTester native modules and components @@ -38,10 +53,7 @@ def pods() end target 'RNTester' do - pods() - if !USE_FRAMEWORKS - use_flipper! - end + pods({}, :use_flipper => !IN_CI && !USE_FRAMEWORKS) end target 'RNTesterUnitTests' do @@ -55,6 +67,6 @@ target 'RNTesterIntegrationTests' do end post_install do |installer| - react_native_post_install(installer) + react_native_post_install(installer, @prefix_path, :mac_catalyst_enabled => false) __apply_Xcode_12_5_M1_post_install_workaround(installer) end diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 518392bdf56f6d..824da7bca361aa 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -4,88 +4,89 @@ PODS: - DoubleConversion (1.1.6) - FBLazyVector (1000.0.0) - FBReactNativeSpec (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-Core (= 1000.0.0) - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - - Flipper (0.99.0): + - Flipper (0.125.0): - Flipper-Folly (~> 2.6) - Flipper-RSocket (~> 1.4) - Flipper-Boost-iOSX (1.76.0.1.11) - - Flipper-DoubleConversion (3.1.7) + - Flipper-DoubleConversion (3.2.0.1) - Flipper-Fmt (7.1.7) - - Flipper-Folly (2.6.7): + - Flipper-Folly (2.6.10): - Flipper-Boost-iOSX - Flipper-DoubleConversion - Flipper-Fmt (= 7.1.7) - Flipper-Glog - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.180) - - Flipper-Glog (0.3.9) + - OpenSSL-Universal (= 1.1.1100) + - Flipper-Glog (0.5.0.5) - Flipper-PeerTalk (0.0.4) - Flipper-RSocket (1.4.3): - Flipper-Folly (~> 2.6) - - FlipperKit (0.99.0): - - FlipperKit/Core (= 0.99.0) - - FlipperKit/Core (0.99.0): - - Flipper (~> 0.99.0) + - FlipperKit (0.125.0): + - FlipperKit/Core (= 0.125.0) + - FlipperKit/Core (0.125.0): + - Flipper (~> 0.125.0) - FlipperKit/CppBridge - FlipperKit/FBCxxFollyDynamicConvert - FlipperKit/FBDefines - FlipperKit/FKPortForwarding - - FlipperKit/CppBridge (0.99.0): - - Flipper (~> 0.99.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.99.0): + - SocketRocket (~> 0.6.0) + - FlipperKit/CppBridge (0.125.0): + - Flipper (~> 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (0.125.0): - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.99.0) - - FlipperKit/FKPortForwarding (0.99.0): + - FlipperKit/FBDefines (0.125.0) + - FlipperKit/FKPortForwarding (0.125.0): - CocoaAsyncSocket (~> 7.6) - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.99.0) - - FlipperKit/FlipperKitLayoutHelpers (0.99.0): + - FlipperKit/FlipperKitHighlightOverlay (0.125.0) + - FlipperKit/FlipperKitLayoutHelpers (0.125.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.99.0): + - FlipperKit/FlipperKitLayoutIOSDescriptors (0.125.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutPlugin (0.99.0): + - FlipperKit/FlipperKitLayoutPlugin (0.125.0): - FlipperKit/Core - FlipperKit/FlipperKitHighlightOverlay - FlipperKit/FlipperKitLayoutHelpers - FlipperKit/FlipperKitLayoutIOSDescriptors - FlipperKit/FlipperKitLayoutTextSearchable - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutTextSearchable (0.99.0) - - FlipperKit/FlipperKitNetworkPlugin (0.99.0): + - FlipperKit/FlipperKitLayoutTextSearchable (0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (0.125.0): - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.99.0): + - FlipperKit/FlipperKitReactPlugin (0.125.0): - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.99.0): + - FlipperKit/FlipperKitUserDefaultsPlugin (0.125.0): - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.99.0): + - FlipperKit/SKIOSNetworkPlugin (0.125.0): - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - libevent (2.1.12) - - OpenSSL-Universal (1.1.180) - - RCT-Folly (2021.06.28.00-v2): + - OpenSSL-Universal (1.1.1100) + - RCT-Folly (2021.07.22.00): - boost - DoubleConversion - fmt (~> 6.2.1) - glog - - RCT-Folly/Default (= 2021.06.28.00-v2) - - RCT-Folly/Default (2021.06.28.00-v2): + - RCT-Folly/Default (= 2021.07.22.00) + - RCT-Folly/Default (2021.07.22.00): - boost - DoubleConversion - fmt (~> 6.2.1) - glog - - RCT-Folly/Fabric (2021.06.28.00-v2): + - RCT-Folly/Fabric (2021.07.22.00): - boost - DoubleConversion - fmt (~> 6.2.1) @@ -93,7 +94,6 @@ PODS: - RCTRequired (1000.0.0) - RCTTypeSafety (1000.0.0): - FBLazyVector (= 1000.0.0) - - RCT-Folly (= 2021.06.28.00-v2) - RCTRequired (= 1000.0.0) - React-Core (= 1000.0.0) - React (1000.0.0): @@ -109,10 +109,13 @@ PODS: - React-RCTSettings (= 1000.0.0) - React-RCTText (= 1000.0.0) - React-RCTVibration (= 1000.0.0) + - React-bridging (1000.0.0): + - RCT-Folly (= 2021.07.22.00) + - React-jsi (= 1000.0.0) - React-callinvoker (1000.0.0) - React-Codegen (1000.0.0): - FBReactNativeSpec (= 1000.0.0) - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-Core (= 1000.0.0) @@ -123,7 +126,7 @@ PODS: - ReactCommon/turbomodule/core (= 1000.0.0) - React-Core (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default (= 1000.0.0) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -132,7 +135,7 @@ PODS: - Yoga - React-Core/CoreModulesHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -141,7 +144,7 @@ PODS: - Yoga - React-Core/Default (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) @@ -149,7 +152,7 @@ PODS: - Yoga - React-Core/DevSupport (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default (= 1000.0.0) - React-Core/RCTWebSocket (= 1000.0.0) - React-cxxreact (= 1000.0.0) @@ -160,7 +163,7 @@ PODS: - Yoga - React-Core/RCTActionSheetHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -169,7 +172,7 @@ PODS: - Yoga - React-Core/RCTAnimationHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -178,7 +181,7 @@ PODS: - Yoga - React-Core/RCTBlobHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -187,7 +190,7 @@ PODS: - Yoga - React-Core/RCTImageHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -196,7 +199,7 @@ PODS: - Yoga - React-Core/RCTLinkingHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -205,7 +208,7 @@ PODS: - Yoga - React-Core/RCTNetworkHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -214,7 +217,7 @@ PODS: - Yoga - React-Core/RCTPushNotificationHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -223,7 +226,7 @@ PODS: - Yoga - React-Core/RCTSettingsHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -232,7 +235,7 @@ PODS: - Yoga - React-Core/RCTTextHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -241,7 +244,7 @@ PODS: - Yoga - React-Core/RCTVibrationHeaders (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -250,7 +253,7 @@ PODS: - Yoga - React-Core/RCTWebSocket (1000.0.0): - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core/Default (= 1000.0.0) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -258,7 +261,7 @@ PODS: - React-perflogger (= 1000.0.0) - Yoga - React-CoreModules (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTTypeSafety (= 1000.0.0) - React-Codegen (= 1000.0.0) - React-Core/CoreModulesHeaders (= 1000.0.0) @@ -269,7 +272,7 @@ PODS: - boost (= 1.76.0) - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-callinvoker (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsinspector (= 1000.0.0) @@ -277,12 +280,12 @@ PODS: - React-perflogger (= 1000.0.0) - React-runtimeexecutor (= 1000.0.0) - React-Fabric (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-Fabric/animations (= 1000.0.0) - React-Fabric/attributedstring (= 1000.0.0) - - React-Fabric/better (= 1000.0.0) + - React-Fabric/butter (= 1000.0.0) - React-Fabric/componentregistry (= 1000.0.0) - React-Fabric/componentregistrynative (= 1000.0.0) - React-Fabric/components (= 1000.0.0) @@ -305,7 +308,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/animations (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -313,15 +316,15 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/attributedstring (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - - React-Fabric/better (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - React-Fabric/butter (1000.0.0): + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -329,7 +332,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/componentregistry (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -337,7 +340,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/componentregistrynative (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -345,7 +348,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-Fabric/components/activityindicator (= 1000.0.0) @@ -366,7 +369,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/activityindicator (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -374,7 +377,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/image (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -382,7 +385,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/inputaccessory (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -390,7 +393,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/legacyviewmanagerinterop (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -398,7 +401,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/modal (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -406,7 +409,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/root (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -414,7 +417,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/safeareaview (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -422,7 +425,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/scrollview (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -430,7 +433,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/slider (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -438,7 +441,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/text (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -446,7 +449,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/textinput (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -454,7 +457,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/unimplementedview (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -462,7 +465,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/components/view (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -471,7 +474,7 @@ PODS: - ReactCommon/turbomodule/core (= 1000.0.0) - Yoga - React-Fabric/config (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -479,7 +482,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/core (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -487,7 +490,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/debug_core (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -495,7 +498,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/debug_renderer (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -503,7 +506,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/imagemanager (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -512,7 +515,7 @@ PODS: - React-RCTImage (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/leakchecker (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -520,7 +523,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/mounting (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -528,7 +531,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/runtimescheduler (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -536,7 +539,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/scheduler (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -544,7 +547,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/telemetry (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -552,7 +555,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/templateprocessor (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -560,7 +563,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/textlayoutmanager (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-Fabric/uimanager @@ -569,7 +572,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/uimanager (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -577,7 +580,7 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-Fabric/utils (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - RCTRequired (= 1000.0.0) - RCTTypeSafety (= 1000.0.0) - React-graphics (= 1000.0.0) @@ -585,28 +588,28 @@ PODS: - React-jsiexecutor (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-graphics (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - React-Core/Default (= 1000.0.0) - React-jsi (1000.0.0): - boost (= 1.76.0) - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-jsi/Default (= 1000.0.0) - React-jsi/Default (1000.0.0): - boost (= 1.76.0) - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-jsi/Fabric (1000.0.0): - boost (= 1.76.0) - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-jsiexecutor (1000.0.0): - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-perflogger (= 1000.0.0) @@ -617,14 +620,14 @@ PODS: - React-RCTActionSheet (1000.0.0): - React-Core/RCTActionSheetHeaders (= 1000.0.0) - React-RCTAnimation (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTTypeSafety (= 1000.0.0) - React-Codegen (= 1000.0.0) - React-Core/RCTAnimationHeaders (= 1000.0.0) - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTBlob (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Codegen (= 1000.0.0) - React-Core/RCTBlobHeaders (= 1000.0.0) - React-Core/RCTWebSocket (= 1000.0.0) @@ -632,12 +635,12 @@ PODS: - React-RCTNetwork (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTFabric (1000.0.0): - - RCT-Folly/Fabric (= 2021.06.28.00-v2) + - RCT-Folly/Fabric (= 2021.07.22.00) - React-Core (= 1000.0.0) - React-Fabric (= 1000.0.0) - React-RCTImage (= 1000.0.0) - React-RCTImage (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTTypeSafety (= 1000.0.0) - React-Codegen (= 1000.0.0) - React-Core/RCTImageHeaders (= 1000.0.0) @@ -650,7 +653,7 @@ PODS: - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTNetwork (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTTypeSafety (= 1000.0.0) - React-Codegen (= 1000.0.0) - React-Core/RCTNetworkHeaders (= 1000.0.0) @@ -663,14 +666,14 @@ PODS: - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTSettings (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - RCTTypeSafety (= 1000.0.0) - React-Codegen (= 1000.0.0) - React-Core/RCTSettingsHeaders (= 1000.0.0) - React-jsi (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTTest (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Core (= 1000.0.0) - React-CoreModules (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -678,7 +681,7 @@ PODS: - React-RCTText (1000.0.0): - React-Core/RCTTextHeaders (= 1000.0.0) - React-RCTVibration (1000.0.0): - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) - React-Codegen (= 1000.0.0) - React-Core/RCTVibrationHeaders (= 1000.0.0) - React-jsi (= 1000.0.0) @@ -689,7 +692,8 @@ PODS: - ReactCommon/turbomodule/core (1000.0.0): - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) + - React-bridging (= 1000.0.0) - React-callinvoker (= 1000.0.0) - React-Core (= 1000.0.0) - React-cxxreact (= 1000.0.0) @@ -699,7 +703,8 @@ PODS: - ReactCommon/turbomodule/samples (1000.0.0): - DoubleConversion - glog - - RCT-Folly (= 2021.06.28.00-v2) + - RCT-Folly (= 2021.07.22.00) + - React-bridging (= 1000.0.0) - React-callinvoker (= 1000.0.0) - React-Core (= 1000.0.0) - React-cxxreact (= 1000.0.0) @@ -708,8 +713,9 @@ PODS: - React-perflogger (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - ScreenshotManager (0.0.1): - - RCT-Folly (= 2021.06.28.00-v2) - - React + - RCT-Folly (= 2021.07.22.00) + - React-Core + - SocketRocket (0.6.0) - Yoga (1.14.0) - YogaKit (1.18.1): - Yoga (~> 1.14) @@ -719,34 +725,35 @@ DEPENDENCIES: - DoubleConversion (from `../../third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../../Libraries/FBLazyVector`) - FBReactNativeSpec (from `../../React/FBReactNativeSpec`) - - Flipper (= 0.99.0) + - Flipper (= 0.125.0) - Flipper-Boost-iOSX (= 1.76.0.1.11) - - Flipper-DoubleConversion (= 3.1.7) + - Flipper-DoubleConversion (= 3.2.0.1) - Flipper-Fmt (= 7.1.7) - - Flipper-Folly (= 2.6.7) - - Flipper-Glog (= 0.3.9) + - Flipper-Folly (= 2.6.10) + - Flipper-Glog (= 0.5.0.5) - Flipper-PeerTalk (= 0.0.4) - Flipper-RSocket (= 1.4.3) - - FlipperKit (= 0.99.0) - - FlipperKit/Core (= 0.99.0) - - FlipperKit/CppBridge (= 0.99.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.99.0) - - FlipperKit/FBDefines (= 0.99.0) - - FlipperKit/FKPortForwarding (= 0.99.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.99.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.99.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.99.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.99.0) - - FlipperKit/FlipperKitReactPlugin (= 0.99.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.99.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.99.0) + - FlipperKit (= 0.125.0) + - FlipperKit/Core (= 0.125.0) + - FlipperKit/CppBridge (= 0.125.0) + - FlipperKit/FBCxxFollyDynamicConvert (= 0.125.0) + - FlipperKit/FBDefines (= 0.125.0) + - FlipperKit/FKPortForwarding (= 0.125.0) + - FlipperKit/FlipperKitHighlightOverlay (= 0.125.0) + - FlipperKit/FlipperKitLayoutPlugin (= 0.125.0) + - FlipperKit/FlipperKitLayoutTextSearchable (= 0.125.0) + - FlipperKit/FlipperKitNetworkPlugin (= 0.125.0) + - FlipperKit/FlipperKitReactPlugin (= 0.125.0) + - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) + - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) - glog (from `../../third-party-podspecs/glog.podspec`) - - OpenSSL-Universal (= 1.1.180) + - OpenSSL-Universal (= 1.1.1100) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCT-Folly/Fabric (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) - RCTTypeSafety (from `../../Libraries/TypeSafety`) - React (from `../../`) + - React-bridging (from `../../ReactCommon/react/bridging`) - React-callinvoker (from `../../ReactCommon/callinvoker`) - React-Codegen (from `build/generated/ios`) - React-Core (from `../../`) @@ -796,6 +803,7 @@ SPEC REPOS: - fmt - libevent - OpenSSL-Universal + - SocketRocket - YogaKit EXTERNAL SOURCES: @@ -817,6 +825,8 @@ EXTERNAL SOURCES: :path: "../../Libraries/TypeSafety" React: :path: "../../" + React-bridging: + :path: "../../ReactCommon/react/bridging" React-callinvoker: :path: "../../ReactCommon/callinvoker" React-Codegen: @@ -879,57 +889,59 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 - FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949 - FBReactNativeSpec: 755b7fee1b08aefd74fb2fa9f7312b253719d536 - Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733 + DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 + FBLazyVector: 19e408e76fa9258dd32191a50d60c41444f52d29 + FBReactNativeSpec: a9bf67b4be55c0819bc88e1721820286c1340710 + Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c - Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c + Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b - Flipper-Folly: 83af37379faa69497529e414bd43fbfc7cae259a - Flipper-Glog: 05579840e2750ec907ee2f81544f41ad76a7cae4 + Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 + Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 - FlipperKit: d8d346844eca5d9120c17d441a2f38596e8ed2b9 + FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: c10b67b343303f51715e5c5eedb18a41402f350a + glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b - RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685 - RCTRequired: af2d6080a4b9ba0885b28ca78879a92066c71cab - RCTTypeSafety: c7a7f67ae5b1b986b78d817baa408fc984ab7c0c - React: f64c9f6db5428717922a3292ba6a448615a2e143 - React-callinvoker: c5d61e29df57793f0dc10ec2bc01c846f863e51f - React-Codegen: 2256e335ccce7326eeca6d7a668e05c4de259289 - React-Core: 22bc86b79dd931dbfb7fd2af91a35a98d41ceb64 - React-CoreModules: a8e2bdc1ebbf8d440478456197abd58d1691f61a - React-cxxreact: cfc1663dae1ea52b465bbf021ef7b1527c5dc80c - React-Fabric: 002345cff43721617e0a3c0866f6f76bae8c50ff - React-graphics: 9a84942b49ea1375ce83844041fa2ba766cfe0b9 - React-jsi: c1c0108d86e1378aabf7c9146ed7d12d87c7df85 - React-jsiexecutor: d08ec14edc8f2e19af51550cd1505332eae35c7b - React-jsinspector: 7d223826b0e7a61b3540c21b9eca2603b1d4e823 - React-logger: 2009c0280c286a76200d6b7c5fe242fad51ddd7a - React-perflogger: fe66bd6d8b17ebcfdf0159bf41fe28d8035ac20c - React-RCTActionSheet: 3131a0b9280aa0e51bdf54b3d79aecd8503db62c - React-RCTAnimation: 70f2b9daaa1b45dea608be865cc5f2e1789dbc39 - React-RCTBlob: 48cae62d905ef96ab10c84ab16163643a3c872a7 - React-RCTFabric: c126a269f6279896e19e133d6b1e019fa2f0f028 - React-RCTImage: 2ce3f1f72de91798eb31c9001b30cab8d1c71c4e - React-RCTLinking: 77300bd3cda2a613845ae0056b62ad330c2d319d - React-RCTNetwork: 8ef793740f893987384918e04382d37fac36960d - React-RCTPushNotification: 1845de920c2583f4541e13b3e9bd20a2ba896ffa - React-RCTSettings: 2beadc19336aa83a49e9ee9f704157c64799e840 - React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6 - React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7 - React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa - React-rncore: d09af3a25cbff0b484776785676c28f3729e07f5 - React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3 - ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569 - ScreenshotManager: e8a3fc9b2e24b81127b36cb4ebe0eed65090c949 - Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75 + OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c + RCT-Folly: 9638863070ed4e7b2be5e91385745a0ad741e9c1 + RCTRequired: 1c8808cf84569265784a6c33984bbb506ada8c6e + RCTTypeSafety: b6dcb5036a808864ee8cad66ca15f263c24661cc + React: 8d809d414723bb5763093ddec7658066a21ccabc + React-bridging: 3ba3efbd3a2d7d99aad5658b8e48b1c134c16ecf + React-callinvoker: 5f16202ad4e45f0607b1fae0f6955a8f7c87eef1 + React-Codegen: 5adf19af97eb37a7d441c040521191e446255086 + React-Core: 0cfb25c65d4dcb856b1807fe44a1ebe5e7ec9749 + React-CoreModules: 675170bccf156da3a3348e04e2036ce401b2010d + React-cxxreact: 7276467c246302fedf598cc40d7003896ddb20ba + React-Fabric: abfd61dc5498ce165634af85d65fcc42b82b5bf4 + React-graphics: 5ccc9cc0d91794fd42bc1c693e9aea207554bbef + React-jsi: a042596cb558abea721ab5e23cb175647610a73d + React-jsiexecutor: f7fbac5dff7e7ff110a66edf2626b4f4f4600ef5 + React-jsinspector: 7733dd522d044aef87caa39f3eda77593358a7eb + React-logger: c7960346b021767ed90971aff592a44e3d69f8bb + React-perflogger: c4fdd48988c2d3047186fc1bc1772d634cfca2ea + React-RCTActionSheet: 166fd1df85ac10219466b45d12a5884d3eaceac1 + React-RCTAnimation: d6127046c6bb44bd3e67b7503c4ad7f91131b58e + React-RCTBlob: 68675c89ebe6edf310dddd0774ba07b685f090a9 + React-RCTFabric: a98a6effece6719669b8c6b4d2c33fb0edddc613 + React-RCTImage: 6de9f0f4402af859849e97cc73a56a52f400f4c9 + React-RCTLinking: 21bb4675c3ec8fe704672ea511e817aeb3bf8370 + React-RCTNetwork: a865deadacbf6b3d863f0496e7d2c2e81c269317 + React-RCTPushNotification: 7f678a88147254ede5d21a1e1e71e8a964dd0051 + React-RCTSettings: 23ce1aa52ddf5db44c973bb5cc93713e871e09b6 + React-RCTTest: 06c388632dc7b30df17af01c8f9e89e641b4d31c + React-RCTText: a861fbf2835299d3cc4189697cddd8bd8602afb9 + React-RCTVibration: 0386f50996a153b3f39cecbe7d139763ac9a9fdf + React-rncore: 6daa27c74047a9e13ce3412b99660274a5780603 + React-runtimeexecutor: 97dca9247f4d3cfe0733384b189c6930fbd402b7 + ReactCommon: a34f02c7251e6725e744167b9381d5dd9d016591 + ScreenshotManager: 71d047abd38a77310985b87f8136b620c5c61e88 + SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 + Yoga: 1b1a12ff3d86a10565ea7cbe057d42f5e5fb2a07 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: eb8cf8c55af63e11cb1907f2ae6b457739f4f0af +PODFILE CHECKSUM: e067e04e7697dc3cd3d3fbd7556f77c6eccf8075 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h index 2d36c53d22e3bd..327e3972d97406 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m index f207384e9bb103..9e5a14c2c3e21f 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h index d7b1b51fe48a5b..f220d0fd6fd057 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m index 308029d9e2e88b..3aefe13faf7f2d 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -208,7 +208,7 @@ - (BOOL)compareReferenceImage:(UIImage *)referenceImage toImage:(UIImage *)image #pragma mark - Private API -typedef NS_ENUM(NSUInteger, FBTestSnapshotFileNameType) { +typedef NS_ENUM(NSInteger, FBTestSnapshotFileNameType) { FBTestSnapshotFileNameTypeReference, FBTestSnapshotFileNameTypeFailedReference, FBTestSnapshotFileNameTypeFailedTest, @@ -325,23 +325,14 @@ - (UIImage *)_snapshotView:(UIView *)view NSAssert1(CGRectGetWidth(bounds), @"Zero width for view %@", view); NSAssert1(CGRectGetHeight(bounds), @"Zero height for view %@", view); - UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); - CGContextRef context = UIGraphicsGetCurrentContext(); - NSAssert1(context, @"Could not generate context for view %@", view); + UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat]; + UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:bounds.size + format:rendererFormat]; - UIGraphicsPushContext(context); - CGContextSaveGState(context); - { + return [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { BOOL success = [view drawViewHierarchyInRect:bounds afterScreenUpdates:YES]; NSAssert1(success, @"Could not create snapshot for view %@", view); - } - CGContextRestoreGState(context); - UIGraphicsPopContext(); - - UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return snapshot; + }]; } @end diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.h b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.h index 3ab1d8c2fb1468..e84bbc6ea99592 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.h +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m index 585b6b2f5b1b05..2ddf514138d0d1 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.h b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.h index b67cdf65e761e7..4bf6f527846ec6 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.h +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.m index 20a45ce909f4ce..5713d4b74c5ef8 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Diff.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -15,19 +15,22 @@ - (UIImage *)diffWithImage:(UIImage *)image return nil; } CGSize imageSize = CGSizeMake(MAX(self.size.width, image.size.width), MAX(self.size.height, image.size.height)); - UIGraphicsBeginImageContextWithOptions(imageSize, YES, 0.0); - CGContextRef context = UIGraphicsGetCurrentContext(); - [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)]; - CGContextSetAlpha(context, 0.5f); - CGContextBeginTransparencyLayer(context, NULL); - [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; - CGContextSetBlendMode(context, kCGBlendModeDifference); - CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); - CGContextFillRect(context, CGRectMake(0, 0, self.size.width, self.size.height)); - CGContextEndTransparencyLayer(context); - UIImage *returnImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return returnImage; + + UIGraphicsImageRendererFormat *const rendererFormat = [UIGraphicsImageRendererFormat defaultFormat]; + rendererFormat.opaque = YES; + UIGraphicsImageRenderer *const renderer = [[UIGraphicsImageRenderer alloc] initWithSize:imageSize + format:rendererFormat]; + + return [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { + [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)]; + CGContextSetAlpha(context.CGContext, 0.5f); + CGContextBeginTransparencyLayer(context.CGContext, NULL); + [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; + CGContextSetBlendMode(context.CGContext, kCGBlendModeDifference); + CGContextSetFillColorWithColor(context.CGContext, [UIColor whiteColor].CGColor); + CGContextFillRect(context.CGContext, CGRectMake(0, 0, self.size.width, self.size.height)); + CGContextEndTransparencyLayer(context.CGContext); + }]; } @end diff --git a/packages/rn-tester/RCTTest/RCTSnapshotManager.h b/packages/rn-tester/RCTTest/RCTSnapshotManager.h index 34396dad6cafc2..4cd67c2a142506 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotManager.h +++ b/packages/rn-tester/RCTTest/RCTSnapshotManager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTSnapshotManager.m b/packages/rn-tester/RCTTest/RCTSnapshotManager.m index 226af5998d556c..7b17622015af6c 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotManager.m +++ b/packages/rn-tester/RCTTest/RCTSnapshotManager.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js index e10b75c7e17804..ede6b04270032e 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js +++ b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestModule.h b/packages/rn-tester/RCTTest/RCTTestModule.h index 2dbfbb568f5c60..5f60be764db2e0 100644 --- a/packages/rn-tester/RCTTest/RCTTestModule.h +++ b/packages/rn-tester/RCTTest/RCTTestModule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestModule.mm b/packages/rn-tester/RCTTest/RCTTestModule.mm index 7ab48b726d6bb7..ab797d55f893e0 100644 --- a/packages/rn-tester/RCTTest/RCTTestModule.mm +++ b/packages/rn-tester/RCTTest/RCTTestModule.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestPlugins.h b/packages/rn-tester/RCTTest/RCTTestPlugins.h index 1572f3a603a1a4..755019513d4a85 100644 --- a/packages/rn-tester/RCTTest/RCTTestPlugins.h +++ b/packages/rn-tester/RCTTest/RCTTestPlugins.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestPlugins.mm b/packages/rn-tester/RCTTest/RCTTestPlugins.mm index a057177b619d66..aee79a0764bfef 100644 --- a/packages/rn-tester/RCTTest/RCTTestPlugins.mm +++ b/packages/rn-tester/RCTTest/RCTTestPlugins.mm @@ -1,5 +1,5 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestRunner.h b/packages/rn-tester/RCTTest/RCTTestRunner.h index 3266eb7b6b1ae3..5fb15bd2e3bceb 100644 --- a/packages/rn-tester/RCTTest/RCTTestRunner.h +++ b/packages/rn-tester/RCTTest/RCTTestRunner.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/RCTTestRunner.m b/packages/rn-tester/RCTTest/RCTTestRunner.m index daa047dfcd2aeb..7f95689af57f4d 100644 --- a/packages/rn-tester/RCTTest/RCTTestRunner.m +++ b/packages/rn-tester/RCTTest/RCTTestRunner.m @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RCTTest/React-RCTTest.podspec b/packages/rn-tester/RCTTest/React-RCTTest.podspec index 2259cd6f87076d..f6836ca2fa1e2d 100644 --- a/packages/rn-tester/RCTTest/React-RCTTest.podspec +++ b/packages/rn-tester/RCTTest/React-RCTTest.podspec @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# 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. @@ -17,7 +17,7 @@ else end folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -folly_version = '2021.06.28.00-v2' +folly_version = '2021.07.22.00' Pod::Spec.new do |s| s.name = "React-RCTTest" @@ -26,7 +26,7 @@ Pod::Spec.new do |s| s.homepage = "https://reactnative.dev/" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" - s.platforms = { :ios => "11.0", :tvos => "11.0" } + s.platforms = { :ios => "12.4", :tvos => "12.4" } s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source s.source_files = "**/*.{h,m,mm}" @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.header_dir = "RCTTest" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\"" } diff --git a/packages/rn-tester/README.md b/packages/rn-tester/README.md index 087f0cf35872bd..688b061cbe8f9f 100644 --- a/packages/rn-tester/README.md +++ b/packages/rn-tester/README.md @@ -12,29 +12,44 @@ Before running the app, make sure you ran: ### Running on iOS -If you are testing non-fabric component, modify [the fabric_enabled flag in RNTester's Podfile](https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L21). +If you are testing non-fabric component, modify [the fabric_enabled flag in RNTester's Podfile](https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L24). ```ruby fabric_enabled = false ``` +Also, if you previously built RNTester with fabric enabled, you might need to clean up the build files and Pods. +```sh +# Clean the generated files and folders to clean install RNTester +cd packages/rn-tester +yarn clean-ios +``` + +If you are still having a problem after doing the clean up (which can happen if you have built RNTester with older React Native versions where files were generated inside the react-native folder.), the best way might be to clean-install react-native (e.g. remove node_modules and yarn install). + Both macOS and Xcode are required. -- `cd packages/rn-tester` -- Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally. -- Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` instead. -- Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly. +1. `cd packages/rn-tester` +1. Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally. +1. Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install` or `yarn setup-ios-hermes`. In order to use JSC instead of Hermes engine, run: `USE_HERMES=0 bundle exec pod install` or `yarn setup-ios-jsc` instead. +1. Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly. + +#### Note for M1 users +If you own a Mac M1 laptop, you need to run some different commands to install and run cocoapods. + +- `sudo arch -x86_64 gem install ffi`: this installs the `ffi` package to load dynamically-linked libraries. +- `arch -x86_64 pod install`: this run `pod install` with the right architecture. ### Running on Android -You'll need to have all the [prerequisites](https://github.com/facebook/react-native/wiki/Building-from-source#prerequisites) (SDK, NDK) for Building React Native installed. +You'll need to have all the [prerequisites](https://reactnative.dev/contributing/how-to-build-from-source#prerequisites) (SDK, NDK) for Building React Native installed. Start an Android emulator. ```sh -cd react-native -# In order to use Hermes engine, run `installHermesDebug` instead. -./gradlew :packages:rn-tester:android:app:installJscDebug -./scripts/packager.sh +cd packages/rn-tester +# In order to use Hermes engine, run `yarn install-android-hermes` instead. +yarn install-android-jsc +yarn start ``` _Note: Building for the first time can take a while._ @@ -58,29 +73,6 @@ Run the following commands from the react-native folder: _Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._ -## Running Detox Tests on iOS - -Install Detox from [here](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md). - -To run the e2e tests locally, run the following commands from the react-native folder: - - yarn build-ios-e2e - yarn test-ios-e2e - -These are the equivalent of running: - - detox build -c ios.sim.release - detox test -c ios.sim.release --cleanup - -These build the app in Release mode, so the production code is bundled and included in the built app. - -When developing E2E tests, you may want to run in development mode, so that changes to the production code show up immediately. To do this, run: - - detox build -c ios.sim.debug - detox test -c ios.sim.debug - -You will also need to have Metro running in another terminal. Note that if you've previously run the E2E tests in release mode, you may need to delete the `RNTester/build` folder before rerunning `detox build`. - ## Building from source Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo. diff --git a/packages/rn-tester/RNTester/AppDelegate.h b/packages/rn-tester/RNTester/AppDelegate.h index 98a3c182e51d64..55625d8693c2a8 100644 --- a/packages/rn-tester/RNTester/AppDelegate.h +++ b/packages/rn-tester/RNTester/AppDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index c34703b5570eee..2d1b676a5ec846 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * 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. @@ -77,6 +77,8 @@ @interface AppDelegate () } @end +static NSString *const kRNConcurrentRoot = @"concurrentRoot"; + @implementation AppDelegate - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions @@ -86,12 +88,7 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; // Appetizer.io params check - NSDictionary *initProps = @{}; - NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"]; - if (_routeUri) { - initProps = - @{@"exampleFromAppetizeParams" : [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]}; - } + NSDictionary *initProps = [self prepareInitialProps]; #ifdef RN_FABRIC_ENABLED _contextContainer = std::make_shared(); @@ -119,10 +116,31 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith return YES; } +- (BOOL)concurrentRootEnabled +{ + // Switch this bool to turn on and off the concurrent root + return true; +} + +- (NSDictionary *)prepareInitialProps +{ + NSMutableDictionary *initProps = [NSMutableDictionary new]; + + NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"]; + if (_routeUri) { + initProps[@"exampleFromAppetizeParams"] = [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]; + } + +#ifdef RCT_NEW_ARCH_ENABLED + initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); +#endif + + return initProps; +} + - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/rn-tester/js/RNTesterApp.ios" - fallbackResource:nil]; + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/rn-tester/js/RNTesterApp.ios"]; } - (void)initializeFlipper:(UIApplication *)application diff --git a/packages/rn-tester/RNTester/LaunchScreen.storyboard b/packages/rn-tester/RNTester/LaunchScreen.storyboard index 373f89ee18c77e..cddf99f518c6b9 100644 --- a/packages/rn-tester/RNTester/LaunchScreen.storyboard +++ b/packages/rn-tester/RNTester/LaunchScreen.storyboard @@ -28,7 +28,7 @@ -