diff --git a/.circleci/config.yml b/.circleci/config.yml index b9056680af6708..7452d4bd43a7b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,11 +1,10 @@ aliases: # Cache Management - - &restore-yarn-cache + - &restore-cache-yarn keys: - v1-yarn-{{ arch }}-{{ checksum "package.json" }} - # Fallback in case checksum fails - v1-yarn-{{ arch }}- - - &save-yarn-cache + - &save-cache-yarn paths: - node_modules - ~/.cache/yarn @@ -14,7 +13,6 @@ aliases: - &restore-cache-analysis keys: - v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }} - # Fallback in case checksum fails - v1-analysis-dependencies-{{ arch }}- - &save-cache-analysis paths: @@ -24,29 +22,55 @@ aliases: - &restore-cache-android-packages keys: - - v2-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} - # Fallback in case checksum fails - - v2-android-sdkmanager-packages-{{ arch }}- + - v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }} + - v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha- - &save-cache-android-packages paths: - /opt/android/sdk - key: v2-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} + key: v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }} + + - &restore-cache-gradle + keys: + - v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} + # Fallback in case checksum fails + - v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}- + - v1-gradle-{{ arch }}-{{ .Branch }}- + # Fallback in case this is a first-time run on a fork + - v1-gradle-{{ arch }}-master- + - &save-cache-gradle + paths: + - ~/.gradle + key: v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} + + - &restore-cache-apt + keys: + - v1-apt-{{ arch }}-{{ .Branch }}-{{ checksum "scripts/circleci/apt-get-android-deps.sh" }} + # Fallback in case checksum fails + - v1-apt-{{ arch }}-{{ .Branch }}- + # Fallback in case this is a first-time run on a fork + - v1-apt-{{ arch }}-master- + - &save-cache-apt + paths: + - ~/vendor/apt + key: v1-apt-{{ arch }}-{{ .Branch }}-{{ checksum "scripts/circleci/apt-get-android-deps.sh" }} - &restore-cache-ndk keys: - - v1-android-ndk-{{ arch }}-r10e-32-64 + - v3-android-ndk-{{ arch }}-r10e-{{ checksum "scripts/circle-ci-android-setup.sh" }} + - v3-android-ndk-{{ arch }}-r10e- - &save-cache-ndk paths: - /opt/ndk - key: v1-android-ndk-{{ arch }}-r10e-32-64 + key: v3-android-ndk-{{ arch }}-r10e-{{ checksum "scripts/circle-ci-android-setup.sh" }} - &restore-cache-buck keys: - - v2-buck-{{ arch }}-v2017.11.16.01 + - v3-buck-{{ arch }}-v2018.02.16.01 - &save-cache-buck paths: - ~/buck - key: v2-buck-{{ arch }}-v2017.11.16.01 + - ~/okbuck + key: v3-buck-{{ arch }}-v2018.02.16.01 - &restore-cache-watchman keys: @@ -56,6 +80,17 @@ aliases: - ~/watchman key: v1-watchman-{{ arch }}-v4.9.0 + - &restore-cache-gradle-downloads + keys: + - v1-gradle-{{ arch }}-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} + - v1-gradle-{{ arch }}- + - &save-cache-gradle-downloads + paths: + - ~/.gradle + - ReactAndroid/build/downloads + - ReactAndroid/build/third-party-ndk + key: v1-gradle-{{ arch }}-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} + # Branch Filtering - &filter-only-master-stable branches: @@ -81,15 +116,16 @@ aliases: # Dependency Management - &install-ndk - | - source scripts/circle-ci-android-setup.sh && getAndroidNDK + name: Install Android NDK + command: source scripts/circle-ci-android-setup.sh && getAndroidNDK - &yarn | yarn install --non-interactive --cache-folder ~/.cache/yarn - &install-yarn - | + name: Install Yarn + command: | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn @@ -99,15 +135,24 @@ aliases: npm install --no-package-lock --no-spin --no-progress - &install-buck - | + name: Install BUCK + command: | if [[ ! -e ~/buck ]]; then - git clone https://github.com/facebook/buck.git ~/buck --branch v2017.11.16.01 --depth=1 + git clone https://github.com/facebook/buck.git ~/buck --branch v2018.02.16.01 --depth=1 fi cd ~/buck && ant buck --version + # Install related tooling + if [[ ! -e ~/okbuck ]]; then + git clone https://github.com/uber/okbuck.git ~/okbuck --depth=1 + fi + mkdir -p ~/react-native/tooling/junit + cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/. - - &install-node - | + + - &install-node + name: Install Node + command: | curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs @@ -128,23 +173,30 @@ aliases: source $BASH_ENV - &install-android-packages - | - source scripts/circle-ci-android-setup.sh && getAndroidSDK + name: Install Android SDK Packages + command: source scripts/circle-ci-android-setup.sh && getAndroidSDK - &install-android-build-dependencies name: Install Android Build Dependencies - command: | - sudo apt-get update -y - sudo apt-get install ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev file -y + command: ./scripts/circleci/apt-get-android-deps.sh + + - &validate-android-sdk + name: Validate Android SDK Install + command: ./scripts/validate-android-sdk.sh + + - &validate-android-test-env + name: Validate Android Test Environment + command: ./scripts/validate-android-test-env.sh # Test Definitions - &run-js-tests name: JavaScript Test Suite command: yarn test-ci - + + # eslint sometimes runs into trouble generating the reports - &run-lint-checks name: Lint code - command: yarn lint --format junit -o ~/reports/junit/js-lint-results.xml + command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/js-lint-results.xml when: always - &run-flow-checks @@ -152,6 +204,17 @@ aliases: command: yarn flow check when: always + - &run-sanity-checks + name: Sanity checks + command: | + ./scripts/circleci/check_license.sh + ./scripts/circleci/check_cache.sh + when: always + + - &gradle-download-deps + name: Download C++ Dependencies + command: ./scripts/circleci/gradle_download_deps.sh + - &build-android-app name: Build Android App command: | @@ -182,7 +245,7 @@ aliases: - &run-android-unit-tests name: Run Unit Tests - command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS + command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ~/react-native/reports/buck/all-results-raw.xml - &run-android-instrumentation-tests name: Run Instrumentation Tests @@ -190,44 +253,55 @@ aliases: if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then echo "JavaScript bundle missing, cannot run instrumentation tests. Verify build-js-bundle step completed successfully."; exit 1; fi - source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS + source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 timeout 300 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS - &collect-android-test-results name: Collect Test Results command: | - find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/reports/junit/ \; - find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/reports/junit/ \; - find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/reports/junit/ \; + find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/react-native/reports/build/ \; + find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/react-native/reports/outputs/ \; + find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/react-native/reports/buck/ \; + ./tooling/junit/buck_to_junit.sh ~/react-native/reports/buck/all-results-raw.xml ~/react-native/reports/junit/all-results-junit.xml when: always - &setup-artifacts name: Initial Setup command: | - mkdir -p ~/reports/junit/ - + mkdir -p ~/react-native/reports/buck/ + mkdir -p ~/react-native/reports/build/ + mkdir -p ~/react-native/reports/junit/ + mkdir -p ~/react-native/reports/outputs/ + - &run-objc-ios-tests - name: Objective-C iOS Test Suite - command: ./scripts/objc-test-ios.sh + name: iOS Test Suite + command: ./scripts/objc-test-ios.sh test - &run-objc-tvos-tests - name: Objective-C tvOS Test Suite - command: ./scripts/objc-test-tvos.sh + name: tvOS Test Suite + command: ./scripts/objc-test-tvos.sh test - &run-objc-ios-e2e-tests - name: Objective-C iOS End-to-End Test Suite + name: iOS End-to-End Test Suite command: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; - &run-objc-tvos-e2e-tests - name: Objective-C tvOS End-to-End Test Suite + name: tvOS End-to-End Test Suite command: node ./scripts/run-ci-e2e-tests.js --tvos --js --retries 3; defaults: &defaults working_directory: ~/react-native +js_defaults: &js_defaults + <<: *defaults + docker: + - image: circleci/node:8 + environment: + - PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + android_defaults: &android_defaults <<: *defaults docker: - - image: circleci/android:api-26-alpha + - image: circleci/android:api-26-node8-alpha resource_class: "large" environment: - TERM: "dumb" @@ -237,54 +311,62 @@ android_defaults: &android_defaults - ANDROID_NDK: '/opt/ndk/android-ndk-r10e' - BUILD_THREADS: 2 +macos_defaults: &macos_defaults + <<: *defaults + macos: + xcode: "9.2.0" + version: 2 jobs: - # Runs JavaScript lint and flow checks. - # Currently will fail a PR if lint/flow raises issues. - js-checks: - <<: *defaults - docker: - - image: circleci/node:8 + + # Set up a Node environment for downstream jobs + checkout_code: + <<: *js_defaults steps: - checkout - run: *setup-artifacts - - restore-cache: *restore-yarn-cache + - restore-cache: *restore-cache-yarn - run: *yarn - - save-cache: *save-yarn-cache + - save-cache: *save-cache-yarn + + # Basic checks against the checkout, cache... + - run: *run-sanity-checks + + - persist_to_workspace: + root: . + paths: . + + # Runs JavaScript lint and flow checks. + # Currently will fail a PR if lint/flow raises issues. + analyze: + <<: *js_defaults + steps: + - attach_workspace: + at: ~/react-native - run: *run-lint-checks - run: *run-flow-checks - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit - store_artifacts: path: ~/react-native/yarn.lock # Runs JavaScript tests on Node 8 - js-node-8: - <<: *defaults - docker: - - image: circleci/node:8 + test_javascript: + <<: *js_defaults steps: - - checkout - - run: *setup-artifacts - - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache + - attach_workspace: + at: ~/react-native - run: *run-js-tests - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Runs JavaScript tests on Node 6 - js-node-6: + test_javascript_node6_compatibility: <<: *defaults docker: - image: circleci/node:6 @@ -292,132 +374,105 @@ jobs: - checkout - run: *setup-artifacts - - restore-cache: *restore-yarn-cache + - restore-cache: *restore-cache-yarn - run: *yarn - - save-cache: *save-yarn-cache + - save-cache: *save-cache-yarn - run: *run-js-tests - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Runs unit tests on iOS devices - objc-ios: - <<: *defaults - macos: - xcode: "9.0" - dependencies: - pre: - - xcrun instruments -w "iPhone 5s (10.3.1)" || true + test_ios: + <<: *macos_defaults steps: - - checkout - - run: *setup-artifacts - - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache + - attach_workspace: + at: ~/react-native + - run: xcrun instruments -w "iPhone 5s (11.1)" || true + - run: brew install watchman - run: *run-objc-ios-tests - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Runs unit tests on tvOS devices - objc-tvos: - <<: *defaults - macos: - xcode: "9.0" - dependencies: - pre: - - xcrun instruments -w "Apple TV 1080p (10.0)" || true + test_tvos: + <<: *macos_defaults steps: - - checkout - - run: *setup-artifacts - - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache + - attach_workspace: + at: ~/react-native + - run: xcrun instruments -w "Apple TV 1080p (11.1)" || true + - run: brew install watchman - run: *run-objc-tvos-tests - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Runs end to end tests - objc-ios-e2e: - <<: *defaults - macos: - xcode: "9.0" - dependencies: - pre: - - xcrun instruments -w "iPhone 5s (10.3.1)" || true + test_ios_e2e: + <<: *macos_defaults steps: - - checkout - - run: *setup-artifacts - - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache + - attach_workspace: + at: ~/react-native + - run: xcrun instruments -w "iPhone 5s (11.1)" || true - run: *run-objc-ios-e2e-tests - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Checks podspec - test-podspec: - <<: *defaults - macos: - xcode: "9.0" + test_podspec: + <<: *macos_defaults steps: - - checkout - - run: *setup-artifacts + - attach_workspace: + at: ~/react-native - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache - run: ./scripts/process-podspecs.sh # Publishes new version onto npm - deploy: + publish_npm_package: <<: *android_defaults steps: + # Checkout code so that we can work with `git` in publish.js - checkout - - run: *setup-artifacts - - # Configure Android dependencies + + # Configure Android SDK and related dependencies - run: *configure-android-path - run: *install-android-build-dependencies + - restore-cache: *restore-cache-android-packages - run: *install-android-packages - save-cache: *save-cache-android-packages + + # Install Android NDK - run: *create-ndk-directory - restore-cache: *restore-cache-ndk - run: *install-ndk - save-cache: *save-cache-ndk + + # Fetch dependencies using BUCK - restore-cache: *restore-cache-buck - run: *install-buck - save-cache: *save-cache-buck - - run: *install-node - - run: *install-yarn - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache + - 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 - run: buck fetch ReactAndroid/src/test/... - run: buck fetch ReactAndroid/src/androidTest/... - - run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders + - restore-cache: *restore-cache-gradle-downloads + - run: *gradle-download-deps + - save-cache: *save-cache-gradle-downloads + + - restore-cache: *restore-cache-yarn + - run: *yarn + - save-cache: *save-cache-yarn + - run: name: Publish React Native Package command: | @@ -431,79 +486,81 @@ jobs: echo "Skipping deploy." fi - # Runs unit tests tests on Android - android: + # Set up an Android environment for downstream jobs + test_android: <<: *android_defaults steps: - - checkout - - run: *setup-artifacts + - attach_workspace: + at: ~/react-native # Configure Android SDK and related dependencies - run: *configure-android-path + - restore-cache: *restore-cache-apt - run: *install-android-build-dependencies + - save-cache: *save-cache-apt + - restore-cache: *restore-cache-android-packages - run: *install-android-packages - save-cache: *save-cache-android-packages + - run: *validate-android-sdk + # Starting emulator in advance as it takes some time to boot. - run: *create-avd - run: *launch-avd - + # Keep configuring Android dependencies while AVD boots up + # Install Android NDK + - run: *create-ndk-directory + - restore-cache: *restore-cache-ndk + - run: *install-ndk + - save-cache: *save-cache-ndk + # Fetch dependencies using BUCK - restore-cache: *restore-cache-buck - run: *install-buck - save-cache: *save-cache-buck + - run: *validate-android-test-env + - 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 - run: buck fetch ReactAndroid/src/test/... - run: buck fetch ReactAndroid/src/androidTest/... - - run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders - # Install Android NDK - - run: *create-ndk-directory - - restore-cache: *restore-cache-ndk - - run: *install-ndk - - save-cache: *save-cache-ndk + - restore-cache: *restore-cache-gradle-downloads + - run: *gradle-download-deps + - save-cache: *save-cache-gradle-downloads # Build and compile - run: *build-android-app - run: *compile-native-libs # Build JavaScript Bundle for instrumentation tests - - run: *install-node - - run: *install-yarn - - restore-cache: *restore-yarn-cache - - run: *yarn - - save-cache: *save-yarn-cache - run: *build-js-bundle # Wait for AVD to finish booting before running tests - run: *wait-for-avd - + # Test Suite - run: *run-android-unit-tests - run: *run-android-instrumentation-tests - # post (always runs) + # Collect Results - run: *collect-android-test-results - store_test_results: - path: ~/reports/junit - - store_artifacts: - path: ~/reports/junit + path: ~/react-native/reports/junit # Analyze pull request and raise any lint/flow issues. # Issues will be posted to the PR itself via GitHub bots. # This workflow should only fail if the bots fail to run. - analyze-pull-request: - <<: *defaults - docker: - - image: circleci/node:8 + analyze_pr: + <<: *js_defaults steps: - - checkout + - attach_workspace: + at: ~/react-native - restore-cache: *restore-cache-analysis - run: *yarn @@ -518,11 +575,13 @@ jobs: echo "Skipping dependency installation." fi - save-cache: *save-cache-analysis + - run: name: Analyze Pull Request command: | + # DANGER_GITHUB_API_TOKEN=Facebook-Open-Source-Bot public_repo access token if [ -n "$CIRCLE_PR_NUMBER" ]; then - cd bots && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger + cd bots && DANGER_GITHUB_API_TOKEN="b186c9a82bab3b08ec80""c0818117619eec6f281a" yarn danger else echo "Skipping pull request analysis." fi @@ -530,8 +589,9 @@ jobs: - run: name: Analyze Code command: | + # GITHUB_TOKEN=eslint-bot public_repo access token if [ -n "$CIRCLE_PR_NUMBER" ]; then - cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js + GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER scripts/circleci/analyze_code.sh else echo "Skipping code analysis." fi @@ -541,43 +601,90 @@ jobs: workflows: version: 2 - build: + tests: jobs: - # Run lint and flow checks - - js-checks: + # Checkout repo and run Yarn + - checkout_code: filters: *filter-ignore-gh-pages - # Test JavaScript on Node 8 and 6 - - js-node-8: + # Run lint, flow, and other checks + - analyze: filters: *filter-ignore-gh-pages - - js-node-6: + requires: + - checkout_code + + # Test JavaScript + - test_javascript: + filters: *filter-ignore-gh-pages + requires: + - checkout_code + + # Test JavaScript using Node 6, the minimum supported version + - test_javascript_node6_compatibility: filters: *filter-ignore-gh-pages # Test Android - - android: + - test_android: filters: *filter-ignore-gh-pages + requires: + - checkout_code # Test iOS & tvOS - - objc-ios: + - test_ios: filters: *filter-ignore-gh-pages - - objc-tvos: + requires: + - checkout_code + - test_tvos: filters: *filter-ignore-gh-pages + requires: + - checkout_code # End-to-end tests - - objc-ios-e2e: + - test_ios_e2e: filters: *filter-ignore-gh-pages requires: - - objc-ios - - js-node-8 - - # If we are on a stable branch, deploy to `npm` - - hold: - type: approval - - deploy: + - checkout_code + + # Only runs on PRs + analyze: + jobs: + # Checkout repo and run Yarn + - checkout_code: + filters: *filter-ignore-master-stable + + # Run code checks + - analyze_pr: + filters: *filter-ignore-master-stable + requires: + - checkout_code + + # Only runs on NN-stable branches + deploy: + jobs: + # If we are on a stable branch, wait for approval to deploy to npm + - approve_publish_npm_package: filters: *filter-only-stable + type: approval + + - publish_npm_package: requires: - - hold - - - analyze-pull-request: - filters: *filter-ignore-master-stable \ No newline at end of file + - approve_publish_npm_package + + # These tests are flaky or are yet to be fixed. They are placed on their own + # workflow to avoid marking benign PRs as broken. + # To run them, uncomment the entire block and open a PR (do not merge). + # Once a test is fixed, move the test definition to the 'tests' workflow. + # disabled_tests: + # jobs: + # # Checkout repo and run Yarn (pre-req, should succeed) + # - checkout_code: + # filters: *filter-ignore-gh-pages + + # # The following were DISABLED because they have not run since + # # the migration from Travis, and they have broken since then, + # # CocoaPods + # - test_podspec: + # filters: *filter-ignore-gh-pages + # requires: + # - checkout_code diff --git a/.eslintrc b/.eslintrc index 3f1c59d4df004b..9887d1c6d8dbe0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,10 +3,6 @@ "parser": "babel-eslint", - "ecmaFeatures": { - "jsx": true - }, - "env": { "es6": true, "jest": true, @@ -17,6 +13,7 @@ "flowtype", "prettier", "react", + "react-native", "jest" ], @@ -173,10 +170,10 @@ // ESLint Comments Plugin // The following rules are made available via `eslint-plugin-eslint-comments` - 'eslint-comments/no-aggregating-enable': 1, // disallows eslint-enable comments for multiple eslint-disable comments - 'eslint-comments/no-unlimited-disable': 1, // disallows eslint-disable comments without rule names - 'eslint-comments/no-unused-disable': 1, // disallow disables that don't cover any errors - 'eslint-comments/no-unused-enable': 1, // // disallow enables that don't enable anything or enable rules that weren't disabled + "eslint-comments/no-aggregating-enable": 1, // disallows eslint-enable comments for multiple eslint-disable comments + "eslint-comments/no-unlimited-disable": 1, // disallows eslint-disable comments without rule names + "eslint-comments/no-unused-disable": 1, // disallow disables that don't cover any errors + "eslint-comments/no-unused-enable": 1, // // disallow enables that don't enable anything or enable rules that weren't disabled // Flow Plugin // The following rules are made available via `eslint-plugin-flowtype` @@ -205,7 +202,7 @@ "new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments "no-nested-ternary": 0, // disallow nested ternary expressions (off by default) "no-array-constructor": 1, // disallow use of the Array constructor - 'no-empty-character-class': 1, // disallow the use of empty character classes in regular expressions + "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 @@ -256,11 +253,48 @@ "react/self-closing-comp": 1, "react/wrap-multilines": 0, + // React-Native Plugin + // The following rules are made available via `eslint-plugin-react-native` + + "react-native/no-inline-styles": 1, + // Jest Plugin // The following rules are made available via `eslint-plugin-jest`. "jest/no-disabled-tests": 1, "jest/no-focused-tests": 1, "jest/no-identical-title": 1, "jest/valid-expect": 1, - } + }, + + "overrides": [ + { + "files": [ + "Libraries/**/*.js", + "RNTester/**/*.js", + "jest/**/*.js", + ], + "rules": { + // These folders currently run through babel and don't need to be + // compatible with node 4 + "comma-dangle": 0, + }, + }, + { + "files": [ + "local-cli/**/*.js", + ], + "rules": { + // This folder currently runs through babel and doesn't need to be + // compatible with node 4 + "comma-dangle": 0, + + "lint/extra-arrow-initializer": 0, + "no-alert": 0, + "no-console-disallow": 0, + }, + "env": { + "node": true, + }, + }, + ], } diff --git a/.flowconfig b/.flowconfig index 571fc9114e9e0d..f67339eee78487 100644 --- a/.flowconfig +++ b/.flowconfig @@ -52,4 +52,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError [version] -^0.64.0 +^0.69.0 diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1f642ca4fb1b84..46d7bb4760de02 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,122 +1,27 @@ -### Is this a bug report? +- [ ] I have reviewed the [documentation](https://facebook.github.io/react-native) +- [ ] I have searched [existing issues](https://github.com/facebook/react-native/issues) +- [ ] I am using the [latest React Native version](https://github.com/facebook/react-native/releases) -(write your answer here) + - - -### Have you read the [Contributing Guidelines](https://facebook.github.io/react-native/docs/contributing.html)? - -(Write your answer here.) - -### Environment - - - -### Steps to Reproduce - - - -(Write your steps here:) +## Environment + -1. -2. -3. - -### Expected Behavior - - - -(Write what you thought would happen.) - -### Actual Behavior - - - -(Write what happened. Add screenshots!) - -### Reproducible Demo - - -(Paste the link to an example project and exact instructions to reproduce the issue.) +## Expected Behavior + - +## Actual Behavior + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d8a1469f329099..93f140001bd706 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,43 +1,46 @@ - -## Motivation - -(Write your motivation here.) - ## Test Plan -(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) + ## Related PRs -(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.) + ## Release Notes - - CATEGORY -[----------] TYPE -[ CLI ] [-------------] LOCATION -[ DOCS ] [ BREAKING ] [-------------] -[ GENERAL ] [ BUGFIX ] [-{Component}-] -[ INTERNAL ] [ ENHANCEMENT ] [ {File} ] -[ IOS ] [ FEATURE ] [ {Directory} ] |-----------| -[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | -[----------] [-------------] [-------------] |-----------| +[CATEGORY] [TYPE] [LOCATION] - Message -[CATEGORY] [TYPE] [LOCATION] - MESSAGE + diff --git a/ContainerShip/Dockerfile.android b/ContainerShip/Dockerfile.android index adb361ab58f79c..f7a207aea3e557 100644 --- a/ContainerShip/Dockerfile.android +++ b/ContainerShip/Dockerfile.android @@ -9,6 +9,7 @@ ADD .buckconfig /app/.buckconfig ADD .buckjavaargs /app/.buckjavaargs ADD ReactAndroid /app/ReactAndroid ADD ReactCommon /app/ReactCommon +ADD ReactNative /app/ReactNative ADD keystores /app/keystores # set workdir @@ -41,10 +42,12 @@ RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 -Pcom.android.bu ADD . /app WORKDIR /app -# https://github.com/npm/npm/issues/13306 -RUN cd $(npm root -g)/npm && npm install fs-extra && sed -i -e s/graceful-fs/fs-extra/ -e s/fs.rename/fs.move/ ./lib/utils/rename.js - # build node dependencies -RUN npm install +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +RUN apt-get install apt-transport-https +RUN apt-get update +RUN apt-get install yarn +RUN yarn WORKDIR /app diff --git a/ContainerShip/Dockerfile.android-base b/ContainerShip/Dockerfile.android-base index 05caa480f3c827..93a1aafa811787 100644 --- a/ContainerShip/Dockerfile.android-base +++ b/ContainerShip/Dockerfile.android-base @@ -2,10 +2,10 @@ FROM library/ubuntu:16.04 # set default build arguments ARG ANDROID_TOOLS_VERSION=25.2.5 -ARG BUCK_VERSION=v2017.11.16.01 +ARG BUCK_VERSION=v2018.02.16.01 ARG NDK_VERSION=10e -ARG NODE_VERSION=6.2.0 -ARG WATCHMAN_VERSION=4.7.0 +ARG NODE_VERSION=8.10.0 +ARG WATCHMAN_VERSION=4.9.0 # set default environment variables ENV ADB_INSTALL_TIMEOUT=10 @@ -34,17 +34,6 @@ WORKDIR /opt/buck # build buck RUN ant -# download watchman -RUN git clone https://github.com/facebook/watchman.git /opt/watchman -WORKDIR /opt/watchman -RUN git checkout v$WATCHMAN_VERSION - -# build watchman -RUN ./autogen.sh -RUN ./configure -RUN make -RUN make install - # Full reference at https://dl.google.com/android/repository/repository2-1.xml # download and unpack android RUN mkdir /opt/android diff --git a/ContainerShip/scripts/run-android-ci-instrumentation-tests.js b/ContainerShip/scripts/run-android-ci-instrumentation-tests.js index 34ee3336a168d2..706159c4902bc4 100644 --- a/ContainerShip/scripts/run-android-ci-instrumentation-tests.js +++ b/ContainerShip/scripts/run-android-ci-instrumentation-tests.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/IntegrationTests/AccessibilityManagerTest.js b/IntegrationTests/AccessibilityManagerTest.js index dfa9e9a19f289d..74dbe9ba19edab 100644 --- a/IntegrationTests/AccessibilityManagerTest.js +++ b/IntegrationTests/AccessibilityManagerTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule AccessibilityManagerTest diff --git a/IntegrationTests/AppEventsTest.js b/IntegrationTests/AppEventsTest.js index 62299ec337858d..ae061e167b86d8 100644 --- a/IntegrationTests/AppEventsTest.js +++ b/IntegrationTests/AppEventsTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AppEventsTest * @flow diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index ef7df1f1f365e5..3ce0265dd8ceb0 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule AsyncStorageTest diff --git a/IntegrationTests/ImageCachePolicyTest.js b/IntegrationTests/ImageCachePolicyTest.js index 29b5e68d1d2117..d6fa4f544a1bf9 100644 --- a/IntegrationTests/ImageCachePolicyTest.js +++ b/IntegrationTests/ImageCachePolicyTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule ImageCachePolicyTest diff --git a/IntegrationTests/ImageSnapshotTest.js b/IntegrationTests/ImageSnapshotTest.js index ccb232796927ca..8ba7734286d673 100644 --- a/IntegrationTests/ImageSnapshotTest.js +++ b/IntegrationTests/ImageSnapshotTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule ImageSnapshotTest diff --git a/IntegrationTests/IntegrationTestHarnessTest.js b/IntegrationTests/IntegrationTestHarnessTest.js index 7c9f2527cabbd0..6291c915d68643 100644 --- a/IntegrationTests/IntegrationTestHarnessTest.js +++ b/IntegrationTests/IntegrationTestHarnessTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule IntegrationTestHarnessTest diff --git a/IntegrationTests/IntegrationTestsApp.js b/IntegrationTests/IntegrationTestsApp.js index 0594e289b7b145..6b255c2befe54a 100644 --- a/IntegrationTests/IntegrationTestsApp.js +++ b/IntegrationTests/IntegrationTestsApp.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule IntegrationTestsApp diff --git a/IntegrationTests/LayoutEventsTest.js b/IntegrationTests/LayoutEventsTest.js index ab7bc6040d113d..769ff98f6be8b5 100644 --- a/IntegrationTests/LayoutEventsTest.js +++ b/IntegrationTests/LayoutEventsTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule LayoutEventsTest * @flow diff --git a/IntegrationTests/LoggingTestModule.js b/IntegrationTests/LoggingTestModule.js index ec07f3271bf700..25b409353ce1d4 100644 --- a/IntegrationTests/LoggingTestModule.js +++ b/IntegrationTests/LoggingTestModule.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule LoggingTestModule */ diff --git a/IntegrationTests/PromiseTest.js b/IntegrationTests/PromiseTest.js index 9cf8651e3a3511..f6a81e3d6d5d16 100644 --- a/IntegrationTests/PromiseTest.js +++ b/IntegrationTests/PromiseTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule PromiseTest diff --git a/IntegrationTests/PropertiesUpdateTest.js b/IntegrationTests/PropertiesUpdateTest.js index a279c5aed0af08..623dc82c8ee94b 100644 --- a/IntegrationTests/PropertiesUpdateTest.js +++ b/IntegrationTests/PropertiesUpdateTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * @providesModule PropertiesUpdateTest */ 'use strict'; diff --git a/IntegrationTests/RCTRootViewIntegrationTestApp.js b/IntegrationTests/RCTRootViewIntegrationTestApp.js index 3793938d7e5adf..a97873d2c3224e 100644 --- a/IntegrationTests/RCTRootViewIntegrationTestApp.js +++ b/IntegrationTests/RCTRootViewIntegrationTestApp.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule RCTRootViewIntegrationTestApp */ diff --git a/IntegrationTests/ReactContentSizeUpdateTest.js b/IntegrationTests/ReactContentSizeUpdateTest.js index 07ae0ed661ce15..c5f5ae80c246b0 100644 --- a/IntegrationTests/ReactContentSizeUpdateTest.js +++ b/IntegrationTests/ReactContentSizeUpdateTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * @providesModule ReactContentSizeUpdateTest */ 'use strict'; @@ -30,7 +28,7 @@ var ReactContentSizeUpdateTest = createReactClass({ mixins: [Subscribable.Mixin, TimerMixin], - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this.addListenerOn( RCTNativeAppEventEmitter, 'rootViewDidChangeIntrinsicSize', diff --git a/IntegrationTests/SimpleSnapshotTest.js b/IntegrationTests/SimpleSnapshotTest.js index 3998118dda8f6e..1c0be2a431d469 100644 --- a/IntegrationTests/SimpleSnapshotTest.js +++ b/IntegrationTests/SimpleSnapshotTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule SimpleSnapshotTest diff --git a/IntegrationTests/SizeFlexibilityUpdateTest.js b/IntegrationTests/SizeFlexibilityUpdateTest.js index 5d580f8fc6a028..679694a0d631ce 100644 --- a/IntegrationTests/SizeFlexibilityUpdateTest.js +++ b/IntegrationTests/SizeFlexibilityUpdateTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * @providesModule SizeFlexibilityUpdateTest */ 'use strict'; @@ -27,7 +25,7 @@ var SizeFlexibilityUpdateTest = createReactClass({ displayName: 'SizeFlexibilityUpdateTest', mixins: [Subscribable.Mixin], - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this.addListenerOn( RCTNativeAppEventEmitter, 'rootViewDidChangeIntrinsicSize', diff --git a/IntegrationTests/SyncMethodTest.js b/IntegrationTests/SyncMethodTest.js index 76bb70a81f41d7..6318eaa4f14282 100644 --- a/IntegrationTests/SyncMethodTest.js +++ b/IntegrationTests/SyncMethodTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule SyncMethodTest diff --git a/IntegrationTests/TimersTest.js b/IntegrationTests/TimersTest.js index ddd052081cffd4..23da99dc6edbdc 100644 --- a/IntegrationTests/TimersTest.js +++ b/IntegrationTests/TimersTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule TimersTest diff --git a/IntegrationTests/WebSocketTest.js b/IntegrationTests/WebSocketTest.js index 78d00701b53683..6e459f913babc3 100644 --- a/IntegrationTests/WebSocketTest.js +++ b/IntegrationTests/WebSocketTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule WebSocketTest diff --git a/IntegrationTests/WebViewTest.js b/IntegrationTests/WebViewTest.js index c0381c639a8256..a41e244b58be3a 100644 --- a/IntegrationTests/WebViewTest.js +++ b/IntegrationTests/WebViewTest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule WebViewTest */ diff --git a/IntegrationTests/launchWebSocketServer.command b/IntegrationTests/launchWebSocketServer.command index ebb305dc150326..a6531c5f8d78b2 100755 --- a/IntegrationTests/launchWebSocketServer.command +++ b/IntegrationTests/launchWebSocketServer.command @@ -1,11 +1,9 @@ #!/usr/bin/env bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. # -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. +# 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" diff --git a/IntegrationTests/websocket_integration_test_server.js b/IntegrationTests/websocket_integration_test_server.js index b7887f1c5e3753..e338d85ae3b89d 100755 --- a/IntegrationTests/websocket_integration_test_server.js +++ b/IntegrationTests/websocket_integration_test_server.js @@ -2,11 +2,9 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule websocket_integration_test_server diff --git a/LICENSE b/LICENSE index 8085fec497caf6..9e051010d82dc6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,30 +1,21 @@ -BSD License +MIT License -For React Native software +Copyright (c) 2015-present, Facebook, Inc. -Copyright (c) 2015-present, Facebook, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Libraries/.eslintrc b/Libraries/.eslintrc deleted file mode 100644 index ddcf4e27251d8f..00000000000000 --- a/Libraries/.eslintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - // This folder currently runs through babel and doesn't need to be - // compatible with node 4 - "comma-dangle": 0 - } -} diff --git a/Libraries/.npmignore b/Libraries/.npmignore new file mode 100644 index 00000000000000..c912533dd7d2dd --- /dev/null +++ b/Libraries/.npmignore @@ -0,0 +1 @@ +__tests__ diff --git a/Libraries/ART/ARTCGFloatArray.h b/Libraries/ART/ARTCGFloatArray.h index 9d748549973d30..72286a50527e84 100644 --- a/Libraries/ART/ARTCGFloatArray.h +++ b/Libraries/ART/ARTCGFloatArray.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // A little helper to make sure we have the right memory allocation ready for use. diff --git a/Libraries/ART/ARTContainer.h b/Libraries/ART/ARTContainer.h index d83f7ae1a559f8..532145825bd74b 100644 --- a/Libraries/ART/ARTContainer.h +++ b/Libraries/ART/ARTContainer.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTGroup.h b/Libraries/ART/ARTGroup.h index 4d94a9acded24b..d9dcb48c87b180 100644 --- a/Libraries/ART/ARTGroup.h +++ b/Libraries/ART/ARTGroup.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTGroup.m b/Libraries/ART/ARTGroup.m index 672c3b6ebeb9f8..1bc70725c030e8 100644 --- a/Libraries/ART/ARTGroup.m +++ b/Libraries/ART/ARTGroup.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTGroup.h" diff --git a/Libraries/ART/ARTNode.h b/Libraries/ART/ARTNode.h index 0ade1f21b57a6c..8b66c205ef2440 100644 --- a/Libraries/ART/ARTNode.h +++ b/Libraries/ART/ARTNode.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTNode.m b/Libraries/ART/ARTNode.m index 38b01a0c56c449..b27b014b9e7d0e 100644 --- a/Libraries/ART/ARTNode.m +++ b/Libraries/ART/ARTNode.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTNode.h" diff --git a/Libraries/ART/ARTRenderable.h b/Libraries/ART/ARTRenderable.h index 8eae9c25ae4a70..e5735a1fbd81ef 100644 --- a/Libraries/ART/ARTRenderable.h +++ b/Libraries/ART/ARTRenderable.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTRenderable.m b/Libraries/ART/ARTRenderable.m index 7ba9a9a6073915..d7a3115586f3dd 100644 --- a/Libraries/ART/ARTRenderable.m +++ b/Libraries/ART/ARTRenderable.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTRenderable.h" diff --git a/Libraries/ART/ARTSerializablePath.js b/Libraries/ART/ARTSerializablePath.js index 4e8b3c2271a6c7..7f52bc6540eda2 100644 --- a/Libraries/ART/ARTSerializablePath.js +++ b/Libraries/ART/ARTSerializablePath.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ARTSerializablePath */ diff --git a/Libraries/ART/ARTShape.h b/Libraries/ART/ARTShape.h index 7d13c268f6e802..ce685c564b06be 100644 --- a/Libraries/ART/ARTShape.h +++ b/Libraries/ART/ARTShape.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTShape.m b/Libraries/ART/ARTShape.m index c07d68e62aa4a3..935c8894994a2b 100644 --- a/Libraries/ART/ARTShape.m +++ b/Libraries/ART/ARTShape.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTShape.h" diff --git a/Libraries/ART/ARTSurfaceView.h b/Libraries/ART/ARTSurfaceView.h index 8be8d95040c146..cb42928cedbe12 100644 --- a/Libraries/ART/ARTSurfaceView.h +++ b/Libraries/ART/ARTSurfaceView.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTSurfaceView.m b/Libraries/ART/ARTSurfaceView.m index 16e2029083de59..c8f46069038603 100644 --- a/Libraries/ART/ARTSurfaceView.m +++ b/Libraries/ART/ARTSurfaceView.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTSurfaceView.h" diff --git a/Libraries/ART/ARTText.h b/Libraries/ART/ARTText.h index ee976e329a46e8..cdf8393a137629 100644 --- a/Libraries/ART/ARTText.h +++ b/Libraries/ART/ARTText.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ARTText.m b/Libraries/ART/ARTText.m index dfffde26546656..0953c850dc293e 100644 --- a/Libraries/ART/ARTText.m +++ b/Libraries/ART/ARTText.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTText.h" diff --git a/Libraries/ART/ARTTextFrame.h b/Libraries/ART/ARTTextFrame.h index 1f6b557bfc77af..8ad06e0a01baed 100644 --- a/Libraries/ART/ARTTextFrame.h +++ b/Libraries/ART/ARTTextFrame.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/Brushes/ARTBrush.h b/Libraries/ART/Brushes/ARTBrush.h index 05020dd7bafa26..95709e65f19bc9 100644 --- a/Libraries/ART/Brushes/ARTBrush.h +++ b/Libraries/ART/Brushes/ARTBrush.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/Brushes/ARTBrush.m b/Libraries/ART/Brushes/ARTBrush.m index 1cc762b650f04a..4ade2c221143f7 100644 --- a/Libraries/ART/Brushes/ARTBrush.m +++ b/Libraries/ART/Brushes/ARTBrush.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTBrush.h" diff --git a/Libraries/ART/Brushes/ARTLinearGradient.h b/Libraries/ART/Brushes/ARTLinearGradient.h index d7ff2e5684458f..8e6abbc5fbbfde 100644 --- a/Libraries/ART/Brushes/ARTLinearGradient.h +++ b/Libraries/ART/Brushes/ARTLinearGradient.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTBrush.h" diff --git a/Libraries/ART/Brushes/ARTLinearGradient.m b/Libraries/ART/Brushes/ARTLinearGradient.m index f8412163b319c0..1415a6ffcbc80f 100644 --- a/Libraries/ART/Brushes/ARTLinearGradient.m +++ b/Libraries/ART/Brushes/ARTLinearGradient.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTLinearGradient.h" diff --git a/Libraries/ART/Brushes/ARTPattern.h b/Libraries/ART/Brushes/ARTPattern.h index 5f513ec60e2ae6..ce1767cc9b0bc8 100644 --- a/Libraries/ART/Brushes/ARTPattern.h +++ b/Libraries/ART/Brushes/ARTPattern.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTBrush.h" diff --git a/Libraries/ART/Brushes/ARTPattern.m b/Libraries/ART/Brushes/ARTPattern.m index 0d720613b80182..5c43586452d198 100644 --- a/Libraries/ART/Brushes/ARTPattern.m +++ b/Libraries/ART/Brushes/ARTPattern.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTPattern.h" diff --git a/Libraries/ART/Brushes/ARTRadialGradient.h b/Libraries/ART/Brushes/ARTRadialGradient.h index 7f86d93058ce80..d7895f8b74d084 100644 --- a/Libraries/ART/Brushes/ARTRadialGradient.h +++ b/Libraries/ART/Brushes/ARTRadialGradient.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTBrush.h" diff --git a/Libraries/ART/Brushes/ARTRadialGradient.m b/Libraries/ART/Brushes/ARTRadialGradient.m index 1dd449595316e7..19db9cb97b567a 100644 --- a/Libraries/ART/Brushes/ARTRadialGradient.m +++ b/Libraries/ART/Brushes/ARTRadialGradient.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTRadialGradient.h" diff --git a/Libraries/ART/Brushes/ARTSolidColor.h b/Libraries/ART/Brushes/ARTSolidColor.h index f212c735680f60..a16c2b915c72f8 100644 --- a/Libraries/ART/Brushes/ARTSolidColor.h +++ b/Libraries/ART/Brushes/ARTSolidColor.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTBrush.h" diff --git a/Libraries/ART/Brushes/ARTSolidColor.m b/Libraries/ART/Brushes/ARTSolidColor.m index 900621cfb4ea3c..096c4e043ed429 100644 --- a/Libraries/ART/Brushes/ARTSolidColor.m +++ b/Libraries/ART/Brushes/ARTSolidColor.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTSolidColor.h" diff --git a/Libraries/ART/RCTConvert+ART.h b/Libraries/ART/RCTConvert+ART.h index ef46e4e9341e3c..1deb3c600176ab 100644 --- a/Libraries/ART/RCTConvert+ART.h +++ b/Libraries/ART/RCTConvert+ART.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/RCTConvert+ART.m b/Libraries/ART/RCTConvert+ART.m index 6135dc4f4fd250..ea22d5426f18f9 100644 --- a/Libraries/ART/RCTConvert+ART.m +++ b/Libraries/ART/RCTConvert+ART.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTConvert+ART.h" diff --git a/Libraries/ART/ReactNativeART.js b/Libraries/ART/ReactNativeART.js index 4a56d0275822ee..7d9f1b59063459 100644 --- a/Libraries/ART/ReactNativeART.js +++ b/Libraries/ART/ReactNativeART.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ReactNativeART */ diff --git a/Libraries/ART/ViewManagers/ARTGroupManager.h b/Libraries/ART/ViewManagers/ARTGroupManager.h index 0a90eb3d6c18c9..a35e09481be639 100644 --- a/Libraries/ART/ViewManagers/ARTGroupManager.h +++ b/Libraries/ART/ViewManagers/ARTGroupManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTNodeManager.h" diff --git a/Libraries/ART/ViewManagers/ARTGroupManager.m b/Libraries/ART/ViewManagers/ARTGroupManager.m index 8b277641588803..2de0d0e5688739 100644 --- a/Libraries/ART/ViewManagers/ARTGroupManager.m +++ b/Libraries/ART/ViewManagers/ARTGroupManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTGroupManager.h" diff --git a/Libraries/ART/ViewManagers/ARTNodeManager.h b/Libraries/ART/ViewManagers/ARTNodeManager.h index 22f2ef166b24cf..3a8f99e7abdc7a 100644 --- a/Libraries/ART/ViewManagers/ARTNodeManager.h +++ b/Libraries/ART/ViewManagers/ARTNodeManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ViewManagers/ARTNodeManager.m b/Libraries/ART/ViewManagers/ARTNodeManager.m index 3c697c129783aa..8e568ce6d8efd4 100644 --- a/Libraries/ART/ViewManagers/ARTNodeManager.m +++ b/Libraries/ART/ViewManagers/ARTNodeManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTNodeManager.h" diff --git a/Libraries/ART/ViewManagers/ARTRenderableManager.h b/Libraries/ART/ViewManagers/ARTRenderableManager.h index 376fcf518b3293..1e4b554f0f79f7 100644 --- a/Libraries/ART/ViewManagers/ARTRenderableManager.h +++ b/Libraries/ART/ViewManagers/ARTRenderableManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTNodeManager.h" diff --git a/Libraries/ART/ViewManagers/ARTRenderableManager.m b/Libraries/ART/ViewManagers/ARTRenderableManager.m index aaed2e31d11179..a30841b50c1046 100644 --- a/Libraries/ART/ViewManagers/ARTRenderableManager.m +++ b/Libraries/ART/ViewManagers/ARTRenderableManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTRenderableManager.h" diff --git a/Libraries/ART/ViewManagers/ARTShapeManager.h b/Libraries/ART/ViewManagers/ARTShapeManager.h index d6bc76baa09fdb..2f31b23a0eab10 100644 --- a/Libraries/ART/ViewManagers/ARTShapeManager.h +++ b/Libraries/ART/ViewManagers/ARTShapeManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTRenderableManager.h" diff --git a/Libraries/ART/ViewManagers/ARTShapeManager.m b/Libraries/ART/ViewManagers/ARTShapeManager.m index 3997586d18e4d1..57b603ca1a16b6 100644 --- a/Libraries/ART/ViewManagers/ARTShapeManager.m +++ b/Libraries/ART/ViewManagers/ARTShapeManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTShapeManager.h" diff --git a/Libraries/ART/ViewManagers/ARTSurfaceViewManager.h b/Libraries/ART/ViewManagers/ARTSurfaceViewManager.h index fc36435edb7707..5915536bd6f917 100644 --- a/Libraries/ART/ViewManagers/ARTSurfaceViewManager.h +++ b/Libraries/ART/ViewManagers/ARTSurfaceViewManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ART/ViewManagers/ARTSurfaceViewManager.m b/Libraries/ART/ViewManagers/ARTSurfaceViewManager.m index 10772b72c7f23d..54052a331d4585 100644 --- a/Libraries/ART/ViewManagers/ARTSurfaceViewManager.m +++ b/Libraries/ART/ViewManagers/ARTSurfaceViewManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTSurfaceViewManager.h" diff --git a/Libraries/ART/ViewManagers/ARTTextManager.h b/Libraries/ART/ViewManagers/ARTTextManager.h index 48da9c891f4757..c7d5304da3a3eb 100644 --- a/Libraries/ART/ViewManagers/ARTTextManager.h +++ b/Libraries/ART/ViewManagers/ARTTextManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTRenderableManager.h" diff --git a/Libraries/ART/ViewManagers/ARTTextManager.m b/Libraries/ART/ViewManagers/ARTTextManager.m index 430f26db537ab1..ac6688c3d925b9 100644 --- a/Libraries/ART/ViewManagers/ARTTextManager.m +++ b/Libraries/ART/ViewManagers/ARTTextManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "ARTTextManager.h" diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index 9797b47b36e51c..23db7680ab34e1 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ActionSheetIOS * @flow diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.h b/Libraries/ActionSheetIOS/RCTActionSheetManager.h index 313939149fd1a6..b9a5b2df7329a1 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.h +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 9f550f77af32a4..91f047323769c7 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTActionSheetManager.h" diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 3f2e2379eeb44a..bcb51714440444 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Alert * @flow @@ -30,14 +28,14 @@ type Options = { /** * Launches an alert dialog with the specified title and message. - * + * * See http://facebook.github.io/react-native/docs/alert.html */ class Alert { /** * Launches an alert dialog with the specified title and message. - * + * * See http://facebook.github.io/react-native/docs/alert.html#alert */ static alert( diff --git a/Libraries/Alert/AlertIOS.js b/Libraries/Alert/AlertIOS.js index b42b57c29ae481..b254406462399e 100644 --- a/Libraries/Alert/AlertIOS.js +++ b/Libraries/Alert/AlertIOS.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AlertIOS * @flow @@ -103,7 +101,7 @@ class AlertIOS { /** * Create and display a prompt to enter some text. - * + * * See http://facebook.github.io/react-native/docs/alertios.html#prompt */ static prompt( @@ -122,11 +120,10 @@ class AlertIOS { 'keyboardType) and the old syntax will be removed in a future version.'); var callback = type; - var defaultValue = message; RCTAlertManager.alertWithArgs({ title: title || '', type: 'plain-text', - defaultValue, + defaultValue: message, }, (id, value) => { callback(value); }); diff --git a/Libraries/Alert/RCTAlertManager.android.js b/Libraries/Alert/RCTAlertManager.android.js index f8ad604e16da60..f819b55e1b3d1f 100644 --- a/Libraries/Alert/RCTAlertManager.android.js +++ b/Libraries/Alert/RCTAlertManager.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule RCTAlertManager */ diff --git a/Libraries/Alert/RCTAlertManager.ios.js b/Libraries/Alert/RCTAlertManager.ios.js index 409ecf5caf0430..3aef740abed4d5 100644 --- a/Libraries/Alert/RCTAlertManager.ios.js +++ b/Libraries/Alert/RCTAlertManager.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule RCTAlertManager * @flow diff --git a/Libraries/Animated/release/gulpfile.js b/Libraries/Animated/release/gulpfile.js index 3d2a52c4a40405..b454ea790c2731 100644 --- a/Libraries/Animated/release/gulpfile.js +++ b/Libraries/Animated/release/gulpfile.js @@ -1,10 +1,8 @@ /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2013-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * @providesModule gulpfile */ @@ -32,13 +30,10 @@ var PRODUCTION_HEADER = [ '/**', ' * Animated v<%= version %>', ' *', - ' * Copyright 2013-2015, Facebook, Inc.', - ' * All rights reserved.', - ' *', - ' * This source code is licensed under the BSD-style license found in the', - ' * LICENSE file in the root directory of this source tree. An additional grant', - ' * of patent rights can be found in the PATENTS file in the same directory.', + ' * Copyright (c) 2013-present, Facebook, Inc.', ' *', + ' * This source code is licensed under the MIT license found in the', + ' * LICENSE file in the root directory of this source tree.', ' */' ].join('\n') + '\n'; diff --git a/Libraries/Animated/release/package.json b/Libraries/Animated/release/package.json index 33654f7eae10e2..74f457a4dcd33c 100644 --- a/Libraries/Animated/release/package.json +++ b/Libraries/Animated/release/package.json @@ -7,7 +7,7 @@ "animated", "animation" ], - "license": "BSD-3-Clause", + "license": "MIT", "main": "Animated.js", "dependencies": { "fbjs": "^0.2.1" diff --git a/Libraries/Animated/src/Animated.js b/Libraries/Animated/src/Animated.js index 1eacd03c48c66e..32ec9ff8046954 100644 --- a/Libraries/Animated/src/Animated.js +++ b/Libraries/Animated/src/Animated.js @@ -1,37 +1,30 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Animated * @flow + * @format */ -'use strict'; - -var AnimatedImplementation = require('AnimatedImplementation'); -var Image = require('Image'); -var Text = require('Text'); -var View = require('View'); +'use strict'; -let AnimatedScrollView; +const AnimatedImplementation = require('AnimatedImplementation'); +const Image = require('Image'); +const ScrollView = require('ScrollView'); +const Text = require('Text'); +const View = require('View'); const Animated = { View: AnimatedImplementation.createAnimatedComponent(View), Text: AnimatedImplementation.createAnimatedComponent(Text), Image: AnimatedImplementation.createAnimatedComponent(Image), - get ScrollView() { - // Make this lazy to avoid circular reference. - if (!AnimatedScrollView) { - AnimatedScrollView = AnimatedImplementation.createAnimatedComponent(require('ScrollView')); - } - return AnimatedScrollView; - }, + ScrollView: AnimatedImplementation.createAnimatedComponent(ScrollView), }; Object.assign((Animated: Object), AnimatedImplementation); -module.exports = ((Animated: any): (typeof AnimatedImplementation) & typeof Animated); +module.exports = ((Animated: any): typeof AnimatedImplementation & + typeof Animated); diff --git a/Libraries/Animated/src/AnimatedEvent.js b/Libraries/Animated/src/AnimatedEvent.js index 206516f5d96a95..f9300feb4e79ea 100644 --- a/Libraries/Animated/src/AnimatedEvent.js +++ b/Libraries/Animated/src/AnimatedEvent.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedEvent * @flow diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index 08d69c3bd80eca..9291a7956531e3 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedImplementation * @flow @@ -22,6 +20,7 @@ const AnimatedModulo = require('./nodes/AnimatedModulo'); const AnimatedMultiplication = require('./nodes/AnimatedMultiplication'); const AnimatedNode = require('./nodes/AnimatedNode'); const AnimatedProps = require('./nodes/AnimatedProps'); +const AnimatedSubtraction = require('./nodes/AnimatedSubtraction'); const AnimatedTracking = require('./nodes/AnimatedTracking'); const AnimatedValue = require('./nodes/AnimatedValue'); const AnimatedValueXY = require('./nodes/AnimatedValueXY'); @@ -41,7 +40,7 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation'; import type {SpringAnimationConfig} from './animations/SpringAnimation'; import type {Mapping, EventConfig} from './AnimatedEvent'; -type CompositeAnimation = { +export type CompositeAnimation = { start: (callback?: ?EndCallback) => void, stop: () => void, reset: () => void, @@ -56,6 +55,13 @@ const add = function( return new AnimatedAddition(a, b); }; +const subtract = function( + a: AnimatedNode | number, + b: AnimatedNode | number, +): AnimatedSubtraction { + return new AnimatedSubtraction(a, b); +}; + const divide = function( a: AnimatedNode | number, b: AnimatedNode | number, @@ -523,7 +529,7 @@ module.exports = { /** * 2D value class for driving 2D animations, such as pan gestures. * - * See https://facebook.github.io/react-native/releases/next/docs/animatedvaluexy.html + * See https://facebook.github.io/react-native/docs/animatedvaluexy.html */ ValueXY: AnimatedValueXY, /** @@ -570,6 +576,14 @@ module.exports = { */ add, + /** + * Creates a new Animated value composed by subtracting the second Animated + * value from the first Animated value. + * + * See http://facebook.github.io/react-native/docs/animated.html#subtract + */ + subtract, + /** * Creates a new Animated value composed by dividing the first Animated value * by the second Animated value. diff --git a/Libraries/Animated/src/AnimatedWeb.js b/Libraries/Animated/src/AnimatedWeb.js index b88acb940bd65b..f3af397b740931 100644 --- a/Libraries/Animated/src/AnimatedWeb.js +++ b/Libraries/Animated/src/AnimatedWeb.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @providesModule AnimatedWeb diff --git a/Libraries/Animated/src/Easing.js b/Libraries/Animated/src/Easing.js index 6cad73c334ccbe..f5c00fd813f7dc 100644 --- a/Libraries/Animated/src/Easing.js +++ b/Libraries/Animated/src/Easing.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Easing * @flow diff --git a/Libraries/Animated/src/NativeAnimatedHelper.js b/Libraries/Animated/src/NativeAnimatedHelper.js index 6bebbe427cb50e..68bf4563fa9597 100644 --- a/Libraries/Animated/src/NativeAnimatedHelper.js +++ b/Libraries/Animated/src/NativeAnimatedHelper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule NativeAnimatedHelper * @flow @@ -147,6 +145,15 @@ const API = { const STYLES_WHITELIST = { opacity: true, transform: true, + borderRadius: true, + borderBottomEndRadius: true, + borderBottomLeftRadius: true, + borderBottomRightRadius: true, + borderBottomStartRadius: true, + borderTopEndRadius: true, + borderTopLeftRadius: true, + borderTopRightRadius: true, + borderTopStartRadius: true, /* ios styles */ shadowOpacity: true, shadowRadius: true, diff --git a/Libraries/Animated/src/SpringConfig.js b/Libraries/Animated/src/SpringConfig.js index e74d167efecedc..5b476f6723469e 100644 --- a/Libraries/Animated/src/SpringConfig.js +++ b/Libraries/Animated/src/SpringConfig.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SpringConfig * @flow diff --git a/Libraries/Animated/src/__tests__/Animated-test.js b/Libraries/Animated/src/__tests__/Animated-test.js index 1ddbb38d559f06..d6409d7f8a9224 100644 --- a/Libraries/Animated/src/__tests__/Animated-test.js +++ b/Libraries/Animated/src/__tests__/Animated-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 */ @@ -94,11 +92,11 @@ describe('Animated tests', () => { opacity: anim, }, }; - c.componentWillMount(); + c.UNSAFE_componentWillMount(); expect(anim.__detach).not.toBeCalled(); c._component = {}; - c.componentWillReceiveProps({ + c.UNSAFE_componentWillReceiveProps({ style: { opacity: anim, }, @@ -120,7 +118,7 @@ describe('Animated tests', () => { opacity: anim, }, }; - c.componentWillMount(); + c.UNSAFE_componentWillMount(); Animated.timing(anim, {toValue: 10, duration: 1000}).start(callback); c._component = {}; diff --git a/Libraries/Animated/src/__tests__/AnimatedNative-test.js b/Libraries/Animated/src/__tests__/AnimatedNative-test.js index 08388069d59ef4..f04d5afb1429a3 100644 --- a/Libraries/Animated/src/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/src/__tests__/AnimatedNative-test.js @@ -1,20 +1,22 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 */ 'use strict'; +const ClassComponentMock = class {}; +ClassComponentMock.prototype.isReactComponent = true; + jest .clearAllMocks() - .setMock('Text', {}) - .setMock('View', {}) - .setMock('Image', {}) + .setMock('Text', ClassComponentMock) + .setMock('View', ClassComponentMock) + .setMock('Image', ClassComponentMock) + .setMock('ScrollView', ClassComponentMock) .setMock('React', {Component: class {}}) .setMock('NativeModules', { NativeAnimatedModule: {}, @@ -29,7 +31,7 @@ const NativeAnimatedHelper = require('NativeAnimatedHelper'); function createAndMountComponent(ComponentClass, props) { const component = new ComponentClass(); component.props = props; - component.componentWillMount(); + component.UNSAFE_componentWillMount(); // Simulate that refs were set. component._component = {}; component.componentDidMount(); @@ -331,6 +333,38 @@ describe('Native Animated', () => { .toBeCalledWith(additionCall[1].input[1], {type: 'value', value: 2, offset: 0}); }); + it('sends a valid graph description for Animated.subtract nodes', () => { + const first = new Animated.Value(2); + const second = new Animated.Value(1); + first.__makeNative(); + second.__makeNative(); + + createAndMountComponent(Animated.View, { + style: { + opacity: Animated.subtract(first, second), + }, + }); + + expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith( + expect.any(Number), + {type: 'subtraction', input: expect.any(Array)}, + ); + const subtractionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter( + (call) => call[1].type === 'subtraction' + ); + expect(subtractionCalls.length).toBe(1); + const subtractionCall = subtractionCalls[0]; + const subtractionNodeTag = subtractionCall[0]; + const subtractionConnectionCalls = nativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + (call) => call[1] === subtractionNodeTag + ); + expect(subtractionConnectionCalls.length).toBe(2); + expect(nativeAnimatedModule.createAnimatedNode) + .toBeCalledWith(subtractionCall[1].input[0], {type: 'value', value: 2, offset: 0}); + expect(nativeAnimatedModule.createAnimatedNode) + .toBeCalledWith(subtractionCall[1].input[1], {type: 'value', value: 1, offset: 0}); + }); + it('sends a valid graph description for Animated.multiply nodes', () => { const first = new Animated.Value(2); const second = new Animated.Value(1); diff --git a/Libraries/Animated/src/__tests__/Easing-test.js b/Libraries/Animated/src/__tests__/Easing-test.js index 048fdb711d3a49..14f18aacd628e0 100644 --- a/Libraries/Animated/src/__tests__/Easing-test.js +++ b/Libraries/Animated/src/__tests__/Easing-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 */ diff --git a/Libraries/Animated/src/__tests__/Interpolation-test.js b/Libraries/Animated/src/__tests__/Interpolation-test.js index e95365423cb09b..27f4438ab1568d 100644 --- a/Libraries/Animated/src/__tests__/Interpolation-test.js +++ b/Libraries/Animated/src/__tests__/Interpolation-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 */ diff --git a/Libraries/Animated/src/animations/Animation.js b/Libraries/Animated/src/animations/Animation.js index 90ea28196ed014..000e44d77f9bc8 100644 --- a/Libraries/Animated/src/animations/Animation.js +++ b/Libraries/Animated/src/animations/Animation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Animation * @flow diff --git a/Libraries/Animated/src/animations/DecayAnimation.js b/Libraries/Animated/src/animations/DecayAnimation.js index 652bd9c9d3b708..7df0e104b72f48 100644 --- a/Libraries/Animated/src/animations/DecayAnimation.js +++ b/Libraries/Animated/src/animations/DecayAnimation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DecayAnimation * @flow diff --git a/Libraries/Animated/src/animations/SpringAnimation.js b/Libraries/Animated/src/animations/SpringAnimation.js index 67dee081b81b6a..8b6f96fe67bdb6 100644 --- a/Libraries/Animated/src/animations/SpringAnimation.js +++ b/Libraries/Animated/src/animations/SpringAnimation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SpringAnimation * @flow diff --git a/Libraries/Animated/src/animations/TimingAnimation.js b/Libraries/Animated/src/animations/TimingAnimation.js index a3db014fe1190c..1b6a4ae94cd9b0 100644 --- a/Libraries/Animated/src/animations/TimingAnimation.js +++ b/Libraries/Animated/src/animations/TimingAnimation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule TimingAnimation * @flow diff --git a/Libraries/Animated/src/createAnimatedComponent.js b/Libraries/Animated/src/createAnimatedComponent.js index 2e10a6c71427e3..357ee0bd59bcd1 100644 --- a/Libraries/Animated/src/createAnimatedComponent.js +++ b/Libraries/Animated/src/createAnimatedComponent.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule createAnimatedComponent * @flow @@ -17,7 +15,16 @@ const AnimatedProps = require('./nodes/AnimatedProps'); const React = require('React'); const ViewStylePropTypes = require('ViewStylePropTypes'); +const invariant = require('fbjs/lib/invariant'); + function createAnimatedComponent(Component: any): any { + invariant( + typeof Component === 'string' || + (Component.prototype && Component.prototype.isReactComponent), + '`createAnimatedComponent` does not support stateless functional components; ' + + 'use a class component instead.', + ); + class AnimatedComponent extends React.Component { _component: any; _invokeAnimatedPropsCallbackOnMount: boolean = false; @@ -42,7 +49,7 @@ function createAnimatedComponent(Component: any): any { this._component.setNativeProps(props); } - componentWillMount() { + UNSAFE_componentWillMount() { this._attachProps(this.props); } @@ -127,7 +134,7 @@ function createAnimatedComponent(Component: any): any { oldPropsAnimated && oldPropsAnimated.__detach(); } - componentWillReceiveProps(newProps) { + UNSAFE_componentWillReceiveProps(newProps) { this._attachProps(newProps); } diff --git a/Libraries/Animated/src/nodes/AnimatedAddition.js b/Libraries/Animated/src/nodes/AnimatedAddition.js index 53d338836ecf8b..2e3453965565f0 100644 --- a/Libraries/Animated/src/nodes/AnimatedAddition.js +++ b/Libraries/Animated/src/nodes/AnimatedAddition.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedAddition * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedDiffClamp.js b/Libraries/Animated/src/nodes/AnimatedDiffClamp.js index eac26a10271b53..0f64e75c723c06 100644 --- a/Libraries/Animated/src/nodes/AnimatedDiffClamp.js +++ b/Libraries/Animated/src/nodes/AnimatedDiffClamp.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedDiffClamp * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedDivision.js b/Libraries/Animated/src/nodes/AnimatedDivision.js index 8d658f458a5463..606e63937b9a86 100644 --- a/Libraries/Animated/src/nodes/AnimatedDivision.js +++ b/Libraries/Animated/src/nodes/AnimatedDivision.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedDivision * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedInterpolation.js b/Libraries/Animated/src/nodes/AnimatedInterpolation.js index 141929e5be1020..eb4cc5d6995d77 100644 --- a/Libraries/Animated/src/nodes/AnimatedInterpolation.js +++ b/Libraries/Animated/src/nodes/AnimatedInterpolation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedInterpolation * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedModulo.js b/Libraries/Animated/src/nodes/AnimatedModulo.js index 3ff75e737216da..24cd3f0b077c12 100644 --- a/Libraries/Animated/src/nodes/AnimatedModulo.js +++ b/Libraries/Animated/src/nodes/AnimatedModulo.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedModulo * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedMultiplication.js b/Libraries/Animated/src/nodes/AnimatedMultiplication.js index d30ce2594a1675..dc01f7f17127f1 100644 --- a/Libraries/Animated/src/nodes/AnimatedMultiplication.js +++ b/Libraries/Animated/src/nodes/AnimatedMultiplication.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedMultiplication * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedNode.js b/Libraries/Animated/src/nodes/AnimatedNode.js index c29f4b7f1a80b0..e75cfaf0e5c8fb 100644 --- a/Libraries/Animated/src/nodes/AnimatedNode.js +++ b/Libraries/Animated/src/nodes/AnimatedNode.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedNode * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedProps.js b/Libraries/Animated/src/nodes/AnimatedProps.js index 0b9f6508d1526d..78cd11189edfa7 100644 --- a/Libraries/Animated/src/nodes/AnimatedProps.js +++ b/Libraries/Animated/src/nodes/AnimatedProps.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedProps * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedStyle.js b/Libraries/Animated/src/nodes/AnimatedStyle.js index f2cdf31dfdea0a..c7bb24e3b42b14 100644 --- a/Libraries/Animated/src/nodes/AnimatedStyle.js +++ b/Libraries/Animated/src/nodes/AnimatedStyle.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedStyle * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedSubtraction.js b/Libraries/Animated/src/nodes/AnimatedSubtraction.js new file mode 100644 index 00000000000000..610fc226eb65a8 --- /dev/null +++ b/Libraries/Animated/src/nodes/AnimatedSubtraction.js @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule AnimatedSubtraction + * @flow + * @format + */ +'use strict'; + +const AnimatedInterpolation = require('./AnimatedInterpolation'); +const AnimatedNode = require('./AnimatedNode'); +const AnimatedValue = require('./AnimatedValue'); +const AnimatedWithChildren = require('./AnimatedWithChildren'); + +import type {InterpolationConfigType} from './AnimatedInterpolation'; + +class AnimatedSubtraction extends AnimatedWithChildren { + _a: AnimatedNode; + _b: AnimatedNode; + + constructor(a: AnimatedNode | number, b: AnimatedNode | number) { + super(); + this._a = typeof a === 'number' ? new AnimatedValue(a) : a; + this._b = typeof b === 'number' ? new AnimatedValue(b) : b; + } + + __makeNative() { + this._a.__makeNative(); + this._b.__makeNative(); + super.__makeNative(); + } + + __getValue(): number { + return this._a.__getValue() - this._b.__getValue(); + } + + interpolate(config: InterpolationConfigType): AnimatedInterpolation { + return new AnimatedInterpolation(this, config); + } + + __attach(): void { + this._a.__addChild(this); + this._b.__addChild(this); + } + + __detach(): void { + this._a.__removeChild(this); + this._b.__removeChild(this); + super.__detach(); + } + + __getNativeConfig(): any { + return { + type: 'subtraction', + input: [this._a.__getNativeTag(), this._b.__getNativeTag()], + }; + } +} + +module.exports = AnimatedSubtraction; diff --git a/Libraries/Animated/src/nodes/AnimatedTracking.js b/Libraries/Animated/src/nodes/AnimatedTracking.js index 1a54f78abb5a23..cf20d6e8bbf3fc 100644 --- a/Libraries/Animated/src/nodes/AnimatedTracking.js +++ b/Libraries/Animated/src/nodes/AnimatedTracking.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedTracking * @flow @@ -14,6 +12,10 @@ const AnimatedValue = require('./AnimatedValue'); const AnimatedNode = require('./AnimatedNode'); +const { + generateNewAnimationId, + shouldUseNativeDriver, +} = require('../NativeAnimatedHelper'); import type {EndCallback} from '../animations/Animation'; @@ -23,6 +25,7 @@ class AnimatedTracking extends AnimatedNode { _callback: ?EndCallback; _animationConfig: Object; _animationClass: any; + _useNativeDriver: boolean; constructor( value: AnimatedValue, @@ -36,16 +39,32 @@ class AnimatedTracking extends AnimatedNode { this._parent = parent; this._animationClass = animationClass; this._animationConfig = animationConfig; + this._useNativeDriver = shouldUseNativeDriver(animationConfig); this._callback = callback; this.__attach(); } + __makeNative() { + this.__isNative = true; + this._parent.__makeNative(); + super.__makeNative(); + this._value.__makeNative(); + } + __getValue(): Object { return this._parent.__getValue(); } __attach(): void { this._parent.__addChild(this); + if (this._useNativeDriver) { + // when the tracking starts we need to convert this node to a "native node" + // so that the parent node will be made "native" too. This is necessary as + // 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(); + } } __detach(): void { @@ -62,6 +81,22 @@ class AnimatedTracking extends AnimatedNode { this._callback, ); } + + __getNativeConfig(): any { + const animation = new this._animationClass({ + ...this._animationConfig, + // remove toValue from the config as it's a ref to Animated.Value + toValue: undefined, + }); + const animationConfig = animation.__getNativeAnimationConfig(); + return { + type: 'tracking', + animationId: generateNewAnimationId(), + animationConfig, + toValue: this._parent.__getNativeTag(), + value: this._value.__getNativeTag(), + }; + } } module.exports = AnimatedTracking; diff --git a/Libraries/Animated/src/nodes/AnimatedTransform.js b/Libraries/Animated/src/nodes/AnimatedTransform.js index c95aa16f699d2b..48f82f9fe3443d 100644 --- a/Libraries/Animated/src/nodes/AnimatedTransform.js +++ b/Libraries/Animated/src/nodes/AnimatedTransform.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedTransform * @flow @@ -17,9 +15,9 @@ const AnimatedWithChildren = require('./AnimatedWithChildren'); const NativeAnimatedHelper = require('../NativeAnimatedHelper'); class AnimatedTransform extends AnimatedWithChildren { - _transforms: Array; + _transforms: $ReadOnlyArray; - constructor(transforms: Array) { + constructor(transforms: $ReadOnlyArray) { super(); this._transforms = transforms; } @@ -36,7 +34,7 @@ class AnimatedTransform extends AnimatedWithChildren { }); } - __getValue(): Array { + __getValue(): $ReadOnlyArray { return this._transforms.map(transform => { const result = {}; for (const key in transform) { @@ -51,7 +49,7 @@ class AnimatedTransform extends AnimatedWithChildren { }); } - __getAnimatedValue(): Array { + __getAnimatedValue(): $ReadOnlyArray { return this._transforms.map(transform => { const result = {}; for (const key in transform) { diff --git a/Libraries/Animated/src/nodes/AnimatedValue.js b/Libraries/Animated/src/nodes/AnimatedValue.js index 49f440471e1ba3..9d06c751cefbea 100644 --- a/Libraries/Animated/src/nodes/AnimatedValue.js +++ b/Libraries/Animated/src/nodes/AnimatedValue.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedValue * @flow @@ -20,6 +18,7 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper'); import type Animation, {EndCallback} from '../animations/Animation'; import type {InterpolationConfigType} from './AnimatedInterpolation'; +import type AnimatedTracking from './AnimatedTracking'; const NativeAnimatedAPI = NativeAnimatedHelper.API; @@ -52,6 +51,9 @@ let _uniqueId = 1; function _flush(rootNode: AnimatedValue): void { const animatedStyles = new Set(); function findAnimatedStyles(node) { + /* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an + * error found when Flow v0.68 was deployed. To see the error delete this + * comment and run Flow. */ if (typeof node.update === 'function') { animatedStyles.add(node); } else { @@ -76,7 +78,7 @@ class AnimatedValue extends AnimatedWithChildren { _startingValue: number; _offset: number; _animation: ?Animation; - _tracking: ?AnimatedNode; + _tracking: ?AnimatedTracking; _listeners: {[key: string]: ValueListenerCallback}; __nativeAnimatedValueListener: ?any; @@ -311,7 +313,7 @@ class AnimatedValue extends AnimatedWithChildren { /** * Typically only used internally. */ - track(tracking: AnimatedNode): void { + track(tracking: AnimatedTracking): void { this.stopTracking(); this._tracking = tracking; } diff --git a/Libraries/Animated/src/nodes/AnimatedValueXY.js b/Libraries/Animated/src/nodes/AnimatedValueXY.js index 13aee1e50d1cde..52c207c0f42ffe 100644 --- a/Libraries/Animated/src/nodes/AnimatedValueXY.js +++ b/Libraries/Animated/src/nodes/AnimatedValueXY.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedValueXY * @flow diff --git a/Libraries/Animated/src/nodes/AnimatedWithChildren.js b/Libraries/Animated/src/nodes/AnimatedWithChildren.js index 4676437a9eae47..1f58cd834e165e 100644 --- a/Libraries/Animated/src/nodes/AnimatedWithChildren.js +++ b/Libraries/Animated/src/nodes/AnimatedWithChildren.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AnimatedWithChildren * @flow diff --git a/Libraries/Animated/src/polyfills/InteractionManager.js b/Libraries/Animated/src/polyfills/InteractionManager.js index db45ede6426fd0..c063e9234b3df1 100644 --- a/Libraries/Animated/src/polyfills/InteractionManager.js +++ b/Libraries/Animated/src/polyfills/InteractionManager.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/Libraries/Animated/src/polyfills/Set.js b/Libraries/Animated/src/polyfills/Set.js index 988f0b3f13ff21..fd071410d42395 100644 --- a/Libraries/Animated/src/polyfills/Set.js +++ b/Libraries/Animated/src/polyfills/Set.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/Libraries/Animated/src/polyfills/flattenStyle.js b/Libraries/Animated/src/polyfills/flattenStyle.js index 42a68020c6539c..2e4c8a1d36b476 100644 --- a/Libraries/Animated/src/polyfills/flattenStyle.js +++ b/Libraries/Animated/src/polyfills/flattenStyle.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; module.exports = function(style) { diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index ebdb6d54913bb4..f2faa9480d2b57 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AppState * @flow @@ -47,8 +45,8 @@ class AppState extends NativeEventEmitter { let eventUpdated = false; // TODO: this is a terrible solution - in order to ensure `currentState` - // prop is up to date, we have to register an observer that updates it - // whenever the state changes, even if nobody cares. We should just + // prop is up to date, we have to register an observer that updates it + // whenever the state changes, even if nobody cares. We should just // deprecate the `currentState` property and get rid of this. this.addListener( 'appStateDidChange', @@ -72,14 +70,14 @@ class AppState extends NativeEventEmitter { } // TODO: now that AppState is a subclass of NativeEventEmitter, we could - // deprecate `addEventListener` and `removeEventListener` and just use - // addListener` and `listener.remove()` directly. That will be a breaking + // deprecate `addEventListener` and `removeEventListener` and just use + // addListener` and `listener.remove()` directly. That will be a breaking // change though, as both the method and event names are different // (addListener events are currently required to be globally unique). /** * Add a handler to AppState changes by listening to the `change` event type * and providing the handler. - * + * * See http://facebook.github.io/react-native/docs/appstate.html#addeventlistener */ addEventListener( @@ -107,7 +105,7 @@ class AppState extends NativeEventEmitter { /** * Remove a handler by passing the `change` event type and the handler. - * + * * See http://facebook.github.io/react-native/docs/appstate.html#removeeventlistener */ removeEventListener( diff --git a/Libraries/BatchedBridge/BatchedBridge.js b/Libraries/BatchedBridge/BatchedBridge.js index 46e8b5f41052a8..516c2ac1e22339 100644 --- a/Libraries/BatchedBridge/BatchedBridge.js +++ b/Libraries/BatchedBridge/BatchedBridge.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule BatchedBridge * @flow @@ -13,20 +11,7 @@ const MessageQueue = require('MessageQueue'); -// MessageQueue can install a global handler to catch all exceptions where JS users can register their own behavior -// This handler makes all exceptions to be handled inside MessageQueue rather than by the VM at its origin -// This makes stacktraces to be placed at MessageQueue rather than at where they were launched -// The parameter __fbUninstallRNGlobalErrorHandler is passed to MessageQueue to prevent the handler from being installed -// -// __fbUninstallRNGlobalErrorHandler is conditionally set by the Inspector while the VM is paused for initialization -// If the Inspector isn't present it defaults to undefined and the global error handler is installed -// The Inspector can still call MessageQueue#uninstallGlobalErrorHandler to uninstalled on attach - -const BatchedBridge = new MessageQueue( - // $FlowFixMe - typeof __fbUninstallRNGlobalErrorHandler !== 'undefined' && - __fbUninstallRNGlobalErrorHandler === true, // eslint-disable-line no-undef -); +const BatchedBridge = new MessageQueue(); // Wire up the batched bridge on the global object so that we can call into it. // Ideally, this would be the inverse relationship. I.e. the native environment diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 4309de35519cf6..ef689333917db1 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule MessageQueue * @flow @@ -46,8 +44,8 @@ let JSTimers = null; class MessageQueue { _lazyCallableModules: {[key: string]: (void) => Object}; _queue: [number[], number[], any[], number]; - _successCallbacks: (?Function)[]; - _failureCallbacks: (?Function)[]; + _successCallbacks: {[key: number]: ?Function}; + _failureCallbacks: {[key: number]: ?Function}; _callID: number; _inCall: number; _lastFlush: number; @@ -59,21 +57,14 @@ class MessageQueue { __spy: ?(data: SpyData) => void; - __guard: (() => void) => void; - - constructor(shouldUninstallGlobalErrorHandler: boolean = false) { + constructor() { this._lazyCallableModules = {}; this._queue = [[], [], [], 0]; - this._successCallbacks = []; - this._failureCallbacks = []; + this._successCallbacks = {}; + this._failureCallbacks = {}; this._callID = 0; this._lastFlush = 0; this._eventLoopStartTime = new Date().getTime(); - if (shouldUninstallGlobalErrorHandler) { - this.uninstallGlobalErrorHandler(); - } else { - this.installGlobalErrorHandler(); - } if (__DEV__) { this._debugInfo = {}; @@ -291,34 +282,39 @@ class MessageQueue { } } - uninstallGlobalErrorHandler() { - this.__guard = this.__guardUnsafe; - } - - installGlobalErrorHandler() { - this.__guard = this.__guardSafe; - } - /** * Private methods */ - // Lets exceptions propagate to be handled by the VM at the origin - __guardUnsafe(fn: () => void) { + __guard(fn: () => void) { this._inCall++; - fn(); + if (this.__shouldPauseOnThrow()) { + fn(); + } else { + try { + fn(); + } catch (error) { + ErrorUtils.reportFatalError(error); + } + } this._inCall--; } - __guardSafe(fn: () => void) { - this._inCall++; - try { - fn(); - } catch (error) { - ErrorUtils.reportFatalError(error); - } finally { - this._inCall--; - } + // MessageQueue installs a global handler to catch all exceptions where JS users can register their own behavior + // This handler makes all exceptions to be propagated from inside MessageQueue rather than by the VM at their origin + // This makes stacktraces to be placed at MessageQueue rather than at where they were launched + // The parameter DebuggerInternal.shouldPauseOnThrow is used to check before catching all exceptions and + // can be configured by the VM or any Inspector + __shouldPauseOnThrow() { + return ( + // $FlowFixMe + (typeof DebuggerInternal !== 'undefined' && + DebuggerInternal.shouldPauseOnThrow === true) || // eslint-disable-line no-undef + // FIXME(festevezga) Remove once T24034309 is rolled out internally + // $FlowFixMe + (typeof __fbUninstallRNGlobalErrorHandler !== 'undefined' && + __fbUninstallRNGlobalErrorHandler === true) // eslint-disable-line no-undef + ); } __callImmediates() { @@ -396,7 +392,8 @@ class MessageQueue { return; } - this._successCallbacks[callID] = this._failureCallbacks[callID] = null; + delete this._successCallbacks[callID]; + delete this._failureCallbacks[callID]; callback(...args); if (__DEV__) { diff --git a/Libraries/BatchedBridge/NativeModules.js b/Libraries/BatchedBridge/NativeModules.js index 2bf0f26c875119..324c4f6e995bdd 100644 --- a/Libraries/BatchedBridge/NativeModules.js +++ b/Libraries/BatchedBridge/NativeModules.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule NativeModules * @flow diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js index 09ec56663b5c46..40ad81f5f5cb5f 100644 --- a/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +++ b/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * These don't actually exist anywhere in the code. */ diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js index 380bacf65e2c66..8c4f7d3c03063f 100644 --- a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +++ b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * */ 'use strict'; diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index 106821dd2fcffe..555a9e2053be33 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 * @format @@ -127,59 +125,27 @@ describe('MessageQueue', function() { expect(factory).toHaveBeenCalledTimes(1); }); - it('should catch all exceptions if the global error handler is installed', () => { - const errorMessage = 'intentional error'; - const errorModule = { - explode: function() { - throw new Error(errorMessage); - }, + it('should check if the global error handler is not overriden by the DebuggerInternal object', () => { + const dummyModule = { + dummy: function() {}, }; - const name = 'errorModuleName'; - const factory = jest.fn(() => errorModule); - queue.__guardSafe = jest.fn(() => {}); - queue.__guardUnsafe = jest.fn(() => {}); - queue.installGlobalErrorHandler(); - queue.registerLazyCallableModule(name, factory); - queue.callFunctionReturnFlushedQueue(name, 'explode', []); - expect(queue.__guardUnsafe).toHaveBeenCalledTimes(0); - expect(queue.__guardSafe).toHaveBeenCalledTimes(2); - }); - - it('should propagate exceptions if the global error handler is uninstalled', () => { - queue.uninstallGlobalErrorHandler(); - const errorMessage = 'intentional error'; - const errorModule = { - explode: function() { - throw new Error(errorMessage); - }, - }; - const name = 'errorModuleName'; - const factory = jest.fn(() => errorModule); - queue.__guardUnsafe = jest.fn(() => {}); - queue.__guardSafe = jest.fn(() => {}); + const name = 'emptyModuleName'; + const factory = jest.fn(() => dummyModule); + queue.__shouldPauseOnThrow = jest.fn(() => false); queue.registerLazyCallableModule(name, factory); - queue.uninstallGlobalErrorHandler(); - queue.callFunctionReturnFlushedQueue(name, 'explode'); - expect(queue.__guardUnsafe).toHaveBeenCalledTimes(2); - expect(queue.__guardSafe).toHaveBeenCalledTimes(0); + queue.callFunctionReturnFlushedQueue(name, 'dummy', []); + expect(queue.__shouldPauseOnThrow).toHaveBeenCalledTimes(2); }); - it('should catch all exceptions if the global error handler is re-installed', () => { - const errorMessage = 'intentional error'; - const errorModule = { - explode: function() { - throw new Error(errorMessage); - }, + it('should check if the global error handler is overriden by the DebuggerInternal object', () => { + const dummyModule = { + dummy: function() {}, }; - const name = 'errorModuleName'; - const factory = jest.fn(() => errorModule); - queue.__guardUnsafe = jest.fn(() => {}); - queue.__guardSafe = jest.fn(() => {}); + const name = 'emptyModuleName'; + const factory = jest.fn(() => dummyModule); + queue.__shouldPauseOnThrow = jest.fn(() => true); queue.registerLazyCallableModule(name, factory); - queue.uninstallGlobalErrorHandler(); - queue.installGlobalErrorHandler(); - queue.callFunctionReturnFlushedQueue(name, 'explode'); - expect(queue.__guardUnsafe).toHaveBeenCalledTimes(0); - expect(queue.__guardSafe).toHaveBeenCalledTimes(2); + queue.callFunctionReturnFlushedQueue(name, 'dummy', []); + expect(queue.__shouldPauseOnThrow).toHaveBeenCalledTimes(2); }); }); diff --git a/Libraries/BatchedBridge/__tests__/NativeModules-test.js b/Libraries/BatchedBridge/__tests__/NativeModules-test.js index 88435513e72966..b9cc2411d29512 100644 --- a/Libraries/BatchedBridge/__tests__/NativeModules-test.js +++ b/Libraries/BatchedBridge/__tests__/NativeModules-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 */ diff --git a/Libraries/Blob/Blob.js b/Libraries/Blob/Blob.js index 3f077a05d71fc1..eca13a6a309e8f 100644 --- a/Libraries/Blob/Blob.js +++ b/Libraries/Blob/Blob.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Blob * @flow diff --git a/Libraries/Blob/BlobManager.js b/Libraries/Blob/BlobManager.js index a1cf9b489e6007..dd7cc00eabc652 100644 --- a/Libraries/Blob/BlobManager.js +++ b/Libraries/Blob/BlobManager.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule BlobManager * @flow diff --git a/Libraries/Blob/BlobRegistry.js b/Libraries/Blob/BlobRegistry.js index 925e78f3a78453..330c1659ae4235 100644 --- a/Libraries/Blob/BlobRegistry.js +++ b/Libraries/Blob/BlobRegistry.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule BlobRegistry * @flow diff --git a/Libraries/Blob/BlobTypes.js b/Libraries/Blob/BlobTypes.js index c053c08cfc8deb..8e895d9006108f 100644 --- a/Libraries/Blob/BlobTypes.js +++ b/Libraries/Blob/BlobTypes.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule BlobTypes * @flow diff --git a/Libraries/Blob/File.js b/Libraries/Blob/File.js index 8e999b20f41dd0..f5b03d85f7f178 100644 --- a/Libraries/Blob/File.js +++ b/Libraries/Blob/File.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule File * @flow diff --git a/Libraries/Blob/FileReader.js b/Libraries/Blob/FileReader.js index 121f7ef76caa21..b3ed89dc9318e6 100644 --- a/Libraries/Blob/FileReader.js +++ b/Libraries/Blob/FileReader.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule FileReader * @flow diff --git a/Libraries/Blob/RCTBlobManager.h b/Libraries/Blob/RCTBlobManager.h index 8e8d355f60b7ac..24b589ef987ae5 100755 --- a/Libraries/Blob/RCTBlobManager.h +++ b/Libraries/Blob/RCTBlobManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/Blob/RCTBlobManager.mm b/Libraries/Blob/RCTBlobManager.mm index 8d77cd5b15f553..7c0cbb8673f064 100755 --- a/Libraries/Blob/RCTBlobManager.mm +++ b/Libraries/Blob/RCTBlobManager.mm @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTBlobManager.h" @@ -13,6 +11,7 @@ #import #import +#import #import static NSString *const kBlobURIScheme = @"blob"; @@ -259,12 +258,15 @@ - (BOOL)canHandleNetworkingResponse:(NSString *)responseType - (id)handleNetworkingResponse:(NSURLResponse *)response data:(NSData *)data { + // An empty body will have nil for data, in this case we need to return + // an empty blob as per the XMLHttpRequest spec. + data = data ?: [NSData new]; return @{ @"blobId": [self store:data], @"offset": @0, @"size": @(data.length), - @"name": [response suggestedFilename], - @"type": [response MIMEType], + @"name": RCTNullIfNil([response suggestedFilename]), + @"type": RCTNullIfNil([response MIMEType]), }; } diff --git a/Libraries/Blob/RCTFileReaderModule.h b/Libraries/Blob/RCTFileReaderModule.h index 8728c7c3dc0b67..72d224b0d968cb 100644 --- a/Libraries/Blob/RCTFileReaderModule.h +++ b/Libraries/Blob/RCTFileReaderModule.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/Blob/RCTFileReaderModule.m b/Libraries/Blob/RCTFileReaderModule.m index debbae8cbd771b..5059e0b84180ee 100644 --- a/Libraries/Blob/RCTFileReaderModule.m +++ b/Libraries/Blob/RCTFileReaderModule.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This 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/URL.js b/Libraries/Blob/URL.js index 8b761ca708ce0b..7349f7752f268c 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule URL * @format diff --git a/Libraries/Blob/__mocks__/BlobModule.js b/Libraries/Blob/__mocks__/BlobModule.js index 1cbda950883312..2542c3a9339adc 100644 --- a/Libraries/Blob/__mocks__/BlobModule.js +++ b/Libraries/Blob/__mocks__/BlobModule.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @format diff --git a/Libraries/Blob/__mocks__/FileReaderModule.js b/Libraries/Blob/__mocks__/FileReaderModule.js index d4b35e00c24cc2..f5ccc39d36e200 100644 --- a/Libraries/Blob/__mocks__/FileReaderModule.js +++ b/Libraries/Blob/__mocks__/FileReaderModule.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow * @format diff --git a/Libraries/Blob/__tests__/Blob-test.js b/Libraries/Blob/__tests__/Blob-test.js index 85532c819494f9..8d37915720c9b3 100644 --- a/Libraries/Blob/__tests__/Blob-test.js +++ b/Libraries/Blob/__tests__/Blob-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 diff --git a/Libraries/Blob/__tests__/BlobManager-test.js b/Libraries/Blob/__tests__/BlobManager-test.js index 6422861b0d2780..2ed118b446be1c 100644 --- a/Libraries/Blob/__tests__/BlobManager-test.js +++ b/Libraries/Blob/__tests__/BlobManager-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 diff --git a/Libraries/Blob/__tests__/File-test.js b/Libraries/Blob/__tests__/File-test.js index 99957873242ff6..c10f90c18766ae 100644 --- a/Libraries/Blob/__tests__/File-test.js +++ b/Libraries/Blob/__tests__/File-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 @@ -15,8 +13,39 @@ jest.setMock('NativeModules', { BlobModule: require('../__mocks__/BlobModule'), }); +const Blob = require('Blob'); const File = require('File'); +describe('babel 7 smoke test', function() { + it('should be able to extend a class with native name', function() { + let called = false; + class Array { + constructor() { + called = true; + return {foo: 'PASS'}; + } + } + class A extends Array { + constructor() { + super(); + } + } + + // there is/was a regression in Babel where this would break and super() + // would not actually invoke the constructor of the parent class if the + // parent class had a name matching a built-in class (like Blob) + expect(new A().foo).toBe('PASS'); + expect(called).toBe(true); + }); +}); + +describe('Blob', function() { + it('regression caused by circular dep && babel 7', function() { + const blob = new Blob([], {type: 'image/jpeg'}); + expect(blob).toBeInstanceOf(Blob); + }); +}); + describe('File', function() { it('should create empty file', () => { const file = new File([], 'test.jpg'); diff --git a/Libraries/Blob/__tests__/FileReader-test.js b/Libraries/Blob/__tests__/FileReader-test.js index 58a0e92f6218f7..a278a4918a9d10 100644 --- a/Libraries/Blob/__tests__/FileReader-test.js +++ b/Libraries/Blob/__tests__/FileReader-test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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 diff --git a/Libraries/BugReporting/BugReporting.js b/Libraries/BugReporting/BugReporting.js index bf795899139a69..11a59e6d5222ca 100644 --- a/Libraries/BugReporting/BugReporting.js +++ b/Libraries/BugReporting/BugReporting.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule BugReporting * @flow diff --git a/Libraries/BugReporting/dumpReactTree.js b/Libraries/BugReporting/dumpReactTree.js index 88a5b7f8ffbe2e..f8a137ceff7f2c 100644 --- a/Libraries/BugReporting/dumpReactTree.js +++ b/Libraries/BugReporting/dumpReactTree.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule dumpReactTree * @flow diff --git a/Libraries/BugReporting/getReactData.js b/Libraries/BugReporting/getReactData.js index 18f4b0888f846a..53c8fb6ccfc110 100644 --- a/Libraries/BugReporting/getReactData.js +++ b/Libraries/BugReporting/getReactData.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule getReactData * @flow diff --git a/Libraries/CameraRoll/CameraRoll.js b/Libraries/CameraRoll/CameraRoll.js index 91fba6d8fe893c..3bc48664f35db1 100644 --- a/Libraries/CameraRoll/CameraRoll.js +++ b/Libraries/CameraRoll/CameraRoll.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule CameraRoll * @flow @@ -115,8 +113,10 @@ type GetPhotosReturn = Promise<{ * Shape of the return value of the `getPhotos` function. */ const getPhotosReturnChecker = createStrictShapeTypeChecker({ - // $FlowFixMe(>=0.41.0) edges: PropTypes.arrayOf( + /* $FlowFixMe(>=0.66.0 site=react_native_fb) This comment suppresses an + * error found when Flow v0.66 was deployed. To see the error delete this + * comment and run Flow. */ createStrictShapeTypeChecker({ node: createStrictShapeTypeChecker({ type: PropTypes.string.isRequired, diff --git a/Libraries/CameraRoll/ImagePickerIOS.js b/Libraries/CameraRoll/ImagePickerIOS.js index a67884dc843571..24d1309d2e1b91 100644 --- a/Libraries/CameraRoll/ImagePickerIOS.js +++ b/Libraries/CameraRoll/ImagePickerIOS.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ImagePickerIOS * @flow diff --git a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.h b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.h index 405ba289aeda1d..8189bb56e4ea8c 100644 --- a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.h +++ b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m index 30a3baf6515a09..e9637d7c4c16b5 100644 --- a/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m +++ b/Libraries/CameraRoll/RCTAssetsLibraryRequestHandler.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTAssetsLibraryRequestHandler.h" diff --git a/Libraries/CameraRoll/RCTCameraRollManager.h b/Libraries/CameraRoll/RCTCameraRollManager.h index f2bf18cb27cf69..b8b2c7d2ad63c7 100644 --- a/Libraries/CameraRoll/RCTCameraRollManager.h +++ b/Libraries/CameraRoll/RCTCameraRollManager.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/CameraRoll/RCTCameraRollManager.m b/Libraries/CameraRoll/RCTCameraRollManager.m index 72e128d6ecad33..b5d9a85dadb44b 100644 --- a/Libraries/CameraRoll/RCTCameraRollManager.m +++ b/Libraries/CameraRoll/RCTCameraRollManager.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTCameraRollManager.h" diff --git a/Libraries/CameraRoll/RCTImagePickerManager.h b/Libraries/CameraRoll/RCTImagePickerManager.h index e3053f6a128cec..825e7721a46c01 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.h +++ b/Libraries/CameraRoll/RCTImagePickerManager.h @@ -1,10 +1,8 @@ /* - * Copyright (c) 2013, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2013-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This 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/CameraRoll/RCTImagePickerManager.m b/Libraries/CameraRoll/RCTImagePickerManager.m index e851b5fca4d3c6..1ee31752f2a992 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.m +++ b/Libraries/CameraRoll/RCTImagePickerManager.m @@ -1,10 +1,8 @@ /* - * Copyright (c) 2013, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2013-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This 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/CameraRoll/RCTPhotoLibraryImageLoader.h b/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.h index 67e5cfe5271ba8..0a45f184dab73c 100644 --- a/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.h +++ b/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.h @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import diff --git a/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m b/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m index 0c2adb7f5206df..ac27231adc9e9a 100644 --- a/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m +++ b/Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ #import "RCTPhotoLibraryImageLoader.h" diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js index 2fb4517714a588..afc4abe1533a72 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js @@ -1,40 +1,38 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AccessibilityInfo * @flow */ 'use strict'; -var NativeModules = require('NativeModules'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +const NativeModules = require('NativeModules'); +const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTAccessibilityInfo = NativeModules.AccessibilityInfo; +const RCTAccessibilityInfo = NativeModules.AccessibilityInfo; -var TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange'; +const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange'; type ChangeEventName = $Enum<{ change: string, }>; -var _subscriptions = new Map(); +const _subscriptions = new Map(); /** * Sometimes it's useful to know whether or not the device has a screen reader * that is currently active. The `AccessibilityInfo` API is designed for this - * purpose. You can use it to query the current state of the screen reader as - * well as to register to be notified when the state of the screen reader + * purpose. You can use it to query the current state of the screen reader as + * well as to register to be notified when the state of the screen reader * changes. * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html */ -var AccessibilityInfo = { +const AccessibilityInfo = { fetch: function(): Promise { return new Promise((resolve, reject) => { @@ -50,7 +48,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): void { - var listener = RCTDeviceEventEmitter.addListener( + const listener = RCTDeviceEventEmitter.addListener( TOUCH_EXPLORATION_EVENT, (enabled) => { handler(enabled); @@ -63,7 +61,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): void { - var listener = _subscriptions.get(handler); + const listener = _subscriptions.get(handler); if (!listener) { return; } diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index fb3ce8095c0e61..6e39b5e477d5fb 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -1,49 +1,47 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule AccessibilityInfo * @flow */ 'use strict'; -var NativeModules = require('NativeModules'); -var Promise = require('Promise'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +const NativeModules = require('NativeModules'); +const Promise = require('Promise'); +const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var AccessibilityManager = NativeModules.AccessibilityManager; +const AccessibilityManager = NativeModules.AccessibilityManager; -var VOICE_OVER_EVENT = 'voiceOverDidChange'; -var ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish'; +const VOICE_OVER_EVENT = 'voiceOverDidChange'; +const ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish'; type ChangeEventName = $Enum<{ change: string, announcementFinished: string }>; -var _subscriptions = new Map(); +const _subscriptions = new Map(); /** * Sometimes it's useful to know whether or not the device has a screen reader * that is currently active. The `AccessibilityInfo` API is designed for this - * purpose. You can use it to query the current state of the screen reader as - * well as to register to be notified when the state of the screen reader + * purpose. You can use it to query the current state of the screen reader as + * well as to register to be notified when the state of the screen reader * changes. * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html */ -var AccessibilityInfo = { +const AccessibilityInfo = { /** - * Query whether a screen reader is currently enabled. - * - * Returns a promise which resolves to a boolean. + * Query whether a screen reader is currently enabled. + * + * Returns a promise which resolves to a boolean. * The result is `true` when a screen reader is enabledand `false` otherwise. - * + * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#fetch */ fetch: function(): Promise { @@ -67,14 +65,14 @@ var AccessibilityInfo = { * - `announcement`: The string announced by the screen reader. * - `success`: A boolean indicating whether the announcement was * successfully made. - * + * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#addeventlistener */ addEventListener: function ( eventName: ChangeEventName, handler: Function ): Object { - var listener; + let listener; if (eventName === 'change') { listener = RCTDeviceEventEmitter.addListener( @@ -96,9 +94,9 @@ var AccessibilityInfo = { /** * Set accessibility focus to a react component. - * + * * @platform ios - * + * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus */ setAccessibilityFocus: function( @@ -111,7 +109,7 @@ var AccessibilityInfo = { * Post a string to be announced by the screen reader. * * @platform ios - * + * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#announceforaccessibility */ announceForAccessibility: function( @@ -122,14 +120,14 @@ var AccessibilityInfo = { /** * Remove an event handler. - * + * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#removeeventlistener */ removeEventListener: function( eventName: ChangeEventName, handler: Function ): void { - var listener = _subscriptions.get(handler); + const listener = _subscriptions.get(handler); if (!listener) { return; } diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 6ea90069cdb125..a520b657904738 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ActivityIndicator * @flow @@ -23,6 +21,7 @@ const ViewPropTypes = require('ViewPropTypes'); const createReactClass = require('create-react-class'); const requireNativeComponent = require('requireNativeComponent'); +let RCTActivityIndicator; const GRAY = '#999999'; @@ -48,20 +47,20 @@ const ActivityIndicator = createReactClass({ ...ViewPropTypes, /** * Whether to show the indicator (true, the default) or hide it (false). - * + * * See http://facebook.github.io/react-native/docs/activityindicator.html#animating */ animating: PropTypes.bool, /** * The foreground color of the spinner (default is gray). - * + * * See http://facebook.github.io/react-native/docs/activityindicator.html#color */ color: ColorPropType, /** * Size of the indicator (default is 'small'). * Passing a number to the size prop is only supported on Android. - * + * * See http://facebook.github.io/react-native/docs/activityindicator.html#size */ size: PropTypes.oneOfType([ @@ -72,7 +71,7 @@ const ActivityIndicator = createReactClass({ * Whether the indicator should hide when not animating (true by default). * * @platform ios - * + * * See http://facebook.github.io/react-native/docs/activityindicator.html#hideswhenstopped */ hidesWhenStopped: PropTypes.bool, @@ -122,6 +121,14 @@ const ActivityIndicator = createReactClass({ } }); +if (Platform.OS === 'ios') { + RCTActivityIndicator = requireNativeComponent( + 'RCTActivityIndicatorView', + ActivityIndicator, + { nativeOnly: { activityIndicatorViewStyle: true } } + ); +} + const styles = StyleSheet.create({ container: { alignItems: 'center', @@ -137,12 +144,4 @@ const styles = StyleSheet.create({ }, }); -if (Platform.OS === 'ios') { - var RCTActivityIndicator = requireNativeComponent( - 'RCTActivityIndicatorView', - ActivityIndicator, - { nativeOnly: { activityIndicatorViewStyle: true } } - ); -} - module.exports = ActivityIndicator; diff --git a/Libraries/Components/AppleTV/TVEventHandler.android.js b/Libraries/Components/AppleTV/TVEventHandler.android.js deleted file mode 100644 index dc5a1d6b94e931..00000000000000 --- a/Libraries/Components/AppleTV/TVEventHandler.android.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule TVEventHandler - * @flow - */ -'use strict'; - -function TVEventHandler() {} - -TVEventHandler.prototype.enable = function(component: ?any, callback: Function) {}; - -TVEventHandler.prototype.disable = function() {}; - -module.exports = TVEventHandler; diff --git a/Libraries/Components/AppleTV/TVEventHandler.ios.js b/Libraries/Components/AppleTV/TVEventHandler.js similarity index 76% rename from Libraries/Components/AppleTV/TVEventHandler.ios.js rename to Libraries/Components/AppleTV/TVEventHandler.js index c01f2b065a76fd..363d50d903d876 100644 --- a/Libraries/Components/AppleTV/TVEventHandler.ios.js +++ b/Libraries/Components/AppleTV/TVEventHandler.js @@ -1,17 +1,15 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule TVEventHandler * @flow */ 'use strict'; -const React = require('React'); +const Platform = require('Platform'); const TVNavigationEventEmitter = require('NativeModules').TVNavigationEventEmitter; const NativeEventEmitter = require('NativeEventEmitter'); @@ -21,13 +19,13 @@ function TVEventHandler() { } TVEventHandler.prototype.enable = function(component: ?any, callback: Function) { - if (!TVNavigationEventEmitter) { + if (Platform.OS === 'ios' && !TVNavigationEventEmitter) { return; } this.__nativeTVNavigationEventEmitter = new NativeEventEmitter(TVNavigationEventEmitter); this.__nativeTVNavigationEventListener = this.__nativeTVNavigationEventEmitter.addListener( - 'onTVNavEvent', + 'onHWKeyEvent', (data) => { if (callback) { callback(component, data); diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index b2c426d86241e3..2b6a6d4e53dcd1 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -1,33 +1,27 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule TVViewPropTypes * @flow */ 'use strict'; -var PropTypes = require('prop-types'); +const PropTypes = require('prop-types'); /** * Additional View properties for Apple TV */ -var TVViewPropTypes = { +const TVViewPropTypes = { /** - * *(Apple TV only)* When set to true, this view will be focusable - * and navigable using the Apple TV remote. - * - * @platform ios + * When set to true, this view will be focusable + * and navigable using the TV remote. */ isTVSelectable: PropTypes.bool, /** - * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. - * - * @platform ios + * May be set to true to force the TV focus engine to move focus to this view. */ hasTVPreferredFocus: PropTypes.bool, @@ -39,6 +33,9 @@ var TVViewPropTypes = { * shiftDistanceY: Defaults to 2.0. * tiltAngle: Defaults to 0.05. * magnification: Defaults to 1.0. + * pressMagnification: Defaults to 1.0. + * pressDuration: Defaults to 0.3. + * pressDelay: Defaults to 0.0. * * @platform ios */ diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index fc3f2ef5aab3ad..4370f3571c103c 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Button * @flow @@ -55,6 +53,7 @@ class Button extends React.Component<{ title: string, onPress: () => any, color?: ?string, + hasTVPreferredFocus?: ?boolean, accessibilityLabel?: ?string, disabled?: ?boolean, testID?: ?string, @@ -77,6 +76,10 @@ class Button extends React.Component<{ * If true, disable all interactions for this component. */ disabled: PropTypes.bool, + /** + * TV preferred focus (see documentation for the View component). + */ + hasTVPreferredFocus: PropTypes.bool, /** * Handler to be called when the user taps the button */ @@ -85,12 +88,6 @@ class Button extends React.Component<{ * Used to locate this view in end-to-end tests. */ testID: PropTypes.string, - /** - * *(Apple TV only)* TV preferred focus (see documentation for the View component). - * - * @platform ios - */ - hasTVPreferredFocus: PropTypes.bool, }; render() { diff --git a/Libraries/Components/CheckBox/CheckBox.android.js b/Libraries/Components/CheckBox/CheckBox.android.js index ef1a84730b4655..e4a14c6f73dafb 100644 --- a/Libraries/Components/CheckBox/CheckBox.android.js +++ b/Libraries/Components/CheckBox/CheckBox.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2017-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule CheckBox * @flow diff --git a/Libraries/Components/CheckBox/CheckBox.ios.js b/Libraries/Components/CheckBox/CheckBox.ios.js index 02124a885a6477..386255541d47ec 100644 --- a/Libraries/Components/CheckBox/CheckBox.ios.js +++ b/Libraries/Components/CheckBox/CheckBox.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2017-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule CheckBox * @flow diff --git a/Libraries/Components/Clipboard/Clipboard.js b/Libraries/Components/Clipboard/Clipboard.js index ac8641c834701a..80d067cce257c0 100644 --- a/Libraries/Components/Clipboard/Clipboard.js +++ b/Libraries/Components/Clipboard/Clipboard.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Clipboard * @flow diff --git a/Libraries/Components/DatePicker/DatePickerIOS.android.js b/Libraries/Components/DatePicker/DatePickerIOS.android.js index 9a2b2669711b4b..2a0d8998bfb556 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.android.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.android.js @@ -1,20 +1,18 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DatePickerIOS */ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummyDatePickerIOS extends React.Component { render() { @@ -26,7 +24,7 @@ class DummyDatePickerIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummyDatePickerIOS: { height: 100, width: 300, diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 88ae7d5c876d0e..b08bf8f93412bf 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DatePickerIOS * @flow @@ -15,6 +13,7 @@ const NativeMethodsMixin = require('NativeMethodsMixin'); const React = require('React'); +const invariant = require('fbjs/lib/invariant'); const PropTypes = require('prop-types'); const StyleSheet = require('StyleSheet'); const View = require('View'); @@ -48,7 +47,17 @@ const DatePickerIOS = createReactClass({ /** * The currently selected date. */ - date: PropTypes.instanceOf(Date).isRequired, + date: PropTypes.instanceOf(Date), + + /** + * Provides an initial value that will change when the user starts selecting + * a date. It is useful for simple use-cases where you do not want to deal + * with listening to events and updating the date prop to keep the + * controlled state in sync. The controlled state has known bugs which + * causes it to go out of sync with native. The initialDate prop is intended + * to allow you to have native be source of truth. + */ + initialDate: PropTypes.instanceOf(Date), /** * Date change handler. @@ -104,6 +113,17 @@ const DatePickerIOS = createReactClass({ }; }, + componentDidUpdate: function() { + if (this.props.date) { + const propsTimeStamp = this.props.date.getTime(); + if (this._picker) { + this._picker.setNativeProps({ + date: propsTimeStamp, + }); + } + } + }, + _onChange: function(event: Event) { const nativeTimeStamp = event.nativeEvent.timestamp; this.props.onDateChange && this.props.onDateChange( @@ -111,27 +131,20 @@ const DatePickerIOS = createReactClass({ ); // $FlowFixMe(>=0.41.0) this.props.onChange && this.props.onChange(event); - - // We expect the onChange* handlers to be in charge of updating our `date` - // prop. That way they can also disallow/undo/mutate the selection of - // certain values. In other words, the embedder of this component should - // be the source of truth, not the native component. - const propsTimeStamp = this.props.date.getTime(); - if (this._picker && nativeTimeStamp !== propsTimeStamp) { - this._picker.setNativeProps({ - date: propsTimeStamp, - }); - } }, render: function() { const props = this.props; + invariant( + props.date || props.initialDate, + 'A selected date or initial date should be specified.', + ); return ( { this._picker = picker; } } style={styles.datePickerIOS} - date={props.date.getTime()} + date={props.date ? props.date.getTime() : props.initialDate ? props.initialDate.getTime() : undefined} locale={props.locale ? props.locale : undefined} maximumDate={ props.maximumDate ? props.maximumDate.getTime() : undefined diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js index 11910ead0ad33c..750ed921f0684b 100644 --- a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +++ b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DatePickerAndroid * @flow diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js index afc8a19c2e8d7d..a23602128078f8 100644 --- a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +++ b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DatePickerAndroid * @flow diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index e75e40534ab697..6a20d894f4f4c4 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -1,37 +1,35 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule DrawerLayoutAndroid */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var StatusBar = require('StatusBar'); -var StyleSheet = require('StyleSheet'); -var UIManager = require('UIManager'); -var View = require('View'); -var ViewPropTypes = require('ViewPropTypes'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const Platform = require('Platform'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const StatusBar = require('StatusBar'); +const StyleSheet = require('StyleSheet'); +const UIManager = require('UIManager'); +const View = require('View'); +const ViewPropTypes = require('ViewPropTypes'); -var DrawerConsts = UIManager.AndroidDrawerLayout.Constants; +const DrawerConsts = UIManager.AndroidDrawerLayout.Constants; -var createReactClass = require('create-react-class'); -var dismissKeyboard = require('dismissKeyboard'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const dismissKeyboard = require('dismissKeyboard'); +const requireNativeComponent = require('requireNativeComponent'); -var RK_DRAWER_REF = 'drawerlayout'; -var INNERVIEW_REF = 'innerView'; +const RK_DRAWER_REF = 'drawerlayout'; +const INNERVIEW_REF = 'innerView'; -var DRAWER_STATES = [ +const DRAWER_STATES = [ 'Idle', 'Dragging', 'Settling', @@ -68,7 +66,7 @@ var DRAWER_STATES = [ * }, * ``` */ -var DrawerLayoutAndroid = createReactClass({ +const DrawerLayoutAndroid = createReactClass({ displayName: 'DrawerLayoutAndroid', statics: { positions: DrawerConsts.DrawerPosition, @@ -171,8 +169,8 @@ var DrawerLayoutAndroid = createReactClass({ }, render: function() { - var drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor; - var drawerViewWrapper = + const drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor; + const drawerViewWrapper = } ; - var childrenWrapper = + const childrenWrapper = {drawStatusBar && =0.54.0 site=react_native_oss) This comment suppresses an error * found when Flow v0.54 was deployed. To see the error delete this comment and * run Flow. */ const keyMirror = require('fbjs/lib/keyMirror'); -var TRANSITIONER_REF = 'transitionerRef'; +const TRANSITIONER_REF = 'transitionerRef'; -var __uid = 0; +let __uid = 0; function getuid() { return __uid++; } @@ -307,7 +305,7 @@ type Event = Object; * is pushed. * */ -var NavigatorIOS = createReactClass({ +const NavigatorIOS = createReactClass({ displayName: 'NavigatorIOS', propTypes: { @@ -515,7 +513,7 @@ var NavigatorIOS = createReactClass({ navigator: (undefined: ?Object), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { // Precompute a pack of callbacks that's frequently generated and passed to // instances. this.navigator = { @@ -586,7 +584,7 @@ var NavigatorIOS = createReactClass({ _getFocusEmitter: function(): EventEmitter { // Flow not yet tracking assignments to instance fields. - var focusEmitter = this._focusEmitter; + let focusEmitter = this._focusEmitter; if (!focusEmitter) { focusEmitter = new EventEmitter(); this._focusEmitter = focusEmitter; @@ -616,13 +614,13 @@ var NavigatorIOS = createReactClass({ }, _handleNavigatorStackChanged: function(e: Event) { - var newObservedTopOfStack = e.nativeEvent.stackLength - 1; + const newObservedTopOfStack = e.nativeEvent.stackLength - 1; invariant( newObservedTopOfStack <= this.state.requestedTopOfStack, 'No navigator item should be pushed without JS knowing about it %s %s', newObservedTopOfStack, this.state.requestedTopOfStack ); - var wasWaitingForConfirmation = + const wasWaitingForConfirmation = this.state.requestedTopOfStack !== this.state.observedTopOfStack; if (wasWaitingForConfirmation) { invariant( @@ -640,7 +638,7 @@ var NavigatorIOS = createReactClass({ // Progress isn't always 0 or 1 at the end, the system rounds // If the Navigator is offscreen these values won't be updated // TOOD: Revisit this decision when no longer relying on native navigator. - var nextState = { + const nextState = { observedTopOfStack: newObservedTopOfStack, makingNavigatorRequest: false, updatingAllIndicesAtOrBeyond: null, @@ -655,7 +653,7 @@ var NavigatorIOS = createReactClass({ // Updating the indices that we're deleting and that's all. (Truth: Nothing // even uses the indices in this case, but let's make this describe the // truth anyways). - var updatingAllIndicesAtOrBeyond = + const updatingAllIndicesAtOrBeyond = this.state.routeStack.length > this.state.observedTopOfStack + 1 ? this.state.observedTopOfStack + 1 : null; @@ -679,8 +677,8 @@ var NavigatorIOS = createReactClass({ if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { this._tryLockNavigator(() => { - var nextStack = this.state.routeStack.concat([route]); - var nextIDStack = this.state.idStack.concat([getuid()]); + const nextStack = this.state.routeStack.concat([route]); + const nextIDStack = this.state.idStack.concat([getuid()]); this.setState({ // We have to make sure that we've also supplied enough views to // satisfy our request to adjust the `requestedTopOfStack`. @@ -706,7 +704,7 @@ var NavigatorIOS = createReactClass({ if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { if (this.state.requestedTopOfStack > 0) { this._tryLockNavigator(() => { - var newRequestedTopOfStack = this.state.requestedTopOfStack - n; + const newRequestedTopOfStack = this.state.requestedTopOfStack - n; invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0'); this.setState({ requestedTopOfStack: newRequestedTopOfStack, @@ -744,8 +742,8 @@ var NavigatorIOS = createReactClass({ // I don't believe we need to lock for a replace since there's no // navigation actually happening - var nextIDStack = this.state.idStack.slice(); - var nextRouteStack = this.state.routeStack.slice(); + const nextIDStack = this.state.idStack.slice(); + const nextRouteStack = this.state.routeStack.slice(); nextIDStack[index] = getuid(); nextRouteStack[index] = route; @@ -787,12 +785,12 @@ var NavigatorIOS = createReactClass({ * @param route The new route to navigate to. */ popToRoute: function(route: Route) { - var indexOfRoute = this.state.routeStack.indexOf(route); + const indexOfRoute = this.state.routeStack.indexOf(route); invariant( indexOfRoute !== -1, 'Calling pop to route for a route that doesn\'t exist!' ); - var numToPop = this.state.routeStack.length - indexOfRoute - 1; + const numToPop = this.state.routeStack.length - indexOfRoute - 1; this.popN(numToPop); }, @@ -843,12 +841,12 @@ var NavigatorIOS = createReactClass({ }, _routeToStackItem: function(routeArg: Route, i: number) { - var {component, wrapperStyle, passProps, ...route} = routeArg; - var {itemWrapperStyle, ...props} = this.props; - var shouldUpdateChild = + const {component, wrapperStyle, passProps, ...route} = routeArg; + const {itemWrapperStyle, ...props} = this.props; + const shouldUpdateChild = this.state.updatingAllIndicesAtOrBeyond != null && this.state.updatingAllIndicesAtOrBeyond >= i; - var Component = component; + const Component = component; return ( @@ -921,7 +919,7 @@ var NavigatorIOS = createReactClass({ }, }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ stackItem: { backgroundColor: 'white', overflow: 'hidden', @@ -936,7 +934,7 @@ var styles = StyleSheet.create({ }, }); -var RCTNavigator = requireNativeComponent('RCTNavigator'); -var RCTNavigatorItem = requireNativeComponent('RCTNavItem'); +const RCTNavigator = requireNativeComponent('RCTNavigator'); +const RCTNavigatorItem = requireNativeComponent('RCTNavItem'); module.exports = NavigatorIOS; diff --git a/Libraries/Components/Picker/Picker.js b/Libraries/Components/Picker/Picker.js index 443622221b624d..1df316249d7ce7 100644 --- a/Libraries/Components/Picker/Picker.js +++ b/Libraries/Components/Picker/Picker.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Picker * @flow @@ -12,27 +10,27 @@ 'use strict'; -var ColorPropType = require('ColorPropType'); -var PickerIOS = require('PickerIOS'); -var PickerAndroid = require('PickerAndroid'); -var Platform = require('Platform'); -var React = require('React'); +const ColorPropType = require('ColorPropType'); +const PickerIOS = require('PickerIOS'); +const PickerAndroid = require('PickerAndroid'); +const Platform = require('Platform'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheetPropType = require('StyleSheetPropType'); -var TextStylePropTypes = require('TextStylePropTypes'); -var UnimplementedView = require('UnimplementedView'); +const StyleSheetPropType = require('StyleSheetPropType'); +const TextStylePropTypes = require('TextStylePropTypes'); +const UnimplementedView = require('UnimplementedView'); const ViewPropTypes = require('ViewPropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); +const ViewStylePropTypes = require('ViewStylePropTypes'); -var itemStylePropType = StyleSheetPropType(TextStylePropTypes); +const itemStylePropType = StyleSheetPropType(TextStylePropTypes); -var pickerStyleType = StyleSheetPropType({ +const pickerStyleType = StyleSheetPropType({ ...ViewStylePropTypes, color: ColorPropType, }); -var MODE_DIALOG = 'dialog'; -var MODE_DROPDOWN = 'dropdown'; +const MODE_DIALOG = 'dialog'; +const MODE_DROPDOWN = 'dropdown'; /** * Individual selectable item in a Picker. diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index bc5890657d1ee2..bd9c664a8fa5d6 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PickerAndroid * @flow @@ -12,21 +10,21 @@ 'use strict'; -var ColorPropType = require('ColorPropType'); -var React = require('React'); -var ReactPropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var StyleSheetPropType = require('StyleSheetPropType'); +const ColorPropType = require('ColorPropType'); +const React = require('React'); +const ReactPropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const StyleSheetPropType = require('StyleSheetPropType'); const ViewPropTypes = require('ViewPropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); +const ViewStylePropTypes = require('ViewStylePropTypes'); -var processColor = require('processColor'); -var requireNativeComponent = require('requireNativeComponent'); +const processColor = require('processColor'); +const requireNativeComponent = require('requireNativeComponent'); -var REF_PICKER = 'picker'; -var MODE_DROPDOWN = 'dropdown'; +const REF_PICKER = 'picker'; +const MODE_DROPDOWN = 'dropdown'; -var pickerStyleType = StyleSheetPropType({ +const pickerStyleType = StyleSheetPropType({ ...ViewStylePropTypes, color: ColorPropType, }); @@ -58,7 +56,7 @@ class PickerAndroid extends React.Component<{ constructor(props, context) { super(props, context); - var state = this._stateFromProps(props); + const state = this._stateFromProps(props); this.state = { ...state, @@ -66,13 +64,13 @@ class PickerAndroid extends React.Component<{ }; } - componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps) { this.setState(this._stateFromProps(nextProps)); } // Translate prop and children into stuff that the native picker understands. _stateFromProps = (props) => { - var selectedIndex = 0; + let selectedIndex = 0; const items = React.Children.map(props.children, (child, index) => { if (child.props.value === props.selectedValue) { selectedIndex = index; @@ -90,9 +88,9 @@ class PickerAndroid extends React.Component<{ }; render() { - var Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker; + const Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker; - var nativeProps = { + const nativeProps = { enabled: this.props.enabled, items: this.state.items, mode: this.props.mode, @@ -109,10 +107,10 @@ class PickerAndroid extends React.Component<{ _onChange = (event: Event) => { if (this.props.onValueChange) { - var position = event.nativeEvent.position; + const position = event.nativeEvent.position; if (position >= 0) { - var children = React.Children.toArray(this.props.children); - var value = children[position].props.value; + const children = React.Children.toArray(this.props.children); + const value = children[position].props.value; this.props.onValueChange(value, position); } else { this.props.onValueChange(null, position); @@ -140,7 +138,7 @@ class PickerAndroid extends React.Component<{ } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ pickerAndroid: { // The picker will conform to whatever width is given, but we do // have to set the component's height explicitly on the @@ -151,14 +149,14 @@ var styles = StyleSheet.create({ }, }); -var cfg = { +const cfg = { nativeOnly: { items: true, selected: true, } }; -var DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg); -var DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg); +const DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg); +const DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg); module.exports = PickerAndroid; diff --git a/Libraries/Components/Picker/PickerAndroid.ios.js b/Libraries/Components/Picker/PickerAndroid.ios.js index fc589882864a71..b84e15bad67af0 100644 --- a/Libraries/Components/Picker/PickerAndroid.ios.js +++ b/Libraries/Components/Picker/PickerAndroid.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PickerAndroid */ diff --git a/Libraries/Components/Picker/PickerIOS.android.js b/Libraries/Components/Picker/PickerIOS.android.js index 7c5b39112a9ecf..ce50c2ad4e4157 100644 --- a/Libraries/Components/Picker/PickerIOS.android.js +++ b/Libraries/Components/Picker/PickerIOS.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PickerIOS * diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 81911b4bc16143..d1fe0761d5cc34 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PickerIOS * @@ -12,21 +10,21 @@ */ 'use strict'; -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var StyleSheetPropType = require('StyleSheetPropType'); -var TextStylePropTypes = require('TextStylePropTypes'); -var View = require('View'); +const StyleSheet = require('StyleSheet'); +const StyleSheetPropType = require('StyleSheetPropType'); +const TextStylePropTypes = require('TextStylePropTypes'); +const View = require('View'); const ViewPropTypes = require('ViewPropTypes'); -var processColor = require('processColor'); +const processColor = require('processColor'); -var createReactClass = require('create-react-class'); -var itemStylePropType = StyleSheetPropType(TextStylePropTypes); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const itemStylePropType = StyleSheetPropType(TextStylePropTypes); +const requireNativeComponent = require('requireNativeComponent'); -var PickerIOS = createReactClass({ +const PickerIOS = createReactClass({ displayName: 'PickerIOS', mixins: [NativeMethodsMixin], @@ -41,14 +39,14 @@ var PickerIOS = createReactClass({ return this._stateFromProps(this.props); }, - componentWillReceiveProps: function(nextProps) { + UNSAFE_componentWillReceiveProps: function(nextProps) { this.setState(this._stateFromProps(nextProps)); }, // Translate PickerIOS prop and children into stuff that RCTPickerIOS understands. _stateFromProps: function(props) { - var selectedIndex = 0; - var items = []; + let selectedIndex = 0; + const items = []; React.Children.toArray(props.children).forEach(function (child, index) { if (child.props.value === props.selectedValue) { selectedIndex = index; @@ -113,7 +111,7 @@ PickerIOS.Item = class extends React.Component { } }; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ pickerIOS: { // The picker will conform to whatever width is given, but we do // have to set the component's height explicitly on the @@ -122,7 +120,7 @@ var styles = StyleSheet.create({ }, }); -var RCTPickerIOS = requireNativeComponent('RCTPicker', { +const RCTPickerIOS = requireNativeComponent('RCTPicker', { propTypes: { style: itemStylePropType, }, diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index 6f076e53dc3f0b..f5dcb10cfb9508 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ProgressBarAndroid */ diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js index 99f01c81f36c20..92bae8066abe69 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ProgressBarAndroid */ diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js index d4a7da54aa98ec..f467db1ff51f64 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js @@ -1,21 +1,19 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ProgressViewIOS */ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummyProgressViewIOS extends React.Component { render() { @@ -29,7 +27,7 @@ class DummyProgressViewIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummy: { width: 120, height: 20, diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js index e6a5485f85b30c..55ae1b83abe13d 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js @@ -1,30 +1,28 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ProgressViewIOS * @flow */ 'use strict'; -var Image = require('Image'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const Image = require('Image'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); /** * Use `ProgressViewIOS` to render a UIProgressView on iOS. */ -var ProgressViewIOS = createReactClass({ +const ProgressViewIOS = createReactClass({ displayName: 'ProgressViewIOS', mixins: [NativeMethodsMixin], @@ -71,13 +69,13 @@ var ProgressViewIOS = createReactClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ progressView: { height: 2, }, }); -var RCTProgressView = requireNativeComponent( +const RCTProgressView = requireNativeComponent( 'RCTProgressView', ProgressViewIOS ); diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index 825b8c3f2886e3..8aac1ebf3e5744 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule RefreshControl * @flow @@ -22,7 +20,11 @@ const createReactClass = require('create-react-class'); const requireNativeComponent = require('requireNativeComponent'); if (Platform.OS === 'android') { - var RefreshLayoutConsts = require('UIManager').AndroidSwipeRefreshLayout.Constants; + const AndroidSwipeRefreshLayout = + require('UIManager').AndroidSwipeRefreshLayout; + var RefreshLayoutConsts = AndroidSwipeRefreshLayout + ? AndroidSwipeRefreshLayout.Constants + : {SIZE: {}}; } else { var RefreshLayoutConsts = {SIZE: {}}; } diff --git a/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js b/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js index cb02f672b17947..04312d5d4c5dbe 100644 --- a/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +++ b/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow */ diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.android.js b/Libraries/Components/SafeAreaView/SafeAreaView.android.js index 46265995522ded..62a81a8a284352 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.android.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SafeAreaView * @flow diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.ios.js b/Libraries/Components/SafeAreaView/SafeAreaView.ios.js index 73336990a7a6f6..344cbe5f301ef1 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.ios.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SafeAreaView * @flow diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 5b3244d3eea910..9d60c462ef1dc7 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ScrollResponder * @flow @@ -548,7 +546,7 @@ const ScrollResponderMixin = { * * The `keyboardWillShow` is called before input focus. */ - componentWillMount: function() { + UNSAFE_componentWillMount: function() { const {keyboardShouldPersistTaps} = this.props; warning( typeof keyboardShouldPersistTaps !== 'boolean', diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 964421282ba25b..7c53855a4bc638 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1,17 +1,15 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ScrollView * @flow */ 'use strict'; -const Animated = require('Animated'); +const AnimatedImplementation = require('AnimatedImplementation'); const ColorPropType = require('ColorPropType'); const EdgeInsetsPropType = require('EdgeInsetsPropType'); const Platform = require('Platform'); @@ -277,6 +275,12 @@ const ScrollView = createReactClass({ * @platform ios */ minimumZoomScale: PropTypes.number, + /** + * Enables nested scrolling for Android API level 21+. + * Nested scrolling is supported by default on iOS + * @platform android + */ + nestedScrollEnabled: PropTypes.bool, /** * Called when the momentum scroll starts (scroll which occurs as the ScrollView glides to a stop). */ @@ -499,7 +503,7 @@ const ScrollView = createReactClass({ mixins: [ScrollResponder.Mixin], - _scrollAnimatedValue: (new Animated.Value(0): Animated.Value), + _scrollAnimatedValue: (new AnimatedImplementation.Value(0): AnimatedImplementation.Value), _scrollAnimatedValueAttachment: (null: ?{detach: () => void}), _stickyHeaderRefs: (new Map(): Map), _headerLayoutYs: (new Map(): Map), @@ -510,8 +514,8 @@ const ScrollView = createReactClass({ }; }, - componentWillMount: function() { - this._scrollAnimatedValue = new Animated.Value(this.props.contentOffset ? this.props.contentOffset.y : 0); + UNSAFE_componentWillMount: function() { + this._scrollAnimatedValue = new AnimatedImplementation.Value(this.props.contentOffset ? this.props.contentOffset.y : 0); this._scrollAnimatedValue.setOffset(this.props.contentInset ? this.props.contentInset.top : 0); this._stickyHeaderRefs = new Map(); this._headerLayoutYs = new Map(); @@ -625,7 +629,7 @@ const ScrollView = createReactClass({ this._scrollAnimatedValueAttachment.detach(); } if (this.props.stickyHeaderIndices && this.props.stickyHeaderIndices.length > 0) { - this._scrollAnimatedValueAttachment = Animated.attachNativeEvent( + this._scrollAnimatedValueAttachment = AnimatedImplementation.attachNativeEvent( this._scrollViewRef, 'onScroll', [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}] @@ -677,7 +681,7 @@ const ScrollView = createReactClass({ } } if (Platform.OS === 'android') { - if (this.props.keyboardDismissMode === 'on-drag') { + if (this.props.keyboardDismissMode === 'on-drag' && this.state.isTouching) { dismissKeyboard(); } } diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 54956acf3fee7c..af9dc9b8b63549 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule ScrollViewStickyHeader * @flow @@ -12,17 +10,20 @@ */ 'use strict'; -const Animated = require('Animated'); +const AnimatedImplementation = require('AnimatedImplementation'); const React = require('React'); const StyleSheet = require('StyleSheet'); +const View = require('View'); import type {LayoutEvent} from 'CoreEventTypes'; +const AnimatedView = AnimatedImplementation.createAnimatedComponent(View); + type Props = { children?: React.Element, nextHeaderLayoutY: ?number, onLayout: (event: LayoutEvent) => void, - scrollAnimatedValue: Animated.Value, + scrollAnimatedValue: AnimatedImplementation.Value, // Will cause sticky headers to stick at the bottom of the ScrollView instead // of the top. inverted: ?boolean, @@ -138,7 +139,7 @@ class ScrollViewStickyHeader extends React.Component { const child = React.Children.only(this.props.children); return ( - @@ -146,7 +147,7 @@ class ScrollViewStickyHeader extends React.Component { style: styles.fill, // We transfer the child style to the wrapper. onLayout: undefined, // we call this manually through our this._onLayout })} - + ); } } diff --git a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js index 6aa19b2f0eda40..eaa8bb7385e367 100644 --- a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js +++ b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @flow */ diff --git a/Libraries/Components/ScrollView/processDecelerationRate.js b/Libraries/Components/ScrollView/processDecelerationRate.js index 71955a025bcfef..9cb5a52a557715 100644 --- a/Libraries/Components/ScrollView/processDecelerationRate.js +++ b/Libraries/Components/ScrollView/processDecelerationRate.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule processDecelerationRate */ diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js index 15ac90078588dd..a5b4c0b339bf6e 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js @@ -1,21 +1,19 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SegmentedControlIOS */ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummySegmentedControlIOS extends React.Component { render() { @@ -29,7 +27,7 @@ class DummySegmentedControlIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummy: { width: 120, height: 50, diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js index e5297d8f28b845..3eb4249fa2dbce 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js @@ -1,31 +1,29 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule SegmentedControlIOS * @flow */ 'use strict'; -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type DefaultProps = { values: Array, enabled: boolean, }; -var SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol'; +const SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol'; type Event = Object; @@ -49,7 +47,7 @@ type Event = Object; * /> * ```` */ -var SegmentedControlIOS = createReactClass({ +const SegmentedControlIOS = createReactClass({ displayName: 'SegmentedControlIOS', mixins: [NativeMethodsMixin], @@ -119,13 +117,13 @@ var SegmentedControlIOS = createReactClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ segmentedControl: { height: 28, }, }); -var RCTSegmentedControl = requireNativeComponent( +const RCTSegmentedControl = requireNativeComponent( 'RCTSegmentedControl', SegmentedControlIOS ); diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index 91b780f7aa73a1..5a163fe176d129 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -1,28 +1,26 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Slider * @flow */ 'use strict'; -var Image = require('Image'); -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var Platform = require('Platform'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const Image = require('Image'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); +const Platform = require('Platform'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type Event = Object; @@ -86,7 +84,7 @@ type Event = Object; *``` * */ -var Slider = createReactClass({ +const Slider = createReactClass({ displayName: 'Slider', mixins: [NativeMethodsMixin], diff --git a/Libraries/Components/StaticContainer.react.js b/Libraries/Components/StaticContainer.react.js index ee19d7d4b84431..81e06ace1fdb5f 100644 --- a/Libraries/Components/StaticContainer.react.js +++ b/Libraries/Components/StaticContainer.react.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule StaticContainer.react * @flow diff --git a/Libraries/Components/StaticRenderer.js b/Libraries/Components/StaticRenderer.js index 380a556f937b67..777fe900e120b6 100644 --- a/Libraries/Components/StaticRenderer.js +++ b/Libraries/Components/StaticRenderer.js @@ -1,19 +1,17 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule StaticRenderer * @flow */ 'use strict'; -var React = require('React'); +const React = require('React'); -var PropTypes = require('prop-types'); +const PropTypes = require('prop-types'); class StaticRenderer extends React.Component<{ shouldUpdate: boolean, diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index c545b381050767..0562a315493853 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule StatusBar * @flow diff --git a/Libraries/Components/StatusBar/StatusBarIOS.android.js b/Libraries/Components/StatusBar/StatusBarIOS.android.js index 2be8f34eaf5fb5..5c69c15339addf 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.android.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule StatusBarIOS * @flow diff --git a/Libraries/Components/StatusBar/StatusBarIOS.ios.js b/Libraries/Components/StatusBar/StatusBarIOS.ios.js index a3aceaac7e0988..f132f005696def 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.ios.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.ios.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule StatusBarIOS * @flow diff --git a/Libraries/Components/Subscribable.js b/Libraries/Components/Subscribable.js index 8474b214994f4b..6825acd02f70c5 100644 --- a/Libraries/Components/Subscribable.js +++ b/Libraries/Components/Subscribable.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Subscribable * @flow @@ -21,16 +19,18 @@ import type EventEmitter from 'EventEmitter'; * React Core */ -var Subscribable = {}; +const Subscribable = {}; Subscribable.Mixin = { - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._subscribableSubscriptions = []; }, componentWillUnmount: function() { - this._subscribableSubscriptions.forEach( + // This null check is a fix for a broken version of uglify-es. Should be deleted eventually + // https://github.com/facebook/react-native/issues/17348 + this._subscribableSubscriptions && this._subscribableSubscriptions.forEach( (subscription) => subscription.remove() ); this._subscribableSubscriptions = null; diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index 8ee3225f3a0ee7..e88272dacfa1d0 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -1,26 +1,24 @@ /** * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule Switch * @flow */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var React = require('React'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const Platform = require('Platform'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); +const StyleSheet = require('StyleSheet'); const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type DefaultProps = { value: boolean, @@ -38,7 +36,7 @@ type DefaultProps = { * @keyword checkbox * @keyword toggle */ -var Switch = createReactClass({ +const Switch = createReactClass({ displayName: 'Switch', propTypes: { ...ViewPropTypes, @@ -100,7 +98,7 @@ var Switch = createReactClass({ }, render: function() { - var props = {...this.props}; + const props = {...this.props}; props.onStartShouldSetResponder = () => true; props.onResponderTerminationRequest = () => false; if (Platform.OS === 'android') { @@ -124,7 +122,7 @@ var Switch = createReactClass({ }, }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ rctSwitchIOS: { height: 31, width: 51, diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.android.js b/Libraries/Components/TabBarIOS/TabBarIOS.android.js index 0c6465bb38af25..c52d947ebd325e 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.android.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.android.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule TabBarIOS * @flow diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index c373bc57ac27e8..9d1b63567ba826 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -1,30 +1,28 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule TabBarIOS * @flow */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var React = require('React'); +const ColorPropType = require('ColorPropType'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var TabBarItemIOS = require('TabBarItemIOS'); +const StyleSheet = require('StyleSheet'); +const TabBarItemIOS = require('TabBarItemIOS'); const ViewPropTypes = require('ViewPropTypes'); -var requireNativeComponent = require('requireNativeComponent'); +const requireNativeComponent = require('requireNativeComponent'); -import type {StyleObj} from 'StyleSheetTypes'; +import type {DangerouslyImpreciseStyleProp} from 'StyleSheet'; import type {ViewProps} from 'ViewPropTypes'; class TabBarIOS extends React.Component + * + * this.setState({text})} + * value={this.state.text} + * /> + * + * + *