mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc04bf3d96 | ||
|
|
8e34e7bd5f | ||
|
|
68f6799b7c | ||
|
|
2c130e6a9f | ||
|
|
21423bdf22 | ||
|
|
e5332504cc | ||
|
|
292f035ae8 | ||
|
|
a6c4ae0e75 | ||
|
|
e4b5e9ef85 | ||
|
|
732831dc27 | ||
|
|
b150fdfdce | ||
|
|
73f2007679 | ||
|
|
da2a8b365c | ||
|
|
143ecf4c62 | ||
|
|
c8d6cb9e49 | ||
|
|
0661c6f254 | ||
|
|
5f4a5388ac | ||
|
|
445dac2743 | ||
|
|
2d230bee78 | ||
|
|
382abb4b45 | ||
|
|
b0e4b89b58 | ||
|
|
0b8525847f | ||
|
|
09a923599e | ||
|
|
e7b7951c96 | ||
|
|
a91d0d8c35 | ||
|
|
47206fdd3c | ||
|
|
b02efd9e96 | ||
|
|
31894136f4 | ||
|
|
9b6639ad12 | ||
|
|
11f838f349 | ||
|
|
34787cc0eb | ||
|
|
d40bea925f | ||
|
|
692d3f72fb |
+2
-3
@@ -1,13 +1,12 @@
|
||||
|
||||
[android]
|
||||
target = android-30
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[download]
|
||||
max_number_of_retries = 3
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
google = https://maven.google.com/
|
||||
|
||||
[alias]
|
||||
rntester = //packages/rn-tester/android/app:app
|
||||
rntester = //RNTester/android/app:app
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
BUNDLE_PATH: "vendor/bundle"
|
||||
BUNDLE_FORCE_RUBY_PLATFORM: 1
|
||||
@@ -1,81 +0,0 @@
|
||||
# Docker Test Environment
|
||||
|
||||
This is a high-level overview of the test configuration using Docker.
|
||||
It explains how to run the tests locally.
|
||||
|
||||
## Docker Installation
|
||||
|
||||
It is required to have Docker running on your machine in order to build and run the tests in the Dockerfiles.
|
||||
See <https://docs.docker.com/engine/installation/> for more information on how to install.
|
||||
|
||||
## Convenience Scripts
|
||||
|
||||
We have added a number of default run scripts to the `package.json` file to simplify building and running your tests.
|
||||
|
||||
### Configuring Docker Images
|
||||
|
||||
The following two scripts need to be run first before you can move on to testing:
|
||||
|
||||
- `yarn run docker-setup-android`: Pulls down the React Native Community Android image that serves as a base image when building the actual test image.
|
||||
|
||||
- `yarn run docker-build-android`: Builds a test image with the latest dependencies and React Native library code, including a compiled Android test app.
|
||||
|
||||
### Running Tests
|
||||
|
||||
Once the test image has been built, it can be used to run our Android tests.
|
||||
|
||||
- `yarn run test-android-run-unit` runs the unit tests, as defined in `scripts/run-android-docker-unit-tests.sh`.
|
||||
- `yarn run test-android-run-e2e` runs the end to end tests, as defined in `scripts/run-ci-e2e-tests.sh`.
|
||||
- `yarn run test-android-run-instrumentation` runs the instrumentation tests, as defined in `scripts/run-android-docker-instrumentation-tests.sh`.
|
||||
|
||||
#### Instrumentation Tests
|
||||
|
||||
The instrumentation test script accepts the following flags in order to customize the execution of the tests:
|
||||
|
||||
`--filter` - A regex that filters which instrumentation tests will be run. (Defaults to .*)
|
||||
|
||||
`--package` - Name of the java package containing the instrumentation tests (Defaults to com.facebook.react.tests)
|
||||
|
||||
`--path` - Path to the directory containing the instrumentation tests. (Defaults to ./ReactAndroid/src/androidTest/java/com/facebook/react/tests)
|
||||
|
||||
`--retries` - Number of times to retry a failed test before declaring a failure (Defaults to 2)
|
||||
|
||||
For example, if locally you only wanted to run the InitialPropsTestCase, you could do the following:
|
||||
`yarn run test-android-run-instrumentation -- --filter="InitialPropsTestCase"`
|
||||
|
||||
## Detailed Android Setup
|
||||
|
||||
There are two Dockerfiles for use with the Android codebase.
|
||||
The base image used to build `reactnativecommunity/react-native-android` is located in the https://github.com/react-native-community/docker-android GitHub repository.
|
||||
It contains all the necessary prerequisites required to run the React Android tests.
|
||||
It is separated out into a separate Dockerfile because these are dependencies that rarely change and also because it is quite a beastly image since it contains all the Android dependencies for running Android and the emulators (~9GB).
|
||||
|
||||
The good news is you should rarely have to build or pull down the base image!
|
||||
All iterative code updates happen as part of the `Dockerfile.android` image build.
|
||||
|
||||
Lets break it down...
|
||||
|
||||
First, you'll need to pull the base image.
|
||||
You can use `docker pull` to grab the latest version of the `reactnativecommunity/react-native-android` base image.
|
||||
This is what you get when you run `yarn run docker-setup-android`.
|
||||
|
||||
This will take quite some time depending on your connection and you need to ensure you have ~10GB of free disk space.
|
||||
|
||||
Once you have downloaded the base image, the test image can be built using `docker build -t reactnativeci/android -f ./.circleci/Dockerfiles/Dockerfile.android .`. This is what `yarn run docker-build-android` does. Note that the `-t` flag is how you tell Docker what to name this image locally. You can then use `docker run -t reactnativeci/android` to run this image.
|
||||
|
||||
Now that you've built the test image, you can run unit tests using what you've learned so far:
|
||||
|
||||
```bash
|
||||
docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh
|
||||
```
|
||||
|
||||
> Note: `--cap-add=SYS_ADMIN` flag is required for the `.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh` and `.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh` in order to allow the remounting of `/dev/shm` as writeable so the `buck` build system may write temporary output to that location.
|
||||
|
||||
Every time you make any modifications to the codebase, including changes to the test scripts inside `.circleci/Dockerfiles/scripts`, you should re-run the `docker build ...` command in order for your updates to be included in your local docker test image.
|
||||
|
||||
For rapid iteration, it's useful to keep in mind that Docker can pass along arbitrary commands to an image.
|
||||
For example, you can alternatively use Gradle in this manner:
|
||||
|
||||
```bash
|
||||
docker run --cap-add=SYS_ADMIN -it reactnativeci/android ./gradlew RNTester:android:app:assembleRelease
|
||||
```
|
||||
@@ -1,54 +0,0 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
#
|
||||
# This image builds upon the React Native Community Android image:
|
||||
# https://github.com/react-native-community/docker-android
|
||||
#
|
||||
# The base image is expected to remain relatively stable, and only
|
||||
# needs to be updated when major dependencies such as the Android
|
||||
# SDK or NDK are updated.
|
||||
#
|
||||
# In this Android Test image, we download the latest dependencies
|
||||
# and build a Android application that can be used to run the
|
||||
# tests specified in the scripts/ directory.
|
||||
#
|
||||
FROM reactnativecommunity/react-native-android:4.0
|
||||
|
||||
LABEL Description="React Native Android Test Image"
|
||||
LABEL maintainer="Héctor Ramos <hector@fb.com>"
|
||||
|
||||
# set default environment variables
|
||||
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
|
||||
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
|
||||
|
||||
ADD .buckconfig /app/.buckconfig
|
||||
ADD .buckjavaargs /app/.buckjavaargs
|
||||
ADD BUCK /app/BUCK
|
||||
ADD Libraries /app/Libraries
|
||||
ADD ReactAndroid /app/ReactAndroid
|
||||
ADD ReactCommon /app/ReactCommon
|
||||
ADD React /app/React
|
||||
ADD keystores /app/keystores
|
||||
ADD packages/react-native-codegen /app/packages/react-native-codegen
|
||||
ADD tools /app/tools
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
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 buck build ReactAndroid/src/main/java/com/facebook/react
|
||||
RUN buck build ReactAndroid/src/main/java/com/facebook/react/shell
|
||||
|
||||
ADD . /app
|
||||
|
||||
RUN yarn
|
||||
|
||||
RUN ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog
|
||||
|
||||
RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
# for buck gen
|
||||
mount -o remount,exec /dev/shm
|
||||
|
||||
AVD_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||
|
||||
# create virtual device
|
||||
echo no | android create avd -n "$AVD_UUID" -f -t android-21 --abi default/armeabi-v7a
|
||||
|
||||
# emulator setup
|
||||
emulator64-arm -avd $AVD_UUID -no-skin -no-audio -no-window -no-boot-anim &
|
||||
bootanim=""
|
||||
until [[ "$bootanim" =~ "stopped" ]]; do
|
||||
sleep 5
|
||||
bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
|
||||
echo "boot animation status=$bootanim"
|
||||
done
|
||||
|
||||
set -x
|
||||
|
||||
# solve issue with max user watches limit
|
||||
echo 65536 | tee -a /proc/sys/fs/inotify/max_user_watches
|
||||
watchman shutdown-server
|
||||
|
||||
# integration tests
|
||||
# build JS bundle for instrumentation tests
|
||||
node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
|
||||
|
||||
# build test APK
|
||||
# shellcheck disable=SC1091
|
||||
source ./scripts/android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
|
||||
|
||||
# run installed apk with tests
|
||||
node ./.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js "$*"
|
||||
exit $?
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
# set default environment variables
|
||||
UNIT_TESTS_BUILD_THREADS="${UNIT_TESTS_BUILD_THREADS:-1}"
|
||||
|
||||
# for buck gen
|
||||
mount -o remount,exec /dev/shm
|
||||
|
||||
set -x
|
||||
|
||||
# run unit tests
|
||||
buck test ReactAndroid/src/test/... --config build.threads="$UNIT_TESTS_BUILD_THREADS"
|
||||
@@ -1,251 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
set -ex
|
||||
|
||||
# set default environment variables
|
||||
ROOT=$(pwd)
|
||||
SCRIPTS=$(pwd)/scripts
|
||||
|
||||
RUN_ANDROID=0
|
||||
RUN_CLI_INSTALL=1
|
||||
RUN_IOS=0
|
||||
RUN_JS=0
|
||||
|
||||
RETRY_COUNT=${RETRY_COUNT:-2}
|
||||
AVD_UUID=$(< /dev/urandom tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||
ANDROID_NPM_DEPS="appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1"
|
||||
CLI_PACKAGE="$ROOT/react-native-cli/react-native-cli-*.tgz"
|
||||
PACKAGE="$ROOT/react-native-*.tgz"
|
||||
|
||||
# solve issue with max user watches limit
|
||||
echo 65536 | tee -a /proc/sys/fs/inotify/max_user_watches
|
||||
watchman shutdown-server
|
||||
|
||||
# retries command on failure
|
||||
# $1 -- max attempts
|
||||
# $2 -- command to run
|
||||
function retry() {
|
||||
local -r -i max_attempts="$1"; shift
|
||||
local -r cmd="$*"
|
||||
local -i attempt_num=1
|
||||
|
||||
until $cmd; do
|
||||
if (( attempt_num == max_attempts )); then
|
||||
echo "Execution of '$cmd' failed; no more attempts left"
|
||||
return 1
|
||||
else
|
||||
(( attempt_num++ ))
|
||||
echo "Execution of '$cmd' failed; retrying for attempt number $attempt_num..."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# parse command line args & flags
|
||||
while :; do
|
||||
case "$1" in
|
||||
--android)
|
||||
RUN_ANDROID=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--ios)
|
||||
RUN_IOS=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--js)
|
||||
RUN_JS=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--skip-cli-install)
|
||||
RUN_CLI_INSTALL=0
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
break
|
||||
esac
|
||||
done
|
||||
|
||||
function e2e_suite() {
|
||||
cd "$ROOT"
|
||||
|
||||
if [ $RUN_ANDROID -eq 0 ] && [ $RUN_IOS -eq 0 ] && [ $RUN_JS -eq 0 ]; then
|
||||
echo "No e2e tests specified!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# create temp dir
|
||||
TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX)
|
||||
|
||||
# To make sure we actually installed the local version
|
||||
# of react-native, we will create a temp file inside the template
|
||||
# and check that it exists after `react-native init
|
||||
IOS_MARKER="$(mktemp "$ROOT"/template/ios/HelloWorld/XXXXXXXX)"
|
||||
ANDROID_MARKER="$(mktemp "$ROOT"/template/android/XXXXXXXX)"
|
||||
|
||||
# install CLI
|
||||
cd react-native-cli
|
||||
npm pack
|
||||
cd ..
|
||||
|
||||
# can skip cli install for non sudo mode
|
||||
if [ $RUN_CLI_INSTALL -ne 0 ]; then
|
||||
if ! npm install -g "$CLI_PACKAGE"
|
||||
then
|
||||
echo "Could not install react-native-cli globally, please run in su mode"
|
||||
echo "Or with --skip-cli-install to skip this step"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $RUN_ANDROID -ne 0 ]; then
|
||||
set +ex
|
||||
|
||||
# create virtual device
|
||||
if ! android list avd | grep "$AVD_UUID" > /dev/null; then
|
||||
echo no | android create avd -n "$AVD_UUID" -f -t android-21 --abi default/armeabi-v7a
|
||||
fi
|
||||
|
||||
# newline at end of adb devices call and first line is headers
|
||||
DEVICE_COUNT=$(adb devices | wc -l)
|
||||
((DEVICE_COUNT -= 2))
|
||||
|
||||
# will always kill an existing emulator if one exists for fresh setup
|
||||
if [[ $DEVICE_COUNT -ge 1 ]]; then
|
||||
adb emu kill
|
||||
fi
|
||||
|
||||
# emulator setup
|
||||
emulator64-arm -avd "$AVD_UUID" -no-skin -no-audio -no-window -no-boot-anim &
|
||||
|
||||
bootanim=""
|
||||
# shellcheck disable=SC2076
|
||||
until [[ "$bootanim" =~ "stopped" ]]; do
|
||||
sleep 5
|
||||
bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
|
||||
echo "boot animation status=$bootanim"
|
||||
done
|
||||
|
||||
set -ex
|
||||
|
||||
if ! ./gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"
|
||||
then
|
||||
echo "Failed to compile Android binaries"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! npm pack
|
||||
then
|
||||
echo "Failed to pack react-native"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd "$TEMP_DIR"
|
||||
|
||||
if ! retry "$RETRY_COUNT" react-native init EndToEndTest --version "$PACKAGE" --npm
|
||||
then
|
||||
echo "Failed to execute react-native init"
|
||||
echo "Most common reason is npm registry connectivity, try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd EndToEndTest
|
||||
|
||||
# android tests
|
||||
if [ $RUN_ANDROID -ne 0 ]; then
|
||||
echo "Running an Android e2e test"
|
||||
echo "Installing e2e framework"
|
||||
|
||||
if ! retry "$RETRY_COUNT" npm install --save-dev "$ANDROID_NPM_DEPS" --silent >> /dev/null
|
||||
then
|
||||
echo "Failed to install appium"
|
||||
echo "Most common reason is npm registry connectivity, try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cp "$SCRIPTS/android-e2e-test.js" android-e2e-test.js
|
||||
|
||||
(
|
||||
cd android || exit
|
||||
echo "Downloading Maven deps"
|
||||
./gradlew :app:copyDownloadableDepsToLibs
|
||||
)
|
||||
|
||||
keytool -genkey -v -keystore android/keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
|
||||
|
||||
node ./node_modules/.bin/appium >> /dev/null &
|
||||
APPIUM_PID=$!
|
||||
echo "Starting appium server $APPIUM_PID"
|
||||
|
||||
echo "Building app"
|
||||
buck build android/app
|
||||
|
||||
# hack to get node unhung (kill buckd)
|
||||
if ! kill -9 "$(pgrep java)"
|
||||
then
|
||||
echo "could not execute Buck build, is it installed and in PATH?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Starting Metro"
|
||||
npm start >> /dev/null &
|
||||
SERVER_PID=$!
|
||||
sleep 15
|
||||
|
||||
echo "Executing android e2e test"
|
||||
if ! retry "$RETRY_COUNT" node node_modules/.bin/_mocha android-e2e-test.js
|
||||
then
|
||||
echo "Failed to run Android e2e tests"
|
||||
echo "Most likely the code is broken"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# kill packager process
|
||||
if kill -0 "$SERVER_PID"; then
|
||||
echo "Killing packager $SERVER_PID"
|
||||
kill -9 "$SERVER_PID"
|
||||
fi
|
||||
|
||||
# kill appium process
|
||||
if kill -0 "$APPIUM_PID"; then
|
||||
echo "Killing appium $APPIUM_PID"
|
||||
kill -9 "$APPIUM_PID"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# ios tests
|
||||
if [ $RUN_IOS -ne 0 ]; then
|
||||
echo "Running ios e2e tests not yet implemented for docker!"
|
||||
fi
|
||||
|
||||
# js tests
|
||||
if [ $RUN_JS -ne 0 ]; then
|
||||
# Check the packager produces a bundle (doesn't throw an error)
|
||||
if ! react-native bundle --max-workers 1 --platform android --dev true --entry-file index.js --bundle-output android-bundle.js
|
||||
then
|
||||
echo "Could not build android bundle"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! react-native bundle --max-workers 1 --platform ios --dev true --entry-file index.js --bundle-output ios-bundle.js
|
||||
then
|
||||
echo "Could not build iOS bundle"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# directory cleanup
|
||||
rm "$IOS_MARKER"
|
||||
rm "$ANDROID_MARKER"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
retry "$RETRY_COUNT" e2e_suite
|
||||
@@ -1,5 +0,0 @@
|
||||
# Circle CI
|
||||
|
||||
This directory is home to the Circle CI configuration file. Circle is our continuous integration service provider. You can see the overall status of React Native's builds at https://circleci.com/gh/facebook/react-native
|
||||
|
||||
You may also see an individual PR's build status by scrolling down to the Checks section in the PR.
|
||||
@@ -1,959 +0,0 @@
|
||||
version: 2.1
|
||||
|
||||
# -------------------------
|
||||
# ORBS
|
||||
# -------------------------
|
||||
|
||||
orbs:
|
||||
win: circleci/windows@2.4.0
|
||||
|
||||
# -------------------------
|
||||
# DEFAULTS
|
||||
# -------------------------
|
||||
defaults: &defaults
|
||||
working_directory: ~/react-native
|
||||
environment:
|
||||
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
|
||||
# The public github tokens are publicly visible by design
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_A: &github_pullbot_token_a "a6edf8e8d40ce4e8b11a"
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_B: &github_pullbot_token_b "150e1341f4dd9c944d2a"
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: &github_analysisbot_token_a "312d354b5c36f082cfe9"
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: &github_analysisbot_token_b "07973d757026bdd9f196"
|
||||
|
||||
# -------------------------
|
||||
# EXECUTORS
|
||||
# -------------------------
|
||||
executors:
|
||||
nodelts:
|
||||
<<: *defaults
|
||||
docker:
|
||||
# Note: Version set separately for Windows builds, see below.
|
||||
- image: circleci/node:14
|
||||
nodeprevlts:
|
||||
<<: *defaults
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
reactnativeandroid:
|
||||
<<: *defaults
|
||||
docker:
|
||||
- image: reactnativecommunity/react-native-android:4.0
|
||||
resource_class: "large"
|
||||
environment:
|
||||
- TERM: "dumb"
|
||||
- ADB_INSTALL_TIMEOUT: 10
|
||||
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
|
||||
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
|
||||
- BUILD_THREADS: 2
|
||||
# Repeated here, as the environment key in this executor will overwrite the one in defaults
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: *github_analysisbot_token_a
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: *github_analysisbot_token_b
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_A: *github_pullbot_token_a
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_B: *github_pullbot_token_b
|
||||
reactnativeios:
|
||||
<<: *defaults
|
||||
macos:
|
||||
xcode: &_XCODE_VERSION "13.0.0"
|
||||
|
||||
# -------------------------
|
||||
# COMMANDS
|
||||
# -------------------------
|
||||
commands:
|
||||
|
||||
setup_artifacts:
|
||||
steps:
|
||||
- run:
|
||||
name: Initial Setup
|
||||
command: mkdir -p ./reports/{buck,build,junit,outputs}
|
||||
|
||||
setup_ruby:
|
||||
steps:
|
||||
- restore_cache:
|
||||
key: 1-gems-{{ checksum "Gemfile.lock" }}
|
||||
- run: bundle check || bundle install --path vendor/bundle --clean
|
||||
- save_cache:
|
||||
key: 1-gems-{{ checksum "Gemfile.lock" }}
|
||||
paths:
|
||||
- vendor/bundle
|
||||
|
||||
run_yarn:
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: "Yarn: Install Dependencies"
|
||||
command: |
|
||||
# Skip yarn install on metro bump commits as the package is not yet
|
||||
# available on npm
|
||||
if [[ $(echo "$GIT_COMMIT_DESC" | grep -c "Bump metro@") -eq 0 ]]; then
|
||||
yarn install --non-interactive --cache-folder ~/.cache/yarn
|
||||
fi
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.cache/yarn
|
||||
key: v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
|
||||
|
||||
install_buck_tooling:
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}}
|
||||
- run:
|
||||
name: Install BUCK
|
||||
command: |
|
||||
buck --version
|
||||
# Install related tooling
|
||||
if [[ ! -e ~/okbuck ]]; then
|
||||
git clone https://github.com/uber/okbuck.git ~/okbuck --depth=1
|
||||
fi
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/buck
|
||||
- ~/okbuck
|
||||
key: v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}
|
||||
|
||||
install_github_bot_deps:
|
||||
steps:
|
||||
- run:
|
||||
name: "Yarn: Install dependencies (GitHub bots)"
|
||||
command: cd bots && yarn install --non-interactive --cache-folder ~/.cache/yarn
|
||||
|
||||
brew_install:
|
||||
parameters:
|
||||
package:
|
||||
description: Homebrew package to install
|
||||
type: string
|
||||
steps:
|
||||
- run:
|
||||
name: "Brew: Install << parameters.package >>"
|
||||
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install << parameters.package >> >/dev/null
|
||||
|
||||
with_brew_cache_span:
|
||||
parameters:
|
||||
steps:
|
||||
type: steps
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-brew
|
||||
- steps: << parameters.steps >>
|
||||
- save_cache:
|
||||
paths:
|
||||
- /usr/local/Homebrew
|
||||
- ~/Library/Caches/Homebrew
|
||||
key: v4-brew
|
||||
|
||||
with_rntester_pods_cache_span:
|
||||
parameters:
|
||||
steps:
|
||||
type: steps
|
||||
steps:
|
||||
- run:
|
||||
name: Setup CocoaPods cache
|
||||
# Copy packages/rn-tester/Podfile.lock since it can be changed by pod install
|
||||
command: cp packages/rn-tester/Podfile.lock packages/rn-tester/Podfile.lock.bak
|
||||
- restore_cache:
|
||||
keys:
|
||||
# The committed lockfile is generated using USE_FRAMEWORKS=0 and USE_HERMES=0 so it could load an outdated cache if a change
|
||||
# only affects the frameworks or hermes config. To help prevent this also cache based on the content of Podfile.
|
||||
- v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
|
||||
- steps: << parameters.steps >>
|
||||
- save_cache:
|
||||
paths:
|
||||
- packages/rn-tester/Pods
|
||||
key: v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
|
||||
|
||||
download_gradle_dependencies:
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }}
|
||||
- run:
|
||||
name: Download Dependencies Using Gradle
|
||||
command: ./scripts/circleci/gradle_download_deps.sh
|
||||
- save_cache:
|
||||
paths:
|
||||
- ~/.gradle
|
||||
- ReactAndroid/build/downloads
|
||||
- ReactAndroid/build/third-party-ndk
|
||||
key: v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }}
|
||||
|
||||
download_buck_dependencies:
|
||||
steps:
|
||||
- run:
|
||||
name: Download Dependencies Using Buck
|
||||
command: ./scripts/circleci/buck_fetch.sh
|
||||
|
||||
run_e2e:
|
||||
parameters:
|
||||
platform:
|
||||
description: Target platform
|
||||
type: enum
|
||||
enum: ["android", "ios", "js"]
|
||||
default: "js"
|
||||
retries:
|
||||
description: How many times the job should try to run these tests
|
||||
type: integer
|
||||
default: 3
|
||||
steps:
|
||||
- run:
|
||||
name: "Run Tests: << parameters.platform >> End-to-End Tests"
|
||||
command: node ./scripts/run-ci-e2e-tests.js --<< parameters.platform >> --retries << parameters.retries >>
|
||||
|
||||
report_bundle_size:
|
||||
parameters:
|
||||
platform:
|
||||
description: Target platform
|
||||
type: enum
|
||||
enum: ["android", "ios"]
|
||||
steps:
|
||||
- install_github_bot_deps
|
||||
- run:
|
||||
name: Report size of RNTester.app (analysis-bot)
|
||||
command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh << parameters.platform >>
|
||||
|
||||
# -------------------------
|
||||
# JOBS
|
||||
# -------------------------
|
||||
jobs:
|
||||
# -------------------------
|
||||
# JOBS: Analyze PR
|
||||
# -------------------------
|
||||
# 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_pr:
|
||||
executor: reactnativeandroid
|
||||
steps:
|
||||
- checkout
|
||||
- run_yarn
|
||||
|
||||
- install_github_bot_deps
|
||||
|
||||
# Note: The yarn gpg key needs to be refreshed to work around https://github.com/yarnpkg/yarn/issues/7866
|
||||
- run:
|
||||
name: Install additional GitHub bot dependencies
|
||||
# TEMP: Added workaround from https://github.com/nodesource/distributions/issues/1266#issuecomment-932583579
|
||||
command: |
|
||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
apt update && apt install -y shellcheck jq
|
||||
apt-get install openssl ca-certificates
|
||||
update-ca-certificates
|
||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
apt update && apt install -y shellcheck jq
|
||||
|
||||
- run:
|
||||
name: Run linters against modified files (analysis-bot)
|
||||
command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" yarn lint-ci
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Analyze Pull Request (pull-bot)
|
||||
command: |
|
||||
cd bots
|
||||
DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks
|
||||
when: always
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Analyze Code
|
||||
# -------------------------
|
||||
analyze_code:
|
||||
executor: reactnativeandroid
|
||||
steps:
|
||||
- checkout
|
||||
- setup_artifacts
|
||||
- run_yarn
|
||||
|
||||
- run:
|
||||
name: Lint code
|
||||
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ./reports/junit/eslint/results.xml
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Lint Java
|
||||
command: scripts/circleci/exec_swallow_error.sh yarn lint-java --check
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Check for errors in code using Flow (iOS)
|
||||
command: yarn flow-check-ios
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Check for errors in code using Flow (Android)
|
||||
command: yarn flow-check-android
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Sanity checks
|
||||
command: |
|
||||
./scripts/circleci/check_license.sh
|
||||
./scripts/circleci/validate_yarn_lockfile.sh
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Check formatting
|
||||
command: yarn run format-check
|
||||
when: always
|
||||
|
||||
- store_test_results:
|
||||
path: ./reports/junit
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Test JavaScript
|
||||
# -------------------------
|
||||
test_js:
|
||||
parameters:
|
||||
executor:
|
||||
type: executor
|
||||
default: nodelts
|
||||
run_disabled_tests:
|
||||
type: boolean
|
||||
default: false
|
||||
executor: << parameters.executor >>
|
||||
steps:
|
||||
- checkout
|
||||
- setup_artifacts
|
||||
- run_yarn
|
||||
- run:
|
||||
name: Install rsync
|
||||
command: sudo apt-get install rsync
|
||||
|
||||
# -------------------------
|
||||
# Run JavaScript tests
|
||||
- run:
|
||||
name: "Run Tests: JavaScript Tests"
|
||||
command: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
|
||||
- run_e2e:
|
||||
platform: js
|
||||
|
||||
# Optionally, run disabled tests
|
||||
- when:
|
||||
condition: << parameters.run_disabled_tests >>
|
||||
steps:
|
||||
- run: echo "Failing tests may be moved here temporarily."
|
||||
# -------------------------
|
||||
|
||||
- store_test_results:
|
||||
path: ./reports/junit
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Test iOS
|
||||
# -------------------------
|
||||
test_ios:
|
||||
executor: reactnativeios
|
||||
parameters:
|
||||
use_frameworks:
|
||||
type: boolean
|
||||
default: false
|
||||
use_hermes:
|
||||
type: boolean
|
||||
default: false
|
||||
run_unit_tests:
|
||||
description: Specifies whether unit tests should run.
|
||||
type: boolean
|
||||
default: false
|
||||
run_detox_tests:
|
||||
description: Specifies whether Detox e2e tests should run.
|
||||
type: boolean
|
||||
default: false
|
||||
run_disabled_tests:
|
||||
description: Specifies whether disabled tests should run. Set this to true to debug failing tests.
|
||||
type: boolean
|
||||
default: false
|
||||
environment:
|
||||
- REPORTS_DIR: "./reports/junit"
|
||||
steps:
|
||||
- checkout
|
||||
- setup_artifacts
|
||||
- setup_ruby
|
||||
- run_yarn
|
||||
|
||||
- run: |
|
||||
cd packages/rn-tester
|
||||
bundle check || bundle install
|
||||
- run:
|
||||
name: Boot iPhone Simulator
|
||||
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
|
||||
|
||||
- run:
|
||||
name: Configure Environment Variables
|
||||
command: |
|
||||
echo 'export PATH=/usr/local/opt/node@14/bin:$PATH' >> $BASH_ENV
|
||||
source $BASH_ENV
|
||||
|
||||
- with_brew_cache_span:
|
||||
steps:
|
||||
- brew_install:
|
||||
package: watchman
|
||||
- run:
|
||||
name: "Brew: Tap wix/brew"
|
||||
command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
|
||||
- brew_install:
|
||||
package: applesimutils
|
||||
|
||||
- run:
|
||||
name: Configure Node
|
||||
# Sourcing find-node.sh will ensure nvm is set up.
|
||||
# It also helps future invocation of find-node.sh prevent permission issue with nvm.sh.
|
||||
command: source scripts/find-node.sh && nvm install 14 && nvm alias default 14
|
||||
|
||||
- run:
|
||||
name: Configure Watchman
|
||||
command: echo "{}" > .watchmanconfig
|
||||
|
||||
- when:
|
||||
condition: << parameters.use_frameworks >>
|
||||
steps:
|
||||
- run:
|
||||
name: Set USE_FRAMEWORKS=1
|
||||
command: echo "export USE_FRAMEWORKS=1" >> $BASH_ENV
|
||||
|
||||
- when:
|
||||
condition: << parameters.use_hermes >>
|
||||
steps:
|
||||
- run:
|
||||
name: Set USE_HERMES=1
|
||||
command: echo "export USE_HERMES=1" >> $BASH_ENV
|
||||
|
||||
- run:
|
||||
name: Setup the CocoaPods environment
|
||||
command: bundle exec pod setup
|
||||
|
||||
- with_rntester_pods_cache_span:
|
||||
steps:
|
||||
- run:
|
||||
name: Generate RNTesterPods Workspace
|
||||
command: cd packages/rn-tester && bundle exec pod install --verbose
|
||||
|
||||
# -------------------------
|
||||
# Runs iOS unit tests
|
||||
- when:
|
||||
condition: << parameters.run_unit_tests >>
|
||||
steps:
|
||||
- run:
|
||||
name: "Run Tests: iOS Unit and Integration Tests"
|
||||
command: yarn test-ios
|
||||
# Runs iOS Detox e2e tests
|
||||
- when:
|
||||
condition: << parameters.run_detox_tests >>
|
||||
steps:
|
||||
- run:
|
||||
name: "Run Tests: Detox iOS End-to-End Tests"
|
||||
command: yarn run build-ios-e2e && yarn run test-ios-e2e
|
||||
|
||||
# Optionally, run disabled tests
|
||||
- when:
|
||||
condition: << parameters.run_disabled_tests >>
|
||||
steps:
|
||||
- run: echo "Failing tests may be moved here temporarily."
|
||||
- run:
|
||||
name: "Run Tests: CocoaPods"
|
||||
command: ./scripts/process-podspecs.sh
|
||||
- run:
|
||||
name: Free up port 8081 for iOS End-to-End Tests
|
||||
command: |
|
||||
# free up port 8081 for the packager before running tests
|
||||
set +eo pipefail
|
||||
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
|
||||
set -eo pipefail
|
||||
- run_e2e:
|
||||
platform: ios
|
||||
# -------------------------
|
||||
|
||||
# Collect Results
|
||||
- report_bundle_size:
|
||||
platform: ios
|
||||
- store_test_results:
|
||||
path: ./reports/junit
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Test Android
|
||||
# -------------------------
|
||||
test_android:
|
||||
executor: reactnativeandroid
|
||||
parameters:
|
||||
run_disabled_tests:
|
||||
type: boolean
|
||||
default: false
|
||||
steps:
|
||||
- checkout
|
||||
- setup_artifacts
|
||||
- run_yarn
|
||||
|
||||
# Validate Android SDK installation and packages
|
||||
- run:
|
||||
name: Validate Android SDK Install
|
||||
command: ./scripts/validate-android-sdk.sh
|
||||
|
||||
# Starting emulator in advance as it takes some time to boot.
|
||||
- run:
|
||||
name: Create Android Virtual Device
|
||||
command: source scripts/android-setup.sh && createAVD
|
||||
- run:
|
||||
name: Launch Android Virtual Device in Background
|
||||
command: source scripts/android-setup.sh && launchAVD
|
||||
background: true
|
||||
|
||||
# Install Buck
|
||||
- install_buck_tooling
|
||||
|
||||
# Validate Android test environment (including Buck)
|
||||
- run:
|
||||
name: Validate Android Test Environment
|
||||
command: ./scripts/validate-android-test-env.sh
|
||||
|
||||
- download_buck_dependencies
|
||||
- download_gradle_dependencies
|
||||
|
||||
# Build and compile
|
||||
- run:
|
||||
name: Build Android App
|
||||
command: |
|
||||
buck build ReactAndroid/src/main/java/com/facebook/react
|
||||
buck build ReactAndroid/src/main/java/com/facebook/react/shell
|
||||
- run:
|
||||
name: Compile Native Libs for Unit and Integration Tests
|
||||
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS
|
||||
no_output_timeout: 6m
|
||||
|
||||
# Build JavaScript Bundle for instrumentation tests
|
||||
- run:
|
||||
name: Build JavaScript Bundle
|
||||
command: node cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
|
||||
|
||||
# Wait for AVD to finish booting before running tests
|
||||
- run:
|
||||
name: Wait for Android Virtual Device
|
||||
command: source scripts/android-setup.sh && waitForAVD
|
||||
|
||||
- run:
|
||||
name: Assemble RNTester App
|
||||
command: ./gradlew packages:rn-tester:android:app:assembleRelease
|
||||
|
||||
# -------------------------
|
||||
# Run Android tests
|
||||
- run:
|
||||
name: "Run Tests: Android Unit Tests"
|
||||
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ./reports/buck/all-results-raw.xml
|
||||
- run:
|
||||
name: "Build Tests: Android Instrumentation Tests"
|
||||
# Here, just build the instrumentation tests. There is a known issue with installing the APK to android-21+ emulator.
|
||||
command: |
|
||||
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
|
||||
echo "JavaScript bundle missing, cannot run instrumentation tests. Verify Build JavaScript Bundle step completed successfully."; exit 1;
|
||||
fi
|
||||
source scripts/android-setup.sh && NO_BUCKD=1 retry3 timeout 300 buck build ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
|
||||
|
||||
# Optionally, run disabled tests
|
||||
- when:
|
||||
condition: << parameters.run_disabled_tests >>
|
||||
steps:
|
||||
- run: echo "Failing tests may be moved here temporarily."
|
||||
- run_e2e:
|
||||
platform: android
|
||||
# -------------------------
|
||||
|
||||
# Collect Results
|
||||
- report_bundle_size:
|
||||
platform: android
|
||||
- run:
|
||||
name: Collect Test Results
|
||||
command: |
|
||||
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ./reports/build/ \;
|
||||
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ./reports/outputs/ \;
|
||||
find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ./reports/buck/ \;
|
||||
if [ -f ~/react-native/reports/buck/all-results-raw.xml ]; then
|
||||
cd ~/okbuck
|
||||
./tooling/junit/buck_to_junit.sh ~/react-native/reports/buck/all-results-raw.xml ~/react-native/reports/junit/results.xml
|
||||
fi
|
||||
when: always
|
||||
- store_test_results:
|
||||
path: ./reports/junit
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Test Android Template
|
||||
# -------------------------
|
||||
test_android_template:
|
||||
executor: reactnativeandroid
|
||||
steps:
|
||||
- checkout
|
||||
- run_yarn
|
||||
|
||||
- run:
|
||||
name: Setup the Android Template
|
||||
command: |
|
||||
cd template
|
||||
sed -i 's/1000\.0\.0/file\:\.\./g' package.json
|
||||
npm install
|
||||
# react-native-community/cli is needed as the Android template is referencing a .gradle file inside it.
|
||||
npm i @react-native-community/cli
|
||||
|
||||
- run:
|
||||
name: Bundle the latest version of ReactAndroid
|
||||
command: ./gradlew :ReactAndroid:publishReleasePublicationToNpmRepository
|
||||
|
||||
- run:
|
||||
name: Build the template application
|
||||
command: cd template/android/ && ./gradlew assembleDebug
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Windows
|
||||
# -------------------------
|
||||
test_windows:
|
||||
executor:
|
||||
name: win/default
|
||||
parameters:
|
||||
run_disabled_tests:
|
||||
type: boolean
|
||||
default: false
|
||||
environment:
|
||||
- ANDROID_HOME: "C:\\Android\\android-sdk"
|
||||
- ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944"
|
||||
- ANDROID_BUILD_VERSION: 30
|
||||
- ANDROID_TOOLS_VERSION: 30.0.2
|
||||
- GRADLE_OPTS: -Dorg.gradle.daemon=false
|
||||
- NDK_VERSION: 21.4.7075529
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
- run:
|
||||
name: Install Node
|
||||
# Note: Version set separately for non-Windows builds, see above.
|
||||
command: |
|
||||
nvm install 14.17.0
|
||||
nvm use 14.17.0
|
||||
|
||||
# Setup Dependencies
|
||||
- run:
|
||||
name: Install Yarn
|
||||
command: choco install yarn
|
||||
|
||||
- run:
|
||||
name: Display Environment info
|
||||
command: npx envinfo@latest
|
||||
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: "Yarn: Install Dependencies"
|
||||
command: yarn install --frozen-lockfile --non-interactive
|
||||
- save_cache:
|
||||
key: v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- C:\Users\circleci\AppData\Local\Yarn
|
||||
|
||||
# Try to install the SDK up to 3 times, since network flakiness can cause install failures
|
||||
# Using a timeout of 9 mins, as circle ci will timeout if there is no output for 10 mins
|
||||
- run:
|
||||
name: Install Android SDK Tools
|
||||
command: choco install android-sdk --timeout 540; if (!$?) { choco install android-sdk --timeout 540 --force --forcedependencies}; if (!$?) { choco install android-sdk --force --forcedependencies}
|
||||
|
||||
- run:
|
||||
name: Setup Android SDKs
|
||||
command: |
|
||||
sdkmanager --licenses
|
||||
sdkmanager "system-images;android-21;google_apis;armeabi-v7a"
|
||||
sdkmanager "platforms;android-%ANDROID_BUILD_VERSION%"
|
||||
sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%"
|
||||
sdkmanager "add-ons;addon-google_apis-google-23"
|
||||
sdkmanager "extras;android;m2repository"
|
||||
sdkmanager "ndk;%NDK_VERSION%"
|
||||
|
||||
# -------------------------
|
||||
# Run Tests
|
||||
- run:
|
||||
name: "Flow: Check Android"
|
||||
command: yarn flow-check-android
|
||||
- run:
|
||||
name: "Flow: Check iOS"
|
||||
command: yarn flow-check-ios
|
||||
- run:
|
||||
name: "Run Tests: JavaScript Tests"
|
||||
command: yarn test
|
||||
|
||||
# Optionally, run disabled tests
|
||||
- when:
|
||||
condition: << parameters.run_disabled_tests >>
|
||||
steps:
|
||||
- run: echo "Failing tests may be moved here temporarily."
|
||||
- run:
|
||||
name: Android Build
|
||||
command: ./gradlew.bat packages:rn-tester:android:app:assembleRelease
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Coverage
|
||||
# -------------------------
|
||||
# Collect JavaScript test coverage
|
||||
js_coverage:
|
||||
executor: nodelts
|
||||
environment:
|
||||
- CI_BRANCH: $CIRCLE_BRANCH
|
||||
- CI_PULL_REQUEST: $CIRCLE_PULL_REQUEST
|
||||
- CI_BUILD_NUMBER: $CIRCLE_BUILD_NUM
|
||||
- CI_BUILD_URL: $CIRCLE_BUILD_URL
|
||||
steps:
|
||||
- checkout
|
||||
- setup_artifacts
|
||||
- run_yarn
|
||||
- run:
|
||||
name: Collect test coverage information
|
||||
command: |
|
||||
scripts/circleci/exec_swallow_error.sh yarn test --coverage --maxWorkers=2
|
||||
if [[ -e ./coverage/lcov.info ]]; then
|
||||
cat ./coverage/lcov.info | scripts/circleci/exec_swallow_error.sh ./node_modules/.bin/coveralls
|
||||
fi
|
||||
- store_artifacts:
|
||||
path: ~/react-native/coverage/
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Releases
|
||||
# -------------------------
|
||||
prepare_package_for_release:
|
||||
parameters:
|
||||
version:
|
||||
type: string
|
||||
latest:
|
||||
type: boolean
|
||||
default: false
|
||||
executor: reactnativeios
|
||||
steps:
|
||||
- checkout
|
||||
- run_yarn
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- "1c:98:e0:3a:52:79:95:29:12:cd:b4:87:5b:41:e2:bb"
|
||||
- run:
|
||||
name: "Set new react-native version and commit changes"
|
||||
command: |
|
||||
node ./scripts/prepare-package-for-release.js -v << parameters.version >> -l << parameters.latest >>
|
||||
|
||||
build_npm_package:
|
||||
parameters:
|
||||
publish_npm_args:
|
||||
type: string
|
||||
default: --dry-run
|
||||
executor: reactnativeandroid
|
||||
steps:
|
||||
- run:
|
||||
name: Add github.com to SSH known hosts
|
||||
command: |
|
||||
mkdir -p ~/.ssh
|
||||
echo '|1|If6MU203eXTaaWL678YEfWkVMrw=|kqLeIAyTy8pzpj8x8Ae4Fr8Mtlc= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
|
||||
- checkout
|
||||
- run_yarn
|
||||
- install_buck_tooling
|
||||
- download_buck_dependencies
|
||||
- download_gradle_dependencies
|
||||
# Only tagged releases and nightlies should be able to publish to npm
|
||||
- when:
|
||||
condition:
|
||||
or:
|
||||
- equal: [ --release, << parameters.publish_npm_args >> ]
|
||||
- equal: [ --nightly, << parameters.publish_npm_args >> ]
|
||||
steps:
|
||||
- run: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
|
||||
- run: |
|
||||
git config --global user.email "react-native-bot@users.noreply.github.com"
|
||||
git config --global user.name "npm Deployment Script"
|
||||
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
|
||||
- run: node ./scripts/publish-npm.js << parameters.publish_npm_args >>
|
||||
- when:
|
||||
condition:
|
||||
equal: [ --dry-run, << parameters.publish_npm_args >> ]
|
||||
steps:
|
||||
- run:
|
||||
name: Build release package as a job artifact
|
||||
command: |
|
||||
mkdir -p build
|
||||
FILENAME=$(npm pack)
|
||||
mv $FILENAME build/
|
||||
- store_artifacts:
|
||||
path: ~/react-native/build/
|
||||
destination: build
|
||||
- when:
|
||||
condition:
|
||||
matches: { pattern: '^pull\/.*$', value: << pipeline.git.branch >> }
|
||||
steps:
|
||||
- install_github_bot_deps
|
||||
- run:
|
||||
name: Post link to PR build artifacts (pull-bot)
|
||||
command: GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh
|
||||
|
||||
# -------------------------
|
||||
# JOBS: Nightly
|
||||
# -------------------------
|
||||
nightly_job:
|
||||
machine:
|
||||
image: ubuntu-2004:202010-01
|
||||
steps:
|
||||
- run:
|
||||
name: Nightly
|
||||
command: |
|
||||
echo "Nightly build run"
|
||||
|
||||
|
||||
# -------------------------
|
||||
# PIPELINE PARAMETERS
|
||||
# -------------------------
|
||||
parameters:
|
||||
run_package_release_workflow_only:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_latest:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_version:
|
||||
default: "9999"
|
||||
type: string
|
||||
|
||||
# -------------------------
|
||||
# WORK FLOWS
|
||||
#
|
||||
# When creating a new workflow, make sure to include condition `unless: << pipeline.parameters.run_package_release_workflow_only >>`
|
||||
# It's setup this way so we can trigger a release via a POST
|
||||
# See limitations: https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2
|
||||
# -------------------------
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
tests:
|
||||
unless: << pipeline.parameters.run_package_release_workflow_only >>
|
||||
jobs:
|
||||
- test_js:
|
||||
run_disabled_tests: false
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- test_android:
|
||||
run_disabled_tests: false
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- test_android_template:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- test_ios:
|
||||
name: test_ios_unit_jsc
|
||||
run_unit_tests: true
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
|
||||
# - test_ios:
|
||||
# name: test_ios_unit_frameworks_jsc
|
||||
# use_frameworks: true
|
||||
# run_unit_tests: true
|
||||
- test_ios:
|
||||
name: test_ios_unit_hermes
|
||||
use_hermes: true
|
||||
run_unit_tests: true
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
|
||||
# - test_ios:
|
||||
# name: test_ios_unit_frameworks_hermes
|
||||
# use_hermes: true
|
||||
# use_frameworks: true
|
||||
# run_unit_tests: true
|
||||
# DISABLED: Detox tests need to be fixed
|
||||
# - test_ios:
|
||||
# name: test_ios_detox
|
||||
# run_detox_tests: true
|
||||
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
|
||||
# - test_ios:
|
||||
# name: test_ios_detox_frameworks
|
||||
# use_frameworks: true
|
||||
# run_detox_tests: true
|
||||
- test_js:
|
||||
name: test_js_prev_lts
|
||||
executor: nodeprevlts
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- test_windows:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
run_disabled_tests: false
|
||||
|
||||
# This workflow should only be triggered by release script
|
||||
package_release:
|
||||
when: << pipeline.parameters.run_package_release_workflow_only >>
|
||||
jobs:
|
||||
# This job will trigger publish_release workflow
|
||||
- prepare_package_for_release:
|
||||
name: prepare_package_for_release
|
||||
version: << pipeline.parameters.release_version >>
|
||||
latest : << pipeline.parameters.release_latest >>
|
||||
|
||||
publish_release:
|
||||
unless: << pipeline.parameters.run_package_release_workflow_only >>
|
||||
jobs:
|
||||
# This job will trigger when a version tag is pushed (by package_release)
|
||||
- build_npm_package:
|
||||
name: build_and_publish_npm_package
|
||||
publish_npm_args: --release
|
||||
# CircleCI filters are OR-ed, with all branches triggering by default and tags excluded by default
|
||||
# CircleCI env-vars are only set with the branch OR tag that triggered the job, not both.
|
||||
# In this case, CIRCLE_BRANCH is unset, but CIRCLE_TAG is set
|
||||
filters:
|
||||
# Both of the following conditions must be included!
|
||||
# Ignore any commit on any branch by default.
|
||||
branches:
|
||||
ignore: /.*/
|
||||
# Only act on version tags.
|
||||
tags:
|
||||
only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
|
||||
- build_npm_package:
|
||||
# Build a release package on every untagged commit, but do not publish to npm.
|
||||
publish_npm_args: --dry-run
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- main
|
||||
- /^pull\/.*$/
|
||||
- /^(\d+)\.(\d+)-stable$/
|
||||
tags:
|
||||
ignore: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
|
||||
|
||||
analysis:
|
||||
unless: << pipeline.parameters.run_package_release_workflow_only >>
|
||||
jobs:
|
||||
# Run lints on every commit other than those to the gh-pages branch
|
||||
- analyze_code:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
|
||||
# Run code checks on PRs from forks
|
||||
- analyze_pr:
|
||||
filters:
|
||||
branches:
|
||||
only: /^pull\/.*$/
|
||||
|
||||
# Gather coverage
|
||||
- js_coverage:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
|
||||
nightly:
|
||||
unless: << pipeline.parameters.run_package_release_workflow_only >>
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "0 20 * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- main
|
||||
jobs:
|
||||
- nightly_job
|
||||
|
||||
- build_npm_package:
|
||||
publish_npm_args: --nightly
|
||||
@@ -1,91 +0,0 @@
|
||||
---
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*\.h(pp)?>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
---
|
||||
Language: ObjC
|
||||
ColumnLimit: 120
|
||||
BreakBeforeBraces: WebKit
|
||||
...
|
||||
+1
-7
@@ -1,4 +1,4 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
@@ -12,9 +12,3 @@ indent_size = 2
|
||||
|
||||
[*.gradle]
|
||||
indent_size = 4
|
||||
|
||||
[*.kts]
|
||||
indent_size = 4
|
||||
|
||||
[BUCK]
|
||||
indent_size = 4
|
||||
|
||||
+12
-8
@@ -1,10 +1,14 @@
|
||||
**/main.js
|
||||
# node_modules ignored by default
|
||||
|
||||
**/staticBundle.js
|
||||
bots/node_modules
|
||||
docs/generatedComponentApiDocs.js
|
||||
flow/
|
||||
Libraries/Renderer/*
|
||||
**/main.js
|
||||
Libraries/vendor/**/*
|
||||
node_modules/
|
||||
packages/*/node_modules
|
||||
packages/react-native-codegen/lib
|
||||
Libraries/Renderer/*
|
||||
website/node_modules
|
||||
pr-inactivity-bookmarklet.js
|
||||
question-bookmarklet.js
|
||||
flow/
|
||||
website/core/metadata.js
|
||||
website/core/metadata-blog.js
|
||||
website/src/react-native/docs/
|
||||
website/src/react-native/blog/
|
||||
|
||||
@@ -1,60 +1,238 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": [
|
||||
"./packages/eslint-config-react-native-community/index.js"
|
||||
],
|
||||
"parser": "babel-eslint",
|
||||
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
|
||||
"env": {
|
||||
"es6": true,
|
||||
"jasmine": true,
|
||||
},
|
||||
|
||||
"plugins": [
|
||||
"@react-native/eslint-plugin-codegen"
|
||||
"flowtype",
|
||||
"prettier",
|
||||
"react"
|
||||
],
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"Libraries/**/*.js",
|
||||
],
|
||||
"rules": {
|
||||
"@react-native-community/no-haste-imports": 2,
|
||||
"@react-native-community/error-subclass-name": 2,
|
||||
"@react-native-community/platform-colors": 2,
|
||||
"@react-native/codegen/react-native-modules": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"flow-typed/**/*.js",
|
||||
],
|
||||
"rules": {
|
||||
quotes: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"**/__fixtures__/**/*.js",
|
||||
"**/__mocks__/**/*.js",
|
||||
"**/__tests__/**/*.js",
|
||||
"jest/**/*.js",
|
||||
"packages/rn-tester/**/*.js",
|
||||
],
|
||||
"globals": {
|
||||
// Expose some Jest globals for test helpers
|
||||
"afterAll": true,
|
||||
"afterEach": true,
|
||||
"beforeAll": true,
|
||||
"beforeEach": true,
|
||||
"expect": true,
|
||||
"jest": true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"**/__tests__/**/*-test.js",
|
||||
],
|
||||
"env": {
|
||||
"jasmine": true,
|
||||
"jest": true
|
||||
}
|
||||
}
|
||||
]
|
||||
// Map from global var to bool specifying if it can be redefined
|
||||
"globals": {
|
||||
"__DEV__": true,
|
||||
"__dirname": false,
|
||||
"__fbBatchedBridgeConfig": false,
|
||||
"alert": false,
|
||||
"cancelAnimationFrame": false,
|
||||
"cancelIdleCallback": false,
|
||||
"clearImmediate": true,
|
||||
"clearInterval": false,
|
||||
"clearTimeout": false,
|
||||
"console": false,
|
||||
"document": false,
|
||||
"escape": false,
|
||||
"Event": false,
|
||||
"EventTarget": false,
|
||||
"exports": false,
|
||||
"fetch": false,
|
||||
"FormData": false,
|
||||
"global": false,
|
||||
"jest": false,
|
||||
"Map": true,
|
||||
"module": false,
|
||||
"navigator": false,
|
||||
"process": false,
|
||||
"Promise": true,
|
||||
"requestAnimationFrame": true,
|
||||
"requestIdleCallback": true,
|
||||
"require": false,
|
||||
"Set": true,
|
||||
"setImmediate": true,
|
||||
"setInterval": false,
|
||||
"setTimeout": false,
|
||||
"window": false,
|
||||
"XMLHttpRequest": false,
|
||||
"pit": false
|
||||
},
|
||||
|
||||
"rules": {
|
||||
// Flow Plugin
|
||||
// The following rules are made available via `eslint-plugin-flowtype`
|
||||
"flowtype/define-flow-type": 1,
|
||||
"flowtype/use-flow-type": 1,
|
||||
|
||||
// General
|
||||
|
||||
"comma-dangle": 0, // disallow trailing commas in object literals
|
||||
"no-cond-assign": 1, // disallow assignment in conditional expressions
|
||||
"no-console": 0, // disallow use of console (off by default in the node environment)
|
||||
"no-const-assign": 2, // disallow assignment to const-declared variables
|
||||
"no-constant-condition": 0, // disallow use of constant expressions in conditions
|
||||
"no-control-regex": 1, // disallow control characters in regular expressions
|
||||
"no-debugger": 1, // disallow use of debugger
|
||||
"no-dupe-keys": 1, // disallow duplicate keys when creating object literals
|
||||
"no-empty": 0, // disallow empty statements
|
||||
"no-ex-assign": 1, // disallow assigning to the exception in a catch block
|
||||
"no-extra-boolean-cast": 1, // disallow double-negation boolean casts in a boolean context
|
||||
"no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
|
||||
"no-extra-semi": 1, // disallow unnecessary semicolons
|
||||
"no-func-assign": 1, // disallow overwriting functions written as function declarations
|
||||
"no-inner-declarations": 0, // disallow function or variable declarations in nested blocks
|
||||
"no-invalid-regexp": 1, // disallow invalid regular expression strings in the RegExp constructor
|
||||
"no-negated-in-lhs": 1, // disallow negation of the left operand of an in expression
|
||||
"no-obj-calls": 1, // disallow the use of object properties of the global object (Math and JSON) as functions
|
||||
"no-regex-spaces": 1, // disallow multiple spaces in a regular expression literal
|
||||
"no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default)
|
||||
"no-sparse-arrays": 1, // disallow sparse arrays
|
||||
"no-unreachable": 1, // disallow unreachable statements after a return, throw, continue, or break statement
|
||||
"use-isnan": 1, // disallow comparisons with the value NaN
|
||||
"valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
|
||||
"valid-typeof": 1, // Ensure that the results of typeof are compared against a valid string
|
||||
|
||||
// Best Practices
|
||||
// These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
|
||||
|
||||
"block-scoped-var": 0, // treat var statements as if they were block scoped (off by default)
|
||||
"complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
|
||||
"consistent-return": 0, // require return statements to either always or never specify values
|
||||
"curly": 1, // specify curly brace conventions for all control statements
|
||||
"default-case": 0, // require default case in switch statements (off by default)
|
||||
"dot-notation": 1, // encourages use of dot notation whenever possible
|
||||
"eqeqeq": [1, "allow-null"], // require the use of === and !==
|
||||
"guard-for-in": 0, // make sure for-in loops have an if statement (off by default)
|
||||
"no-alert": 1, // disallow the use of alert, confirm, and prompt
|
||||
"no-caller": 1, // disallow use of arguments.caller or arguments.callee
|
||||
"no-div-regex": 1, // disallow division operators explicitly at beginning of regular expression (off by default)
|
||||
"no-else-return": 0, // disallow else after a return in an if (off by default)
|
||||
"no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default)
|
||||
"no-eval": 1, // disallow use of eval()
|
||||
"no-extend-native": 1, // disallow adding to native types
|
||||
"no-extra-bind": 1, // disallow unnecessary function binding
|
||||
"no-fallthrough": 1, // disallow fallthrough of case statements
|
||||
"no-floating-decimal": 1, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
|
||||
"no-implied-eval": 1, // disallow use of eval()-like methods
|
||||
"no-labels": 1, // disallow use of labeled statements
|
||||
"no-iterator": 1, // disallow usage of __iterator__ property
|
||||
"no-lone-blocks": 1, // disallow unnecessary nested blocks
|
||||
"no-loop-func": 0, // disallow creation of functions within loops
|
||||
"no-multi-str": 0, // disallow use of multiline strings
|
||||
"no-native-reassign": 0, // disallow reassignments of native objects
|
||||
"no-new": 1, // disallow use of new operator when not part of the assignment or comparison
|
||||
"no-new-func": 1, // disallow use of new operator for Function object
|
||||
"no-new-wrappers": 1, // disallows creating new instances of String,Number, and Boolean
|
||||
"no-octal": 1, // disallow use of octal literals
|
||||
"no-octal-escape": 1, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
|
||||
"no-proto": 1, // disallow usage of __proto__ property
|
||||
"no-redeclare": 0, // disallow declaring the same variable more then once
|
||||
"no-return-assign": 1, // disallow use of assignment in return statement
|
||||
"no-script-url": 1, // disallow use of javascript: urls.
|
||||
"no-self-compare": 1, // disallow comparisons where both sides are exactly the same (off by default)
|
||||
"no-sequences": 1, // disallow use of comma operator
|
||||
"no-unused-expressions": 0, // disallow usage of expressions in statement position
|
||||
"no-void": 1, // disallow use of void operator (off by default)
|
||||
"no-warning-comments": 0, // disallow usage of configurable warning terms in comments": 1, // e.g. TODO or FIXME (off by default)
|
||||
"no-with": 1, // disallow use of the with statement
|
||||
"radix": 1, // require use of the second argument for parseInt() (off by default)
|
||||
"semi-spacing": 1, // require a space after a semi-colon
|
||||
"vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
|
||||
"wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
|
||||
"yoda": 1, // require or disallow Yoda conditions
|
||||
|
||||
// Variables
|
||||
// These rules have to do with variable declarations.
|
||||
|
||||
"no-catch-shadow": 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
|
||||
"no-delete-var": 1, // disallow deletion of variables
|
||||
"no-label-var": 1, // disallow labels that share a name with a variable
|
||||
"no-shadow": 1, // disallow declaration of variables already declared in the outer scope
|
||||
"no-shadow-restricted-names": 1, // disallow shadowing of names such as arguments
|
||||
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
|
||||
"no-undefined": 0, // disallow use of undefined variable (off by default)
|
||||
"no-undef-init": 1, // disallow use of undefined when initializing variables
|
||||
"no-unused-vars": [1, {"vars": "all", "args": "none"}], // disallow declaration of variables that are not used in the code
|
||||
"no-use-before-define": 0, // disallow use of variables before they are defined
|
||||
|
||||
// Node.js
|
||||
// These rules are specific to JavaScript running on Node.js.
|
||||
|
||||
"handle-callback-err": 1, // enforces error handling in callbacks (off by default) (on by default in the node environment)
|
||||
"no-mixed-requires": 1, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment)
|
||||
"no-new-require": 1, // disallow use of new operator with the require function (off by default) (on by default in the node environment)
|
||||
"no-path-concat": 1, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment)
|
||||
"no-process-exit": 0, // disallow process.exit() (on by default in the node environment)
|
||||
"no-restricted-modules": 1, // restrict usage of specified node modules (off by default)
|
||||
"no-sync": 0, // disallow use of synchronous methods (off by default)
|
||||
|
||||
// Prettier Plugin
|
||||
// https://github.com/prettier/eslint-plugin-prettier
|
||||
"prettier/prettier": [2, "fb", "@format"],
|
||||
|
||||
// Stylistic Issues
|
||||
// These rules are purely matters of style and are quite subjective.
|
||||
|
||||
"key-spacing": 0,
|
||||
"keyword-spacing": 1, // enforce spacing before and after keywords
|
||||
"jsx-quotes": [1, "prefer-double"],
|
||||
"comma-spacing": 0,
|
||||
"no-multi-spaces": 0,
|
||||
"brace-style": 0, // enforce one true brace style (off by default)
|
||||
"camelcase": 0, // require camel case names
|
||||
"consistent-this": [1, "self"], // enforces consistent naming when capturing the current execution context (off by default)
|
||||
"eol-last": 1, // enforce newline at the end of file, with no multiple empty lines
|
||||
"func-names": 0, // require function expressions to have a name (off by default)
|
||||
"func-style": 0, // enforces use of function declarations or expressions (off by default)
|
||||
"new-cap": 0, // require a capital letter for constructors
|
||||
"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-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
|
||||
"no-ternary": 0, // disallow the use of ternary operators (off by default)
|
||||
"no-trailing-spaces": 1, // disallow trailing whitespace at the end of lines
|
||||
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
|
||||
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
|
||||
"quotes": [1, "single", "avoid-escape"], // specify whether double or single quotes should be used
|
||||
"quote-props": 0, // require quotes around object literal property names (off by default)
|
||||
"semi": 1, // require or disallow use of semicolons instead of ASI
|
||||
"sort-vars": 0, // sort variables within the same declaration block (off by default)
|
||||
"space-in-brackets": 0, // require or disallow spaces inside brackets (off by default)
|
||||
"space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
|
||||
"space-infix-ops": 1, // require spaces around operators
|
||||
"space-unary-ops": [1, { "words": true, "nonwords": false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
|
||||
"max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
|
||||
"one-var": 0, // allow just one var statement per function (off by default)
|
||||
"wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
|
||||
|
||||
// Legacy
|
||||
// The following rules are included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same.
|
||||
|
||||
"max-depth": 0, // specify the maximum depth that blocks can be nested (off by default)
|
||||
"max-len": 0, // specify the maximum length of a line in your program (off by default)
|
||||
"max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default)
|
||||
"max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
|
||||
"no-bitwise": 1, // disallow use of bitwise operators (off by default)
|
||||
"no-plusplus": 0, // disallow use of unary operators, ++ and -- (off by default)
|
||||
|
||||
// React Plugin
|
||||
// The following rules are made available via `eslint-plugin-react`.
|
||||
|
||||
"react/display-name": 0,
|
||||
"react/jsx-boolean-value": 0,
|
||||
"react/jsx-no-duplicate-props": 2,
|
||||
"react/jsx-no-undef": 1,
|
||||
"react/jsx-sort-props": 0,
|
||||
"react/jsx-uses-react": 1,
|
||||
"react/jsx-uses-vars": 1,
|
||||
"react/no-did-mount-set-state": 1,
|
||||
"react/no-did-update-set-state": 1,
|
||||
"react/no-multi-comp": 0,
|
||||
"react/no-string-refs": 1,
|
||||
"react/no-unknown-property": 0,
|
||||
"react/prop-types": 0,
|
||||
"react/react-in-jsx-scope": 1,
|
||||
"react/self-closing-comp": 1,
|
||||
"react/wrap-multilines": 0
|
||||
}
|
||||
}
|
||||
|
||||
+19
-44
@@ -3,72 +3,47 @@
|
||||
.*/*[.]android.js
|
||||
|
||||
; Ignore templates for 'react-native init'
|
||||
<PROJECT_ROOT>/template/.*
|
||||
.*/local-cli/templates/.*
|
||||
|
||||
; Ignore the Dangerfile
|
||||
<PROJECT_ROOT>/bots/dangerfile.js
|
||||
; Ignore the website subdir
|
||||
<PROJECT_ROOT>/website/.*
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
; Ignore unexpected extra "@providesModule"
|
||||
.*/node_modules/.*/node_modules/fbjs/.*
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
; Ignore duplicate module providers
|
||||
; For RN Apps installed via npm, "Libraries" folder is inside
|
||||
; "node_modules/react-native" but in the source repo it is in the root
|
||||
.*/Libraries/react-native/React.js
|
||||
|
||||
[include]
|
||||
|
||||
[declarations]
|
||||
.*/node_modules/.*
|
||||
|
||||
[libs]
|
||||
interface.js
|
||||
Libraries/react-native/react-native-interface.js
|
||||
flow/
|
||||
|
||||
[options]
|
||||
emoji=true
|
||||
|
||||
exact_by_default=true
|
||||
indexed_access=false
|
||||
|
||||
format.bracket_spacing=false
|
||||
|
||||
module.file_ext=.js
|
||||
module.file_ext=.json
|
||||
module.file_ext=.ios.js
|
||||
module.system=haste
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/index.js'
|
||||
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
|
||||
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
|
||||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
|
||||
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
suppress_type=$FlowFixMeEmpty
|
||||
suppress_type=$FixMe
|
||||
|
||||
[lints]
|
||||
sketchy-null-number=warn
|
||||
sketchy-null-mixed=warn
|
||||
sketchy-number=warn
|
||||
untyped-type-import=warn
|
||||
nonstrict-import=warn
|
||||
deprecated-type=error
|
||||
unsafe-getters-setters=warn
|
||||
unnecessary-invariant=warn
|
||||
signature-verification-failure=warn
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
[strict]
|
||||
deprecated-type
|
||||
nonstrict-import
|
||||
sketchy-null
|
||||
unclear-type
|
||||
unsafe-getters-setters
|
||||
untyped-import
|
||||
untyped-type-import
|
||||
unsafe.enable_getters_and_setters=true
|
||||
|
||||
[version]
|
||||
^0.162.0
|
||||
^0.49.1
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
[ignore]
|
||||
; We fork some components by platform
|
||||
.*/*[.]ios.js
|
||||
|
||||
; Ignore templates for 'react-native init'
|
||||
<PROJECT_ROOT>/template/.*
|
||||
|
||||
; Ignore the Dangerfile
|
||||
<PROJECT_ROOT>/bots/dangerfile.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
|
||||
[include]
|
||||
|
||||
[declarations]
|
||||
.*/node_modules/.*
|
||||
|
||||
[libs]
|
||||
interface.js
|
||||
flow/
|
||||
|
||||
[options]
|
||||
emoji=true
|
||||
|
||||
exact_by_default=true
|
||||
indexed_access=false
|
||||
|
||||
format.bracket_spacing=false
|
||||
|
||||
module.file_ext=.js
|
||||
module.file_ext=.json
|
||||
module.file_ext=.android.js
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/index.js'
|
||||
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
|
||||
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
|
||||
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
suppress_type=$FlowFixMeEmpty
|
||||
|
||||
[lints]
|
||||
sketchy-null-number=warn
|
||||
sketchy-null-mixed=warn
|
||||
sketchy-number=warn
|
||||
untyped-type-import=warn
|
||||
nonstrict-import=warn
|
||||
deprecated-type=error
|
||||
unsafe-getters-setters=warn
|
||||
unnecessary-invariant=warn
|
||||
signature-verification-failure=warn
|
||||
|
||||
[strict]
|
||||
deprecated-type
|
||||
nonstrict-import
|
||||
sketchy-null
|
||||
unclear-type
|
||||
unsafe-getters-setters
|
||||
untyped-import
|
||||
untyped-type-import
|
||||
|
||||
[version]
|
||||
^0.162.0
|
||||
@@ -0,0 +1,6 @@
|
||||
# Force LF line endings for Bash scripts. On Windows the rest of the source
|
||||
# files will typically have CR+LF endings (Git default on Windows), but Bash
|
||||
# scripts need to have LF endings to work (under Cygwin), thus override to force
|
||||
# that.
|
||||
gradlew text eol=lf
|
||||
*.sh text eol=lf
|
||||
+7
-38
@@ -1,40 +1,9 @@
|
||||
# See https://help.github.com/en/articles/about-code-owners
|
||||
# to learn more about code owners.
|
||||
# Order is important; the last matching pattern takes the most
|
||||
# precedence. You may specify either a GitHub username, or an
|
||||
# email address if you prefer, as the code owner.
|
||||
|
||||
# Any Markdown file anywhere in the repository
|
||||
**/*.md @hramos @cpojer
|
||||
|
||||
# GitHub Settings, Bots
|
||||
/.github/ @hramos
|
||||
/bots @hramos
|
||||
|
||||
# Continuous Integration
|
||||
/.circleci/ @hramos
|
||||
/.circleci/Dockerfiles @gengjiawen
|
||||
/.appveyor/ @gengjiawen
|
||||
|
||||
# Internals
|
||||
React/Base/* @shergin
|
||||
React/Views/* @shergin
|
||||
React/Modules/* @shergin
|
||||
React/CxxBridge/* @mhorowitz
|
||||
|
||||
# Components and APIs
|
||||
ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis
|
||||
docs/* @hramos
|
||||
blog/* @hramos
|
||||
Libraries/Animated/* @janicduplessis
|
||||
Libraries/NativeAnimation/* @janicduplessis
|
||||
Libraries/Image/* @shergin
|
||||
Libraries/Text/* @shergin
|
||||
|
||||
# Modifications to package.json typically require
|
||||
# additional effort from a Facebook employee to land
|
||||
/package.json @hramos @cpojer
|
||||
|
||||
# These should not be modified through a GitHub PR
|
||||
LICENSE* @hramos @cpojer @yungsters
|
||||
|
||||
# The eslint-config-react-native-community package requires manual publishing after merging
|
||||
/packages/eslint-config-react-native-community/* @matt-oakes
|
||||
ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis
|
||||
website/* @hramos
|
||||
website/showcase.json @hramos
|
||||
package.json @hramos @ericnakagawa
|
||||
website/package.json @hramos @ericnakagawa
|
||||
|
||||
+123
-3
@@ -1,4 +1,124 @@
|
||||
✋ To keep the backlog clean and actionable, issues will be
|
||||
🚫 closed if they do not follow one of the issue templates:
|
||||
👉 https://github.com/facebook/react-native/issues/new/choose
|
||||
<!--
|
||||
PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION.
|
||||
-->
|
||||
|
||||
### Is this a bug report?
|
||||
|
||||
(write your answer here)
|
||||
|
||||
<!--
|
||||
If you answered "Yes":
|
||||
|
||||
We expect that it will take you about 30 minutes to produce a high-quality bug report.
|
||||
While this may seem like a lot, putting care into issues helps us fix them faster.
|
||||
For bug reports, it is REQUIRED to fill the rest of this template, or the issue will be closed.
|
||||
|
||||
If you answered "No":
|
||||
|
||||
We use GitHub Issues exclusively for tracking bugs in React Native. If you're looking for help,
|
||||
check out the How to Get In Touch section of the following guide:
|
||||
https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#how-to-get-in-touch
|
||||
|
||||
Now scroll below!
|
||||
-->
|
||||
|
||||
|
||||
### Have you read the Bugs section of the Contributing to React Native Guide?
|
||||
|
||||
(Write your answer here.)
|
||||
|
||||
<!--
|
||||
Please read through the bug reporting guidelines thoroughly:
|
||||
https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#bugs
|
||||
-->
|
||||
|
||||
### Environment
|
||||
|
||||
<!--
|
||||
Please fill in all the relevant fields by running these commands in terminal.
|
||||
-->
|
||||
|
||||
1. `react-native -v`:
|
||||
2. `node -v`:
|
||||
3. `npm -v`:
|
||||
4. `yarn --version` (if you use Yarn):
|
||||
|
||||
Then, specify:
|
||||
|
||||
<!-- (What platform are you building for? Choose any from iOS, Android, AppleTV.) -->
|
||||
- Target Platform:
|
||||
|
||||
<!-- Which operating system are you using? Specify macOS, Windows, or Linux, along with specific release versions -->
|
||||
- Development Operating System:
|
||||
|
||||
<!-- Include any additional relevant information. Are you using Xcode or Android Studio to build native code? Is the issue specific to a particular iOS or Android SDK? -->
|
||||
- Build tools:
|
||||
|
||||
### Steps to Reproduce
|
||||
|
||||
<!--
|
||||
How would you describe your issue to someone who doesn’t know you or your project?
|
||||
Try to write a sequence of steps that anybody can repeat to see the issue.
|
||||
Be specific! If the bug cannot be reproduced, your issue may be closed.
|
||||
-->
|
||||
|
||||
(Write your steps here:)
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
<!--
|
||||
How did you expect your project to behave?
|
||||
It’s fine if you’re not sure your understanding is correct.
|
||||
Just write down what you thought would happen.
|
||||
-->
|
||||
|
||||
(Write what you thought would happen.)
|
||||
|
||||
### Actual Behavior
|
||||
|
||||
<!--
|
||||
Did something go wrong?
|
||||
Is something broken, or not behaving as you expected?
|
||||
Describe this section in detail, and attach screenshots if possible.
|
||||
Don't just say "it doesn't work"!
|
||||
-->
|
||||
|
||||
(Write what happened. Add screenshots!)
|
||||
|
||||
### Reproducible Demo
|
||||
|
||||
<!--
|
||||
Please share a project that reproduces the issue.
|
||||
There are two ways to do it:
|
||||
|
||||
* Create a new app using https://snack.expo.io/ and try to reproduce the issue in it.
|
||||
This is useful if you roughly know where the problem is, or can’t share the real code.
|
||||
|
||||
* Or, copy your app and remove things until you’re left with the minimal reproducible demo.
|
||||
This is useful for finding the root cause. You may then optionally create a Snack.
|
||||
|
||||
This is a good guide to creating bug demos: https://stackoverflow.com/help/mcve
|
||||
Once you’re done, copy and paste the link to the Snack or a public GitHub repository below:
|
||||
-->
|
||||
|
||||
(Paste the link to an example project and exact instructions to reproduce the issue.)
|
||||
|
||||
<!--
|
||||
What happens if you skip this step?
|
||||
|
||||
Someone will read your bug report, and maybe will be able to help you,
|
||||
but it’s unlikely that it will get much attention from the team. Eventually,
|
||||
the issue will likely get closed in favor of issues that have reproducible demos.
|
||||
|
||||
Please remember that:
|
||||
|
||||
* Issues without reproducible demos have a very low priority.
|
||||
* The person fixing the bug would have to do that anyway. Please be respectful of their time.
|
||||
* You might figure out the issues yourself as you work on extracting it.
|
||||
|
||||
Thanks for helping us help you!
|
||||
-->
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: "🐛 Bug Report"
|
||||
about: Report a reproducible bug or regression in React Native.
|
||||
title: ''
|
||||
labels: 'Needs: Triage :mag:'
|
||||
|
||||
---
|
||||
|
||||
Please provide all the information requested. Issues that do not follow this format are likely to stall.
|
||||
|
||||
## Description
|
||||
Please provide a clear and concise description of what the bug is. Include screenshots if needed.
|
||||
Please test using the latest React Native release to make sure your issue has not already been fixed: https://reactnative.dev/docs/upgrading.html
|
||||
|
||||
## React Native version:
|
||||
Run `react-native info` in your terminal and copy the results here.
|
||||
|
||||
## Steps To Reproduce
|
||||
Provide a detailed list of steps that reproduce the issue.
|
||||
|
||||
1.
|
||||
2.
|
||||
|
||||
## Expected Results
|
||||
Describe what you expected to happen.
|
||||
|
||||
## Snack, code example, screenshot, or link to a repository:
|
||||
Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.
|
||||
You may provide a screenshot of the application if you think it is relevant to your bug report.
|
||||
Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
|
||||
@@ -1,14 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 📃 Documentation Issue
|
||||
url: https://github.com/facebook/react-native-website/issues
|
||||
about: Please report documentation issues in the React Native website repository.
|
||||
- name: ⤴️ Upgrade Issue
|
||||
url: https://github.com/react-native-community/upgrade-support
|
||||
about: Need help upgrading to a newer React Native version? Visit the Upgrade Support repository.
|
||||
- name: 🤔 Questions and Help
|
||||
url: https://reactnative.dev/help
|
||||
about: Looking for help with your app? Please refer to the React Native community's support resources.
|
||||
- name: 🚀 Discussions and Proposals
|
||||
url: https://github.com/react-native-community/discussions-and-proposals
|
||||
about: Discuss the future of React Native in the React Native community's discussions and proposals repository.
|
||||
@@ -1,38 +0,0 @@
|
||||
name: Release Candidate Blocker
|
||||
description: File an issue against the current release candidate.
|
||||
labels: ["Needs: Triage :mag:", "pre-release"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please use this form to file an issue against the current release candidate. See current releases [here](https://github.com/facebook/react-native/releases).
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: What release candidate version does this appear on? Please refer to [release candidate versions](https://github.com/facebook/react-native/releases).
|
||||
placeholder: ex. 0.66.0-rc.2
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: target
|
||||
attributes:
|
||||
label: Build Target(s)
|
||||
description: What target(s) are encountering this issue?
|
||||
placeholder: iOS simulator in release flavor
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: Developer Environment
|
||||
description: Please list relevant versions of system, tooling. Ex. OS, processor, Xcode, etc.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Issue and Reproduction Steps
|
||||
description: Please describe the issue and list out commands run to reproduce.
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,17 +1,9 @@
|
||||
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. -->
|
||||
<!--
|
||||
Thank you for sending the PR!
|
||||
|
||||
## Summary
|
||||
If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!
|
||||
|
||||
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
|
||||
Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.
|
||||
|
||||
## Changelog
|
||||
|
||||
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
|
||||
https://github.com/facebook/react-native/wiki/Changelog
|
||||
Happy contributing!
|
||||
-->
|
||||
|
||||
[CATEGORY] [TYPE] - Message
|
||||
|
||||
## Test Plan
|
||||
|
||||
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
Thanks for using React Native! If you need help with your React Native app, the right place to go depends on the type of help that you need.
|
||||
|
||||
|
||||
## 🤔 I have a question or need help with my React Native app.
|
||||
|
||||
If you have a coding question related to React Native, it might be better suited for Stack Overflow. It's a great place to browse through [frequent questions about using React Native](https://stackoverflow.com/questions/tagged/react-native?sort=frequent&pageSize=15), as well as [ask for help with specific questions](https://stackoverflow.com/questions/tagged/react-native).
|
||||
|
||||
[Reactiflux](https://www.reactiflux.com/) is an active community of React and React Native developers. If you are looking for immediate assistance or have a general question about React Native, the #react-native channel is a good place to start.
|
||||
|
||||
|
||||
## 📃 I found something that seems wrong in the documentation.
|
||||
|
||||
The React Native website is hosted on a [separate repository](https://github.com/facebook/react-native-website). If you want to report something that is wrong or missing from the documentation, [please open a new issue there](https://github.com/facebook/react-native-website/issues).
|
||||
|
||||
|
||||
## 🐛 I found a bug in React Native.
|
||||
|
||||
If you want to report a reproducible bug or regression in the React Native library, you can [create a new issue](https://github.com/facebook/react-native/issues/new?labels=Type%3A+Bug+Report&template=bug_report.md). It's a good idea to look through [open issues](https://github.com/facebook/react-native/issues) before doing so, as someone else may have reported a similar issue.
|
||||
|
||||
|
||||
## 🚀 I want to discuss the future of React Native.
|
||||
|
||||
If you'd like to discuss topics related to the future of React Native, please check out the [React Native Community Discussions and Proposals](https://github.com/react-native-community/discussions-and-proposals) repository.
|
||||
|
||||
|
||||
## 💬 I want to talk to other React Native developers.
|
||||
|
||||
If you want to participate in casual discussions about the use of React Native, consider participating in one of the following forums:
|
||||
|
||||
- [Reactiflux Discord Server](https://www.reactiflux.com)
|
||||
- [Spectrum Chat](https://spectrum.chat/react-native)
|
||||
- [React Native Community Facebook Group](https://www.facebook.com/groups/react.native.community)
|
||||
|
||||
|
||||
> For a full list of community resources, check out [React Native's Community page](https://reactnative.dev/help).
|
||||
@@ -1,56 +0,0 @@
|
||||
# Configuration for Respond To Issue Based on Label https://github.com/marketplace/actions/respond-to-issue-based-on-label
|
||||
|
||||
"Type: Invalid":
|
||||
close: true
|
||||
"Type: Question":
|
||||
comment: >
|
||||
We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on [Stack Overflow](http://stackoverflow.com/questions/tagged/react-native), or on [Reactiflux](https://www.reactiflux.com/).
|
||||
close: true
|
||||
"Type: Docs":
|
||||
comment: >
|
||||
Please report documentation issues in the [`react-native-website`](https://github.com/facebook/react-native-website/issues) repository.
|
||||
close: true
|
||||
"Type: Upgrade Issue":
|
||||
comment: >
|
||||
Do you need help upgrading to a newer React Native version? Visit the [Upgrade Support repository](https://github.com/react-native-community/upgrade-support) or use the [upgrade helper](https://react-native-community.github.io/upgrade-helper/) to see the changes that need to be made to upgrade your app.
|
||||
close: true
|
||||
"Resolution: For Stack Overflow":
|
||||
comment: >
|
||||
We are using GitHub issues exclusively to track bugs in the core React Native library. Please try asking over on [Stack Overflow](http://stackoverflow.com/questions/tagged/react-native) as it is better suited for this type of question.
|
||||
close: true
|
||||
"Needs: Issue Template":
|
||||
comment: >
|
||||
<table><tbody><tr><th width="50">:warning:</th><th width="100%">
|
||||
Missing Required Fields
|
||||
</th></tr><tr><td>:information_source:</td><td>
|
||||
It looks like your issue may be missing some necessary information. GitHub provides an example template whenever a <a href="https://github.com/facebook/react-native/issues/new?template=bug_report.md">new issue is created</a>. Could you go back and make sure to fill out the template? You may edit this issue, or close it and open a new one.
|
||||
</td></tr></tbody></table>
|
||||
labels:
|
||||
- "Needs: Author Feedback"
|
||||
"Needs: Environment Info":
|
||||
comment: >
|
||||
<table><tbody><tr><th width="50">:warning:</th><th width="100%">
|
||||
Missing Environment Information
|
||||
</th></tr><tr><td>:information_source:</td><td>
|
||||
Your issue may be missing information about your development environment. You can obtain the missing information by running <code>react-native info</code> in a console.
|
||||
</td></tr></tbody></table>
|
||||
labels:
|
||||
- "Needs: Author Feedback"
|
||||
"Needs: Verify on Latest Version":
|
||||
comment: >
|
||||
<table><tbody><tr><th width="50">:warning:</th><th width="100%">
|
||||
Using Old Version
|
||||
</th></tr><tr><td>:information_source:</td><td>
|
||||
It looks like you are using an older version of React Native. Please <a href="https://reactnative.dev/docs/upgrading">upgrade</a> to the latest version, and verify if the issue persists. If it does not, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the current release.
|
||||
</td></tr></tbody></table>
|
||||
labels:
|
||||
- "Needs: Author Feedback"
|
||||
"Needs: Repro":
|
||||
comment: >
|
||||
<table><tbody><tr><th width="50">:warning:</th><th width="100%">
|
||||
Missing Reproducible Example
|
||||
</th></tr><tr><td>:information_source:</td><td>
|
||||
It looks like your issue is missing a reproducible example. Please provide a <a href="https://snack.expo.io">Snack</a> or a repository that demonstrates the issue you are reporting in a <a href="https://stackoverflow.com/help/minimal-reproducible-example">minimal, complete, and reproducible</a> manner.
|
||||
</td></tr></tbody></table>
|
||||
labels:
|
||||
- "Needs: Author Feedback"
|
||||
@@ -1,26 +0,0 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 90
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- Good first issue
|
||||
- "Type: Discussion"
|
||||
- Partner
|
||||
- Core Team
|
||||
- "Help Wanted :octocat:"
|
||||
- "Impact: Regression"
|
||||
- "Resolution: PR Submitted"
|
||||
- "Resolution: Backlog"
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: Stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs.
|
||||
You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open.
|
||||
Thank you for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: >
|
||||
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
|
||||
only: issues
|
||||
@@ -1,21 +0,0 @@
|
||||
name: Issue Needs Attention
|
||||
# This workflow is triggered on issue comments.
|
||||
on:
|
||||
issue_comment:
|
||||
types: created
|
||||
|
||||
jobs:
|
||||
applyNeedsAttentionLabel:
|
||||
name: Apply Needs Attention Label
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Apply Needs Attention Label
|
||||
uses: hramos/needs-attention@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
response-required-label: "Needs: Author Feedback"
|
||||
needs-attention-label: "Needs: Attention"
|
||||
id: needs-attention
|
||||
- name: Result
|
||||
run: echo '${{ steps.needs-attention.outputs.result }}'
|
||||
@@ -1,16 +0,0 @@
|
||||
name: On Issue Labeled
|
||||
# This workflow is triggered when a label is added to an issue.
|
||||
on:
|
||||
issues:
|
||||
types: labeled
|
||||
|
||||
jobs:
|
||||
respondToIssueBasedOnLabel:
|
||||
name: Respond to Issue Based on Label
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Respond to Issue Based on Label
|
||||
uses: hramos/respond-to-issue-based-on-label@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,19 +0,0 @@
|
||||
name: Mark stale issues and pull requests
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: 365
|
||||
stale-issue-message: 'This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||
stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.'
|
||||
close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.'
|
||||
@@ -1,19 +0,0 @@
|
||||
name: Test Docker Android Image
|
||||
# This workflow is triggered on commits to main and pull requests.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [ synchronize ]
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test-docker-android:
|
||||
name: Test Docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build Docker image with Android test app
|
||||
run: npm run docker-build-android
|
||||
+8
-63
@@ -23,35 +23,19 @@ project.xcworkspace
|
||||
|
||||
# Gradle
|
||||
/build/
|
||||
/packages/react-native-gradle-plugin/build/
|
||||
/packages/rn-tester/android/app/.cxx/
|
||||
/packages/rn-tester/android/app/build/
|
||||
/packages/rn-tester/android/app/gradle/
|
||||
/packages/rn-tester/android/app/gradlew
|
||||
/packages/rn-tester/android/app/gradlew.bat
|
||||
/RNTester/android/app/build/
|
||||
/RNTester/android/app/gradle/
|
||||
/RNTester/android/app/gradlew
|
||||
/RNTester/android/app/gradlew.bat
|
||||
/ReactAndroid/build/
|
||||
/ReactAndroid/gradle/
|
||||
/ReactAndroid/gradlew
|
||||
/ReactAndroid/gradlew.bat
|
||||
/template/android/app/build/
|
||||
/template/android/build/
|
||||
|
||||
# Buck
|
||||
.buckd
|
||||
buck-out
|
||||
/.lsp.buckd
|
||||
/.lsp-buck-out
|
||||
/ReactAndroid/src/main/jni/prebuilt/lib/
|
||||
/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/
|
||||
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
|
||||
/ReactAndroid/src/main/gen
|
||||
|
||||
# Android Studio
|
||||
.project
|
||||
.settings
|
||||
.classpath
|
||||
|
||||
# Watchman
|
||||
.watchmanconfig
|
||||
|
||||
# Android
|
||||
.idea
|
||||
.gradle
|
||||
@@ -63,8 +47,6 @@ local.properties
|
||||
node_modules
|
||||
*.log
|
||||
.nvm
|
||||
/bots/node_modules/
|
||||
package-lock.json
|
||||
|
||||
# OS X
|
||||
.DS_Store
|
||||
@@ -76,42 +58,5 @@ package-lock.json
|
||||
/coverage
|
||||
/third-party
|
||||
|
||||
# Root dir shouldn't have Xcode project
|
||||
/*.xcodeproj
|
||||
|
||||
# ReactCommon subdir shouldn't have Xcode project
|
||||
/ReactCommon/**/*.xcodeproj
|
||||
/packages/rn-tester/build
|
||||
/packages/rn-tester/android/app/build/*
|
||||
|
||||
# Libs that shouldn't have Xcode project
|
||||
/Libraries/FBLazyVector/**/*.xcodeproj
|
||||
/Libraries/RCTRequired/**/*.xcodeproj
|
||||
/React/CoreModules/**/*.xcodeproj
|
||||
/React/FBReactNativeSpec/**/*.xcodeproj
|
||||
/packages/react-native-codegen/**/*.xcodeproj
|
||||
|
||||
# Ruby Gems (Bundler)
|
||||
/vendor
|
||||
/template/vendor
|
||||
|
||||
# CocoaPods
|
||||
/template/ios/Pods/
|
||||
/template/ios/Podfile.lock
|
||||
/packages/rn-tester/Gemfile.lock
|
||||
|
||||
# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here.
|
||||
/packages/rn-tester/Pods/*
|
||||
!/packages/rn-tester/Pods/__offline_mirrors__
|
||||
|
||||
# react-native-codegen
|
||||
/packages/react-native-codegen/lib
|
||||
/ReactCommon/react/renderer/components/rncore/
|
||||
/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec*
|
||||
|
||||
# Visual studio
|
||||
.vscode
|
||||
.vs
|
||||
|
||||
# Android memory profiler files
|
||||
*.hprof
|
||||
/website/src
|
||||
/website/build
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# rnpm
|
||||
/local-cli/rnpm
|
||||
/local-cli/server/middleware/heapCapture/bundle.js
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"requirePragma": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": false,
|
||||
"jsxBracketSameLine": true,
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
2.7.4
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
language: objective-c
|
||||
|
||||
osx_image: xcode8.3
|
||||
|
||||
install:
|
||||
- nvm install 7
|
||||
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
|
||||
- brew install yarn --ignore-dependencies
|
||||
- yarn install
|
||||
|
||||
script:
|
||||
- if [[ "$TEST_TYPE" = objc-ios ]]; then travis_retry travis_wait 30 ./scripts/objc-test-ios.sh test; fi
|
||||
- if [[ "$TEST_TYPE" = objc-tvos ]]; then travis_retry travis_wait 30 ./scripts/objc-test-tvos.sh; fi
|
||||
- if [[ "$TEST_TYPE" = e2e-objc ]]; then node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; fi
|
||||
- if [[ ( "$TEST_TYPE" = podspecs ) && ( "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then gem install cocoapods && travis_wait 30 ./scripts/process-podspecs.sh; fi
|
||||
|
||||
cache:
|
||||
- cocoapods
|
||||
- yarn
|
||||
|
||||
matrix:
|
||||
- fast_finish: true # Fail the whole build as soon as one test type fails. Should help with Travis capacity issues (very long queues).
|
||||
|
||||
# The order of these tests says which are more likely to run first and fail the whole build fast.
|
||||
env:
|
||||
- TEST_TYPE=objc-ios
|
||||
- TEST_TYPE=podspecs
|
||||
- TEST_TYPE=e2e-objc
|
||||
- TEST_TYPE=objc-tvos
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^.*-stable$/
|
||||
|
||||
notifications:
|
||||
email:
|
||||
recipients:
|
||||
- douglowder@mac.com # Doug Lowder built and maintains Apple TV specific code and wants to be notified about tvOS failures.
|
||||
- eloy@artsy.net # Eloy Durán maintains the podspecs test and wants to be notified about failures.
|
||||
on_failure: change
|
||||
on_success: change
|
||||
slack:
|
||||
secure: oQL2C966v7/DtxNqfM7WowjY0R5mgLHR2qHkoucwK5iVrmaptnHr8fq01xlj7VT0kDwNLqT3n4+gtCviGw89lq71m3W76c8Pms/10jpjw+LwAfQPVizNw/Bx8MFNNmjDauK/auFxaybiLZupi7zd4xFGOZvScmFdfD4CAAp2OOA=
|
||||
on_pull_requests: false
|
||||
on_failure: change
|
||||
on_success: change
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible Node.js debug attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceRoot}/Libraries/react-native/react-native-implementation.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
# Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to make participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all project spaces, and it also applies when
|
||||
an individual is representing the project or its community in public spaces.
|
||||
Examples of representing a project or community include using an official
|
||||
project e-mail address, posting via an official social media account, or acting
|
||||
as an appointed representative at an online or offline event. Representation of
|
||||
a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at <opensource-conduct@fb.com>. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
|
||||
available at https://www.contributor-covenant.org/version/2/1/code_of_conduct/
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
|
||||
+149
-65
@@ -1,112 +1,196 @@
|
||||
# Contributing to React Native
|
||||
|
||||
Thank you for your interest in contributing to React Native! From commenting on and triaging issues, to reviewing and sending Pull Requests, all contributions are welcome. We aim to build a vibrant and inclusive [ecosystem of partners, core contributors, and community](ECOSYSTEM.md) that goes beyond the main React Native GitHub repository.
|
||||
React Native is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody on https://facebook.com. We're still working out the kinks to make contributing to this project as easy and transparent as possible, but we're not quite there yet. Hopefully this document makes the process for contributing clear and preempts some questions you may have.
|
||||
|
||||
The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies who want to learn how to run and contribute to an open source project. Contributors and people new to open source alike will find the following guides especially useful:
|
||||
## Code of Conduct
|
||||
|
||||
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
* [Building Welcoming Communities](https://opensource.guide/building-community/)
|
||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
|
||||
|
||||
## Our Development Process
|
||||
|
||||
### [Code of Conduct](https://github.com/facebook/react-native/blob/HEAD/CODE_OF_CONDUCT.md)
|
||||
Some of the core team will be working directly on [GitHub](https://github.com/facebook/react-native). These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.
|
||||
|
||||
As a reminder, all contributors are expected to adhere to the [Code of Conduct](https://github.com/facebook/react-native/blob/HEAD/CODE_OF_CONDUCT.md).
|
||||
## Branch Organization
|
||||
|
||||
## Ways to Contribute
|
||||
We will do our best to keep `master` in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to [communicate these changes](https://github.com/facebook/react-native/releases) and version appropriately so you can lock into a specific version if need be.
|
||||
|
||||
If you are eager to start contributing code right away, we have a list of [good first issues](https://github.com/facebook/react-native/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. As you gain more experience and demonstrate a commitment to evolving React Native, you may be granted issue management permissions in the repository.
|
||||
To see what changes are coming and provide better feedback to React Native contributors, use the [latest release candidate](http://facebook.github.io/react-native/versions.html) when possible. By the time a release candidate is released, the changes it contains will have been shipped in production Facebook apps for over two weeks.
|
||||
|
||||
There are other ways you can contribute without writing a single line of code. Here are a few things you can do to help out:
|
||||
## Bugs
|
||||
|
||||
1. **Replying and handling open issues.** We get a lot of issues every day, and some of them may lack necessary information. You can help out by guiding people through the process of filling out the issue template, asking for clarifying information, or pointing them to existing issues that match their description of the problem. We cover more about this process in the [Issue Triage wiki](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues).
|
||||
2. **Reviewing pull requests for the docs.** Reviewing [documentation updates](https://github.com/facebook/react-native-website/pulls) can be as simple as checking for spelling and grammar. If you encounter situations that can be explained better in the docs, click **Edit** at the top of most docs pages to get started with your own contribution.
|
||||
3. **Help people write test plans.** Some pull requests sent to the main repository may lack a proper test plan. These help reviewers understand how the change was tested, and can speed up the time it takes for a contribution to be accepted.
|
||||
#### Where to Find Known Issues
|
||||
|
||||
Each of these tasks is highly impactful, and maintainers will greatly appreciate your help.
|
||||
We are using [GitHub Issues](https://github.com/facebook/react-native/issues) for our public bugs. Before filing a new task, try to make sure your problem doesn't already exist.
|
||||
|
||||
### Our Development Process
|
||||
Questions and feature requests are tracked elsewhere:
|
||||
|
||||
We use GitHub issues and pull requests to keep track of bug reports and contributions from the community. All changes from engineers at Facebook will sync to [GitHub](https://github.com/facebook/react-native) through a bridge with Facebook's internal source control. Changes from the community are handled through GitHub pull requests. Once a change made on GitHub is approved, it will first be imported into Facebook's internal source control and tested against Facebook's codebase. Once merged at Facebook, the change will eventually sync back to GitHub as a single commit once it has passed Facebook's internal tests.
|
||||
- Have a question? [Ask on Stack Overflow](http://stackoverflow.com/questions/tagged/react-native).
|
||||
- If you have a question regarding future plans, check out the [roadmap](https://github.com/facebook/react-native/wiki/Roadmap).
|
||||
- Have a feature request that is not covered in the roadmap? [Add it here](https://react-native.canny.io/feature-requests).
|
||||
|
||||
You can learn more about the contribution process in the following documents:
|
||||
#### Reporting New Issues
|
||||
|
||||
* [Issues](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues)
|
||||
* [Pull Requests](https://github.com/facebook/react-native/wiki/Managing-Pull-Requests)
|
||||
The best way to get your bug fixed is to provide a reduced test case. Please provide either a [Sketch](https://sketch.expo.io/) or a public repository with a runnable example.
|
||||
|
||||
We also have a thriving community of contributors who would be happy to help you get set up. You can reach out to us through [@ReactNative](http://twitter.com/reactnative) (the React Native team) and [@ReactNativeComm](http://twitter.com/reactnativecomm) (the React Native Community organization).
|
||||
Please report a single bug per issue. Always provide reproduction steps. You can use Snack in many cases to demonstrate an issue: https://snack.expo.io/. If the bug cannot be reproduced using Snack, verify that the issue can be reproduced locally by targeting the latest release candidate. Ideally, check if the issue is present in master as well.
|
||||
|
||||
### Repositories
|
||||
Do not forget to include sample code that reproduces the issue. Only open issues for bugs affecting either the latest stable release, or the current release candidate, or master (see http://facebook.github.io/react-native/versions.html). If it is not clear from your report that the issue can be reproduced in one of these releases, your issue will be closed.
|
||||
|
||||
The main repository, <https://github.com/facebook/react-native>, contains the React Native framework itself and it is here where we keep track of bug reports and manage pull requests.
|
||||
We're not able to provide support through GitHub Issues. If you're looking for help with your code, consider asking on Stack Overflow: http://stackoverflow.com/questions/tagged/react-native
|
||||
|
||||
There are a few other repositories you might want to familiarize yourself with:
|
||||
#### Security Bugs
|
||||
|
||||
* **React Native website** which contains the source code for the website, including the documentation, located at <https://github.com/facebook/react-native-website>
|
||||
* **Releases** are coordinated through the <https://github.com/react-native-community/releases> repository. This includes important documents such as the Changelog.
|
||||
* **Discussions** about the future of React Native take place in the <https://github.com/react-native-community/discussions-and-proposals> repository.
|
||||
* **High-quality plugins** for React Native can be found throughout the [React Native Community GitHub Organization](http://github.com/react-native-community/).
|
||||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.
|
||||
|
||||
Browsing through these repositories should provide some insight into how the React Native open source project is managed.
|
||||
## How to Get in Touch
|
||||
|
||||
## GitHub Issues
|
||||
Many React Native users are active on [Stack Overflow](http://stackoverflow.com/questions/tagged/react-native).
|
||||
|
||||
We use GitHub issues to track bugs exclusively. We have documented our issue handling processes in the [Issues wiki](https://github.com/facebook/react-native/wiki/Triaging-GitHub-Issues).
|
||||
If you want to get a general sense of what React Native folks talk about, check out the [React Native Community](https://www.facebook.com/groups/react.native.community) Facebook group.
|
||||
|
||||
### Security Bugs
|
||||
There is also [an active community of React and React Native users on the Discord chat platform](https://discord.gg/0ZcbPKXt5bZjGY5n) in case you need help.
|
||||
|
||||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
|
||||
The React Native team sends out periodical updates through the following channels:
|
||||
|
||||
## Helping with Documentation
|
||||
* [Blog](https://facebook.github.io/react-native/blog/)
|
||||
* [Twitter](https://www.twitter.com/reactnative)
|
||||
|
||||
The React Native documentation is hosted as part of the React Native website repository at https://github.com/facebook/react-native-website. The website itself is located at <https://reactnative.dev/> and it is built using [Docusaurus](https://docusaurus.io/). If there's anything you'd like to change in the docs, you can get started by clicking on the "Edit" button located on the upper right of most pages in the website.
|
||||
Core contributors to React Native meet monthly and post their meeting notes on the React Native blog. You can also find ad hoc discussions in the [React Native Core Contributors](https://www.facebook.com/groups/reactnativeoss/) Facebook group.
|
||||
|
||||
If you are adding new functionality or introducing a change in behavior, we will ask you to update the documentation to reflect your changes.
|
||||
## Proposing a Change
|
||||
|
||||
### Contributing to the Blog
|
||||
If you intend to change the public API, or make any non-trivial changes to the implementation, we recommend [filing an issue](https://github.com/facebook/react-native/issues/new). This lets us reach an agreement on your proposal before you put significant effort into it.
|
||||
|
||||
The React Native blog is generated [from the Markdown sources for the blog](https://github.com/facebook/react-native-website/tree/HEAD/website/blog).
|
||||
If you're only fixing a bug, it's fine to submit a pull request right away but we still recommend to file an issue detailing what you're fixing. This is helpful in case we don't accept that specific fix but want to keep track of the issue.
|
||||
|
||||
Please open an issue in the https://github.com/facebook/react-native-website repository or tag us on [@ReactNative on Twitter](http://twitter.com/reactnative) and get the go-ahead from a maintainer before writing an article intended for the React Native blog. In most cases, you might want to share your article on your own blog or writing medium instead. It's worth asking, though, in case we find your article is a good fit for the blog.
|
||||
## Pull Requests
|
||||
|
||||
We recommend referring to the [CONTRIBUTING](https://github.com/facebook/react-native-website/blob/HEAD/CONTRIBUTING.md) document for the `react-native-website` repository to learn more about contributing to the website in general.
|
||||
If you send a pull request, please do it against the master branch. We maintain stable branches for stable releases separately but we don't accept pull requests to them directly. Instead, we cherry-pick non-breaking changes from master to the latest stable version.
|
||||
|
||||
## Contributing Code
|
||||
The core team will be monitoring for pull requests. When we get one, we'll run some Facebook-specific integration tests on it first. From here, we'll need to get another person to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
|
||||
|
||||
Code-level contributions to React Native generally come in the form of [pull requests](https://help.github.com/en/articles/about-pull-requests). These are done by forking the repo and making changes locally. Directly in the repo, there is the [`rn-tester` app](/packages/rn-tester) that you can install on your device (or simulators) and use to test the changes you're making to React Native sources.
|
||||
Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
|
||||
|
||||
The process of proposing a change to React Native can be summarized as follows:
|
||||
*Before* submitting a pull request, please make sure the following is done…
|
||||
|
||||
1. Fork the React Native repository and create your branch from `main`.
|
||||
2. Make the desired changes to React Native sources. Use the `packages/rn-tester` app to test them out.
|
||||
3. If you've added code that should be tested, add tests.
|
||||
4. If you've changed APIs, update the documentation, which lives in [another repo](https://github.com/facebook/react-native-website/).
|
||||
5. Ensure the test suite passes, either locally or on CI once you opened a pull request.
|
||||
6. Make sure your code lints (for example via `yarn lint --fix`).
|
||||
7. Push the changes to your fork.
|
||||
8. Create a pull request to the React Native repository.
|
||||
9. Review and address comments on your pull request.
|
||||
1. A bot may comment with suggestions. Generally we ask you to resolve these first before a maintainer will review your code.
|
||||
2. If changes are requested and addressed, please [request review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) to notify reviewers to take another look.
|
||||
10. If you haven't already, please complete the [Contributor License Agreement](https://github.com/facebook/react-native/wiki/Contributor-License-Agreement) ("CLA"). **[Complete your CLA here.](https://code.facebook.com/cla)**
|
||||
1. Fork the repo and create your branch from `master`.
|
||||
2. Add the copyright notice to the top of any new files you've added.
|
||||
3. Describe your **test plan** in your commit.
|
||||
4. Ensure **tests pass** on Travis and Circle CI.
|
||||
5. Make sure your code lints (`node linter.js <files touched>`).
|
||||
6. If you haven't already, sign the CLA: https://code.facebook.com/cla
|
||||
7. Squash your commits (`git rebase -i`).
|
||||
One intent alongside one commit makes it clearer for people to review and easier to understand your intention.
|
||||
|
||||
If all goes well, your pull request will be merged. If it is not merged, maintainers will do their best to explain the reason why.
|
||||
> **Note:** It is not necessary to keep clicking `Merge master to your branch` on the PR page. You would want to merge master if there are conflicts or tests are failing. The Facebook-GitHub-Bot ultimately squashes all commits to a single one before merging your PR.
|
||||
|
||||
### Step-by-step Guide
|
||||
#### Test plan
|
||||
|
||||
Whenever you are ready to contribute code, check out our [step-by-step guide to sending your first pull request](https://github.com/facebook/react-native/wiki/How-to-Open-a-Pull-Request), or read the [How to Contribute Code](https://github.com/facebook/react-native/wiki/How-to-Contribute-Code) wiki for more details.
|
||||
A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website.
|
||||
|
||||
### Tests
|
||||
- If you've added code that should be tested, add tests!
|
||||
- If you've changed APIs, update the documentation.
|
||||
- If you've updated the docs, verify the website locally and submit screenshots if applicable (see `website/README.md`)
|
||||
|
||||
Tests help us prevent regressions from being introduced to the codebase. The GitHub repository is continuously tested using Circle and Appveyor, the results of which are available through the Checks functionality on [commits](https://github.com/facebook/react-native/commits/HEAD) and pull requests. You can learn more about running and writing tests in the [Tests wiki](http://github.com/facebook/react-native/wiki/Tests).
|
||||
See "What is a Test Plan?" to learn more:
|
||||
https://medium.com/@martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
|
||||
|
||||
## Community Contributions
|
||||
#### Continuous integration tests
|
||||
|
||||
Contributions to React Native are not limited to GitHub. You can help others by sharing your experience using React Native, whether that is through blog posts, presenting talks at conferences, or simply sharing your thoughts on Twitter and tagging @ReactNative.
|
||||
Make sure all **tests pass** on both [Travis][travis] and [Circle CI][circle]. PRs that break tests are unlikely to be merged.
|
||||
|
||||
## Where to Get Help
|
||||
You can learn more about running tests and contributing to React Native here: https://facebook.github.io/react-native/docs/testing.html
|
||||
|
||||
As you work on React Native, it is natural that sooner or later you may require help. In addition to the resources listed in [SUPPORT](.github/SUPPORT.md), people interested in contributing may take advantage of the following:
|
||||
[travis]: https://travis-ci.org/facebook/react-native
|
||||
[circle]: http://circleci.com/gh/facebook/react-native
|
||||
|
||||
* **Twitter**. The React Native team at Facebook has its own account at [@reactnative](https://twitter.com/reactnative), and the React Native Community uses [@reactnativecomm](https://twitter.com/reactnativecomm). If you feel stuck, or need help contributing, please do not hesitate to reach out.
|
||||
* **Proposals Repository**. If you are considering working on a feature large in scope, consider [creating a proposal first](https://github.com/react-native-community/discussions-and-proposals). The community can help you figure out the right approach, and we'd be happy to help.
|
||||
* **React Native Community Discord**. While we try to hold most discussions in public, sometimes it can be beneficial to have conversations in real time with other contributors. People who have demonstrated a commitment to moving React Native forward through sustained contributions to the project may eventually be invited to join the React Native Community Discord.
|
||||
#### Breaking changes
|
||||
|
||||
When adding a new breaking change, follow this template in your pull request:
|
||||
|
||||
```
|
||||
### New breaking change here
|
||||
|
||||
- **Who does this affect**:
|
||||
- **How to migrate**:
|
||||
- **Why make this breaking change**:
|
||||
- **Severity (number of people affected x effort)**:
|
||||
```
|
||||
|
||||
If your pull request is merged, a core contributor will update the [list of breaking changes](https://github.com/facebook/react-native/wiki/Breaking-Changes) which is then used to populate the release notes.
|
||||
|
||||
#### Copyright Notice for files
|
||||
|
||||
Copy and paste this to the top of your new file(s):
|
||||
|
||||
```JS
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
```
|
||||
|
||||
If you've added a new module, add a `@providesModule <moduleName>` at the end of the comment. This will allow the haste package manager to find it.
|
||||
|
||||
### Contributor License Agreement (CLA)
|
||||
|
||||
In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
|
||||
|
||||
Complete your CLA here: https://code.facebook.com/cla
|
||||
|
||||
## Style Guide
|
||||
|
||||
Our linter will catch most styling issues that may exist in your code. You can check the status of your code styling by simply running `node linter.js <files touched>`.
|
||||
|
||||
However, there are still some styles that the linter cannot pick up.
|
||||
|
||||
### Code Conventions
|
||||
|
||||
#### General
|
||||
|
||||
* **Most important: Look around.** Match the style you see used in the rest of the project. This includes formatting, naming things in code, naming things in documentation.
|
||||
* Add trailing commas,
|
||||
* 2 spaces for indentation (no tabs)
|
||||
* "Attractive"
|
||||
|
||||
#### JavaScript
|
||||
|
||||
* Use semicolons;
|
||||
* `'use strict';`
|
||||
* Prefer `'` over `"`
|
||||
* Do not use the optional parameters of `setTimeout` and `setInterval`
|
||||
* 80 character line length
|
||||
|
||||
#### JSX
|
||||
|
||||
* Prefer `"` over `'` for string literal props
|
||||
* When wrapping opening tags over multiple lines, place one prop per line
|
||||
* `{}` of props should hug their values (no spaces)
|
||||
* Place the closing `>` of opening tags on the same line as the last prop
|
||||
* Place the closing `/>` of self-closing tags on their own line and left-align them with the opening `<`
|
||||
|
||||
#### Objective-C
|
||||
|
||||
* Space after `@property` declarations
|
||||
* Brackets on *every* `if`, on the *same* line
|
||||
* `- method`, `@interface`, and `@implementation` brackets on the following line
|
||||
* *Try* to keep it around 80 characters line length (sometimes it's just not possible...)
|
||||
* `*` operator goes with the variable name (e.g. `NSObject *variableName;`)
|
||||
|
||||
#### Java
|
||||
|
||||
* If a method call spans multiple lines closing bracket is on the same line as the last argument.
|
||||
* If a method header doesn't fit on one line each argument goes on a separate line.
|
||||
* 100 character line length
|
||||
|
||||
### Documentation
|
||||
|
||||
* Do not wrap lines at 80 characters - configure your editor to soft-wrap when editing documentation.
|
||||
|
||||
## License
|
||||
|
||||
By contributing to React Native, you agree that your contributions will be licensed under its BSD license.
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
FROM containership/android-base:latest
|
||||
|
||||
# set default environment variables
|
||||
ENV GRADLE_OPTS="-Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
|
||||
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
|
||||
|
||||
# add ReactAndroid directory
|
||||
ADD .buckconfig /app/.buckconfig
|
||||
ADD .buckjavaargs /app/.buckjavaargs
|
||||
ADD ReactAndroid /app/ReactAndroid
|
||||
ADD ReactCommon /app/ReactCommon
|
||||
ADD keystores /app/keystores
|
||||
|
||||
# set workdir
|
||||
WORKDIR /app
|
||||
|
||||
# run buck fetches
|
||||
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/...
|
||||
|
||||
# build app
|
||||
RUN buck build ReactAndroid/src/main/java/com/facebook/react
|
||||
RUN buck build ReactAndroid/src/main/java/com/facebook/react/shell
|
||||
|
||||
ADD gradle /app/gradle
|
||||
ADD gradlew /app/gradlew
|
||||
ADD settings.gradle /app/settings.gradle
|
||||
ADD build.gradle /app/build.gradle
|
||||
ADD react.gradle /app/react.gradle
|
||||
|
||||
# run gradle downloads
|
||||
RUN ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
|
||||
|
||||
# compile native libs with Gradle script, we need bridge for unit and integration tests
|
||||
RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 -Pcom.android.build.threadPoolSize=1
|
||||
|
||||
# add all react-native code
|
||||
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 npm install github@0.2.4
|
||||
|
||||
WORKDIR /app/website
|
||||
RUN npm install
|
||||
|
||||
WORKDIR /app
|
||||
@@ -0,0 +1,101 @@
|
||||
FROM library/ubuntu:16.04
|
||||
|
||||
# set default build arguments
|
||||
ARG ANDROID_VERSION=25.2.3
|
||||
ARG BUCK_VERSION=f3452a6a7ab15a60e94c962e686293acbe677473
|
||||
ARG NDK_VERSION=10e
|
||||
ARG NODE_VERSION=6.2.0
|
||||
ARG WATCHMAN_VERSION=4.7.0
|
||||
|
||||
# set default environment variables
|
||||
ENV ADB_INSTALL_TIMEOUT=10
|
||||
ENV PATH=${PATH}:/opt/buck/bin/
|
||||
ENV ANDROID_HOME=/opt/android
|
||||
ENV ANDROID_SDK_HOME=${ANDROID_HOME}
|
||||
ENV PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
|
||||
ENV ANDROID_NDK=/opt/ndk/android-ndk-r$NDK_VERSION
|
||||
ENV PATH=${PATH}:${ANDROID_NDK}
|
||||
|
||||
# install system dependencies
|
||||
RUN apt-get update && apt-get install ant autoconf automake curl g++ gcc git libqt5widgets5 lib32z1 lib32stdc++6 make maven npm openjdk-8* python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev unzip -y
|
||||
|
||||
# configure npm
|
||||
RUN npm config set spin=false
|
||||
RUN npm config set progress=false
|
||||
|
||||
# install node
|
||||
RUN npm install n -g
|
||||
RUN n $NODE_VERSION
|
||||
|
||||
# download buck
|
||||
RUN git clone https://github.com/facebook/buck.git /opt/buck
|
||||
WORKDIR /opt/buck
|
||||
RUN git checkout $BUCK_VERSION
|
||||
|
||||
# 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
|
||||
|
||||
# download and unpack android
|
||||
RUN mkdir /opt/android
|
||||
WORKDIR /opt/android
|
||||
RUN curl --silent https://dl.google.com/android/repository/tools_r$ANDROID_VERSION-linux.zip > android.zip
|
||||
RUN unzip android.zip
|
||||
RUN rm android.zip
|
||||
|
||||
# download and unpack NDK
|
||||
RUN mkdir /opt/ndk
|
||||
WORKDIR /opt/ndk
|
||||
RUN curl --silent https://dl.google.com/android/repository/android-ndk-r$NDK_VERSION-linux-x86_64.zip > ndk.zip
|
||||
RUN unzip ndk.zip
|
||||
|
||||
# cleanup NDK
|
||||
RUN rm ndk.zip
|
||||
|
||||
# Add android SDK tools
|
||||
|
||||
# Android SDK Platform-tools, revision 25.0.4
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android SDK Platform-tools, revision 25.0.4" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# Android SDK Build-tools, revision 23.0.1
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android SDK Build-tools, revision 23.0.1" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# SDK Platform Android 6.0, API 23, revision 3
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "SDK Platform Android 6.0, API 23" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# SDK Platform Android 4.4.2, API 19, revision 4
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "SDK Platform Android 4.4.2, API 19, revision 4" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# ARM EABI v7a System Image, Android API 19, revision 5
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "ARM EABI v7a System Image, Android API 19, revision 5" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# Intel x86 Atom System Image, Android API 19, revision 5
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Intel x86 Atom System Image, Android API 19, revision 5" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# Google APIs, Android API 23, revision 1
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Google APIs, Android API 23, revision 1" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# Android Support Repository, revision 45
|
||||
RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android Support Repository" | awk '{ print $1 }' | sed 's/.$//')
|
||||
|
||||
# Link adb executable
|
||||
RUN ln -s /opt/android/platform-tools/adb /usr/bin/adb
|
||||
|
||||
# Install google-chrome
|
||||
RUN curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y google-chrome-stable
|
||||
|
||||
# clean up unnecessary directories
|
||||
RUN rm -rf /opt/android/system-images/android-19/default/x86
|
||||
@@ -0,0 +1,19 @@
|
||||
FROM library/node:6.9.2
|
||||
|
||||
ENV YARN_VERSION=0.27.5
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get update && apt-get install ocaml libelf-dev -y
|
||||
RUN npm install yarn@$YARN_VERSION -g
|
||||
|
||||
# add code
|
||||
RUN mkdir /app
|
||||
ADD . /app
|
||||
|
||||
WORKDIR /app
|
||||
RUN yarn install --ignore-engines
|
||||
|
||||
WORKDIR website
|
||||
RUN yarn install --ignore-engines --ignore-platform
|
||||
|
||||
WORKDIR /app
|
||||
+21
-17
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -18,6 +20,7 @@
|
||||
* --package - com.facebook.react.tests
|
||||
* --retries [num] - how many times to retry possible flaky commands: npm install and running tests, default 1
|
||||
*/
|
||||
/*eslint-disable no-undef */
|
||||
|
||||
const argv = require('yargs').argv;
|
||||
const async = require('async');
|
||||
@@ -28,7 +31,7 @@ const path = require('path');
|
||||
const colors = {
|
||||
GREEN: '\x1b[32m',
|
||||
RED: '\x1b[31m',
|
||||
RESET: '\x1b[0m',
|
||||
RESET: '\x1b[0m'
|
||||
};
|
||||
|
||||
const test_opts = {
|
||||
@@ -38,11 +41,11 @@ const test_opts = {
|
||||
PATH: argv.path || './ReactAndroid/src/androidTest/java/com/facebook/react/tests',
|
||||
RETRIES: parseInt(argv.retries || 2, 10),
|
||||
|
||||
TEST_TIMEOUT: parseInt(argv['test-timeout'] || 1000 * 60 * 10, 10),
|
||||
TEST_TIMEOUT: parseInt(argv['test-timeout'] || 1000 * 60 * 10),
|
||||
|
||||
OFFSET: argv.offset,
|
||||
COUNT: argv.count,
|
||||
};
|
||||
COUNT: argv.count
|
||||
}
|
||||
|
||||
let max_test_class_length = Number.NEGATIVE_INFINITY;
|
||||
|
||||
@@ -68,6 +71,7 @@ testClasses = testClasses.map((clazz) => {
|
||||
|
||||
// only process subset of the tests at corresponding offset and count if args provided
|
||||
if (test_opts.COUNT != null && test_opts.OFFSET != null) {
|
||||
const testCount = testClasses.length;
|
||||
const start = test_opts.COUNT * test_opts.OFFSET;
|
||||
const end = start + test_opts.COUNT;
|
||||
|
||||
@@ -80,15 +84,15 @@ if (test_opts.COUNT != null && test_opts.OFFSET != null) {
|
||||
}
|
||||
}
|
||||
|
||||
async.mapSeries(testClasses, (clazz, callback) => {
|
||||
if (clazz.length > max_test_class_length) {
|
||||
return async.mapSeries(testClasses, (clazz, callback) => {
|
||||
if(clazz.length > max_test_class_length) {
|
||||
max_test_class_length = clazz.length;
|
||||
}
|
||||
|
||||
return async.retry(test_opts.RETRIES, (retryCb) => {
|
||||
const test_process = child_process.spawn('./.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
const test_process = child_process.spawn('./ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
|
||||
stdio: 'inherit'
|
||||
})
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
test_process.kill();
|
||||
@@ -102,7 +106,7 @@ async.mapSeries(testClasses, (clazz, callback) => {
|
||||
test_process.on('exit', (code) => {
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (code !== 0) {
|
||||
if(code !== 0) {
|
||||
return retryCb(new Error(`Process exited with code: ${code}`));
|
||||
}
|
||||
|
||||
@@ -111,7 +115,7 @@ async.mapSeries(testClasses, (clazz, callback) => {
|
||||
}, (err) => {
|
||||
return callback(null, {
|
||||
name: clazz,
|
||||
status: err ? 'failure' : 'success',
|
||||
status: err ? 'failure' : 'success'
|
||||
});
|
||||
});
|
||||
}, (err, results) => {
|
||||
@@ -134,16 +138,16 @@ function print_test_suite_results(results) {
|
||||
function pad_output(num_chars) {
|
||||
let i = 0;
|
||||
|
||||
while (i < num_chars) {
|
||||
while(i < num_chars) {
|
||||
process.stdout.write(' ');
|
||||
i++;
|
||||
}
|
||||
}
|
||||
results.forEach((test) => {
|
||||
if (test.status === 'success') {
|
||||
if(test.status === 'success') {
|
||||
color = colors.GREEN;
|
||||
passing_suites++;
|
||||
} else if (test.status === 'failure') {
|
||||
} else if(test.status === 'failure') {
|
||||
color = colors.RED;
|
||||
failing_suites++;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# for buck gen
|
||||
mount -o remount,exec /dev/shm
|
||||
|
||||
AVD_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||
|
||||
# create virtual device
|
||||
echo no | android create avd -n $AVD_UUID -f -t android-19 --abi default/armeabi-v7a
|
||||
|
||||
# emulator setup
|
||||
emulator64-arm -avd $AVD_UUID -no-skin -no-audio -no-window -no-boot-anim &
|
||||
bootanim=""
|
||||
until [[ "$bootanim" =~ "stopped" ]]; do
|
||||
sleep 5
|
||||
bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
|
||||
echo "boot animation status=$bootanim"
|
||||
done
|
||||
|
||||
set -x
|
||||
|
||||
# solve issue with max user watches limit
|
||||
echo 65536 | tee -a /proc/sys/fs/inotify/max_user_watches
|
||||
watchman shutdown-server
|
||||
|
||||
# integration tests
|
||||
# build JS bundle for instrumentation tests
|
||||
node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
|
||||
|
||||
# build test APK
|
||||
source ./scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
|
||||
|
||||
# run installed apk with tests
|
||||
node ./ContainerShip/scripts/run-android-ci-instrumentation-tests.js $*
|
||||
exit $?
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set default environment variables
|
||||
UNIT_TESTS_BUILD_THREADS="${UNIT_TESTS_BUILD_THREADS:-1}"
|
||||
|
||||
# for buck gen
|
||||
mount -o remount,exec /dev/shm
|
||||
|
||||
set -x
|
||||
|
||||
# run unit tests
|
||||
buck test ReactAndroid/src/test/... --config build.threads=$UNIT_TESTS_BUILD_THREADS
|
||||
Executable
+253
@@ -0,0 +1,253 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# set default environment variables
|
||||
ROOT=$(pwd)
|
||||
SCRIPTS=$(pwd)/scripts
|
||||
|
||||
RUN_ANDROID=0
|
||||
RUN_CLI_INSTALL=1
|
||||
RUN_IOS=0
|
||||
RUN_JS=0
|
||||
|
||||
RETRY_COUNT=${RETRY_COUNT:-2}
|
||||
AVD_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||
|
||||
ANDROID_NPM_DEPS="appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1"
|
||||
CLI_PACKAGE=$ROOT/react-native-cli/react-native-cli-*.tgz
|
||||
PACKAGE=$ROOT/react-native-*.tgz
|
||||
|
||||
# solve issue with max user watches limit
|
||||
echo 65536 | tee -a /proc/sys/fs/inotify/max_user_watches
|
||||
watchman shutdown-server
|
||||
|
||||
# retries command on failure
|
||||
# $1 -- max attempts
|
||||
# $2 -- command to run
|
||||
function retry() {
|
||||
local -r -i max_attempts="$1"; shift
|
||||
local -r cmd="$@"
|
||||
local -i attempt_num=1
|
||||
|
||||
until $cmd; do
|
||||
if (( attempt_num == max_attempts )); then
|
||||
echo "Execution of '$cmd' failed; no more attempts left"
|
||||
return 1
|
||||
else
|
||||
(( attempt_num++ ))
|
||||
echo "Execution of '$cmd' failed; retrying for attempt number $attempt_num..."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# parse command line args & flags
|
||||
while :; do
|
||||
case "$1" in
|
||||
--android)
|
||||
RUN_ANDROID=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--ios)
|
||||
RUN_IOS=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--js)
|
||||
RUN_JS=1
|
||||
shift
|
||||
;;
|
||||
|
||||
--skip-cli-install)
|
||||
RUN_CLI_INSTALL=0
|
||||
shift
|
||||
;;
|
||||
|
||||
--tvos)
|
||||
RUN_IOS=1
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
break
|
||||
esac
|
||||
done
|
||||
|
||||
function e2e_suite() {
|
||||
cd $ROOT
|
||||
|
||||
if [ $RUN_ANDROID -eq 0 ] && [ $RUN_IOS -eq 0 ] && [ $RUN_JS -eq 0 ]; then
|
||||
echo "No e2e tests specified!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# create temp dir
|
||||
TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX)
|
||||
|
||||
# To make sure we actually installed the local version
|
||||
# of react-native, we will create a temp file inside the template
|
||||
# and check that it exists after `react-native init
|
||||
IOS_MARKER=$(mktemp $ROOT/local-cli/templates/HelloWorld/ios/HelloWorld/XXXXXXXX)
|
||||
ANDROID_MARKER=$(mktemp ${ROOT}/local-cli/templates/HelloWorld/android/XXXXXXXX)
|
||||
|
||||
# install CLI
|
||||
cd react-native-cli
|
||||
npm pack
|
||||
cd ..
|
||||
|
||||
# can skip cli install for non sudo mode
|
||||
if [ $RUN_CLI_INSTALL -ne 0 ]; then
|
||||
npm install -g $CLI_PACKAGE
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not install react-native-cli globally, please run in su mode"
|
||||
echo "Or with --skip-cli-install to skip this step"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $RUN_ANDROID -ne 0 ]; then
|
||||
set +ex
|
||||
|
||||
# create virtual device
|
||||
if ! android list avd | grep "$AVD_UUID" > /dev/null; then
|
||||
echo no | android create avd -n $AVD_UUID -f -t android-19 --abi default/armeabi-v7a
|
||||
fi
|
||||
|
||||
# newline at end of adb devices call and first line is headers
|
||||
DEVICE_COUNT=$(adb devices | wc -l)
|
||||
((DEVICE_COUNT -= 2))
|
||||
|
||||
# will always kill an existing emulator if one exists for fresh setup
|
||||
if [[ $DEVICE_COUNT -ge 1 ]]; then
|
||||
adb emu kill
|
||||
fi
|
||||
|
||||
# emulator setup
|
||||
emulator64-arm -avd $AVD_UUID -no-skin -no-audio -no-window -no-boot-anim &
|
||||
|
||||
bootanim=""
|
||||
until [[ "$bootanim" =~ "stopped" ]]; do
|
||||
sleep 5
|
||||
bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
|
||||
echo "boot animation status=$bootanim"
|
||||
done
|
||||
|
||||
set -ex
|
||||
|
||||
./gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to compile Android binaries"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
npm pack
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to pack react-native"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd $TEMP_DIR
|
||||
|
||||
retry $RETRY_COUNT react-native init EndToEndTest --version $PACKAGE --npm
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to execute react-native init"
|
||||
echo "Most common reason is npm registry connectivity, try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd EndToEndTest
|
||||
|
||||
# android tests
|
||||
if [ $RUN_ANDROID -ne 0 ]; then
|
||||
echo "Running an Android e2e test"
|
||||
echo "Installing e2e framework"
|
||||
|
||||
retry $RETRY_COUNT npm install --save-dev $ANDROID_NPM_DEPS --silent >> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install appium"
|
||||
echo "Most common reason is npm registry connectivity, try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cp $SCRIPTS/android-e2e-test.js android-e2e-test.js
|
||||
|
||||
cd android
|
||||
echo "Downloading Maven deps"
|
||||
./gradlew :app:copyDownloadableDepsToLibs
|
||||
|
||||
cd ..
|
||||
keytool -genkey -v -keystore android/keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
|
||||
|
||||
node ./node_modules/.bin/appium >> /dev/null &
|
||||
APPIUM_PID=$!
|
||||
echo "Starting appium server $APPIUM_PID"
|
||||
|
||||
echo "Building app"
|
||||
buck build android/app
|
||||
|
||||
# hack to get node unhung (kill buckd)
|
||||
kill -9 $(pgrep java)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "could not execute Buck build, is it installed and in PATH?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Starting packager server"
|
||||
npm start >> /dev/null &
|
||||
SERVER_PID=$!
|
||||
sleep 15
|
||||
|
||||
echo "Executing android e2e test"
|
||||
retry $RETRY_COUNT node node_modules/.bin/_mocha android-e2e-test.js
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to run Android e2e tests"
|
||||
echo "Most likely the code is broken"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# kill packager process
|
||||
if kill -0 $SERVER_PID; then
|
||||
echo "Killing packager $SERVER_PID"
|
||||
kill -9 $SERVER_PID
|
||||
fi
|
||||
|
||||
# kill appium process
|
||||
if kill -0 $APPIUM_PID; then
|
||||
echo "Killing appium $APPIUM_PID"
|
||||
kill -9 $APPIUM_PID
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# ios tests
|
||||
if [ $RUN_IOS -ne 0 ]; then
|
||||
echo "Running ios e2e tests not yet implemented for docker!"
|
||||
fi
|
||||
|
||||
# js tests
|
||||
if [ $RUN_JS -ne 0 ]; then
|
||||
# Check the packager produces a bundle (doesn't throw an error)
|
||||
react-native bundle --max-workers 1 --platform android --dev true --entry-file index.android.js --bundle-output android-bundle.js
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not build android bundle"
|
||||
return 1
|
||||
fi
|
||||
|
||||
react-native bundle --max-workers 1 --platform ios --dev true --entry-file index.ios.js --bundle-output ios-bundle.js
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not build iOS bundle"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# directory cleanup
|
||||
rm $IOS_MARKER
|
||||
rm $ANDROID_MARKER
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
retry $RETRY_COUNT e2e_suite
|
||||
+5
-10
@@ -1,10 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
# shellcheck disable=SC1117
|
||||
# Python script to run instrumentation tests, copied from https://github.com/circleci/circle-dummy-android
|
||||
# Example: ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests com.facebook.react.tests.ReactPickerTestCase
|
||||
#
|
||||
@@ -14,7 +9,7 @@ export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
|
||||
adb logcat -c
|
||||
|
||||
# run tests and check output
|
||||
python - "$1" "$2" << END
|
||||
python - $1 $2 << END
|
||||
|
||||
import re
|
||||
import subprocess as sp
|
||||
@@ -29,12 +24,12 @@ test_class = None
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
test_class = sys.argv[2]
|
||||
|
||||
|
||||
def update():
|
||||
# prevent CircleCI from killing the process for inactivity
|
||||
while not done:
|
||||
time.sleep(5)
|
||||
print "Running in background. Waiting for 'adb' command response..."
|
||||
print "Running in background. Waiting for 'adb' command reponse..."
|
||||
|
||||
t = threading.Thread(target=update)
|
||||
t.dameon = True
|
||||
@@ -43,10 +38,10 @@ t.start()
|
||||
def run():
|
||||
sp.Popen(['adb', 'wait-for-device']).communicate()
|
||||
if (test_class != None):
|
||||
p = sp.Popen('adb shell am instrument -w -e class %s %s/android.support.test.runner.AndroidJUnitRunner'
|
||||
p = sp.Popen('adb shell am instrument -w -e class %s %s/android.support.test.runner.AndroidJUnitRunner'
|
||||
% (test_class, test_app), shell=True, stdout=sp.PIPE, stderr=sp.PIPE, stdin=sp.PIPE)
|
||||
else :
|
||||
p = sp.Popen('adb shell am instrument -w %s/android.support.test.runner.AndroidJUnitRunner'
|
||||
p = sp.Popen('adb shell am instrument -w %s/android.support.test.runner.AndroidJUnitRunner'
|
||||
% (test_app), shell=True, stdout=sp.PIPE, stderr=sp.PIPE, stdin=sp.PIPE)
|
||||
return p.communicate()
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
# Dockerfile Tests
|
||||
|
||||
This is a high level overview of the test configuration using docker. It explains how to run the tests locally
|
||||
and how they integrate with the Jenkins Pipeline script to run the automated tests on ContainerShip <https://www.containership.io/>.
|
||||
|
||||
## Docker Installation
|
||||
|
||||
It is required to have Docker running on your machine in order to build and run the tests in the Dockerfiles.
|
||||
See <https://docs.docker.com/engine/installation/> for more information on how to install.
|
||||
|
||||
## Convenience NPM Run Scripts
|
||||
|
||||
We have added a number of default run scripts to the `package.json` file to simplify building and running your tests.
|
||||
|
||||
`npm run test-android-setup` - Pulls down the base android docker image used for running the tests
|
||||
|
||||
`npm run test-android-build` - Builds the docker image used to run the tests
|
||||
|
||||
`npm run test-android-run-unit` - Runs all the unit tests that have been built in the latest react/android docker image (note: you need to run test-android-build before executing this, if the image does not exist it will fail)
|
||||
|
||||
`npm run test-android-run-instrumentation` - Runs all the instrumentation tests that have been built in the latest react/android docker image (note: you need to run test-android-build before executing this, if the image does not exist it will fail). You can also pass additional flags to filter which tests instrumentation tests are run. Ex: `npm run test-android-run-instrumentation -- --filter=TestIdTestCase` to only run the TestIdTestCase instrumentation test. See below for more information
|
||||
on the instrumentation test flags.
|
||||
|
||||
`npm run test-android-run-e2e` - Runs all the end to end tests that have been built in the latest react/android docker image (note: you need to run test-android-build before executing this, if the image does not exist it will fail)
|
||||
|
||||
`npm run test-android-unit` - Builds and runs the android unit tests.
|
||||
|
||||
`npm run test-android-instrumentation` - Builds and runs the android instrumentation tests.
|
||||
|
||||
`npm run test-android-e2e` - Builds and runs the android end to end tests.
|
||||
|
||||
## Detailed Android Setup
|
||||
|
||||
There are two Dockerfiles for use with the Android codebase.
|
||||
|
||||
The `Dockerfile.android-base` contains all the necessary prerequisites required to run the React Android tests. It is
|
||||
separated out into a separate Dockerfile because these are dependencies that rarely change and also because it is quite
|
||||
a beastly image since it contains all the Android depedencies for running android and the emulators (~9GB).
|
||||
|
||||
The good news is you should rarely have to build or pull down the base image! All iterative code updates happen as
|
||||
part of the `Dockerfile.android` image build.
|
||||
|
||||
So step one...
|
||||
|
||||
`docker pull containership/android-base:latest`
|
||||
|
||||
This will take quite some time depending on your connection and you need to ensure you have ~10GB of free disk space.
|
||||
|
||||
Once this is done, you can run tests locally by executing two simple commands:
|
||||
|
||||
1. `docker build -t react/android -f ./ContainerShip/Dockerfile.android .`
|
||||
2. `docker run --cap-add=SYS_ADMIN -it react/android bash ContainerShip/scripts/run-android-docker-unit-tests.sh`
|
||||
|
||||
> Note: `--cap-add=SYS_ADMIN` flag is required for the `ContainerShip/scripts/run-android-docker-unit-tests.sh` and
|
||||
`ContainerShip/scripts/run-android-docker-instrumentation-tests.sh` in order to allow the remounting of `/dev/shm` as writeable
|
||||
so the `buck` build system may write temporary output to that location
|
||||
|
||||
Every time you make any modifications to the codebase, you should re-run the `docker build ...` command in order for your
|
||||
updates to be included in your local docker image.
|
||||
|
||||
The following shell scripts have been provided for android testing:
|
||||
|
||||
`ContainerShip/scripts/run-android-docker-unit-tests.sh` - Runs the standard android unit tests
|
||||
|
||||
`ContainerShip/scripts/run-android-docker-instrumentation-tests.sh` - Runs the android instrumentation tests on the emulator. *Note* that these
|
||||
tests take quite some time to run so there are various flags you can pass in order to filter which tests are run (see below)
|
||||
|
||||
`ContainerShip/scripts/run-ci-e2e-tests.sh` - Runs the android end to end tests
|
||||
|
||||
#### ContainerShip/scripts/run-android-docker-instrumentation-tests.sh
|
||||
|
||||
The instrumentation test script accepts the following flags in order to customize the execution of the tests:
|
||||
|
||||
`--filter` - A regex that filters which instrumentation tests will be run. (Defaults to .*)
|
||||
|
||||
`--package` - Name of the java package containing the instrumentation tests (Defaults to com.facebook.react.tests)
|
||||
|
||||
`--path` - Path to the directory containing the instrumentation tests. (Defaults to ./ReactAndroid/src/androidTest/java/com/facebook/react/tests)
|
||||
|
||||
`--retries` - Number of times to retry a failed test before declaring a failure (Defaults to 2)
|
||||
|
||||
For example, if locally you only wanted to run the InitialPropsTestCase, you could do the following:
|
||||
|
||||
`docker run --cap-add=SYS_ADMIN -it react/android bash ContainerShip/scripts/run-android-docker-instrumentation-tests.sh --filter="InitialPropsTestCase"`
|
||||
|
||||
# Javascript Setup
|
||||
|
||||
There is a single Dockerfile for use with the javascript codebase.
|
||||
|
||||
The `Dockerfile.javascript` base requires all the necessary dependencies for running Javascript tests.
|
||||
|
||||
Any time you make an update to the codebase, you can build and run the javascript tests with the following three commands:
|
||||
|
||||
1. `docker build -t react/js -f ./ContainerShip/Dockerfile.javascript .`
|
||||
2. `docker run -it react/js yarn test --maxWorkers=4`
|
||||
3. `docker run -it react/js yarn run flow -- check`
|
||||
@@ -1,59 +0,0 @@
|
||||
# The React Native Ecosystem
|
||||
|
||||
We aim to build a vibrant and inclusive ecosystem of partners, core contributors, and community that goes beyond the main React Native GitHub repository. This document explains the roles and responsibilities of various stakeholders and provides guidelines for the community organization. The structure outlined in this document has been in place for a while but hadn't been written down before.
|
||||
|
||||
There are three types of stakeholders:
|
||||
|
||||
* **Partners:** Companies that are significantly invested in React Native and have been for years.
|
||||
* **Core Contributors:** Individual people who contribute to the React Native project.
|
||||
* **Community Contributors:** Individuals who support projects in the [react-native-community](https://github.com/react-native-community) organization.
|
||||
|
||||
## Partners
|
||||
|
||||
Partners are companies that are significantly invested in React Native and have been for years. Informed by their use of React Native, they push for improvements of the core and/or the ecosystem around it. Partners think of React Native as a product: they understand the trade offs that the project makes as well as future plans and goals. Together we shape the vision for React Native to make it the best way to build applications.
|
||||
|
||||
React Native's current set of partners include Callstack, Expo, Facebook, Infinite Red, Microsoft and Software Mansion. Many engineers from these companies are core contributors, and their partner responsibilities also include:
|
||||
|
||||
* **[Callstack](https://callstack.com/):** Manages releases, maintains the [React Native CLI](https://github.com/react-native-community/react-native-cli) and organizes [React Native EU](https://react-native.eu/)
|
||||
* **[Expo](https://expo.io/):** Builds [expo](https://github.com/expo/expo) on top of React Native to simplify app development
|
||||
* **[Facebook](https://opensource.facebook.com):** Oversees the React Native product and maintains the [React Native core repo](https://reactnative.dev/)
|
||||
* **[Infinite Red](https://infinite.red/):** Maintains the [ignite cli/boilerplate](https://github.com/infinitered/ignite), organizes [Chain React Conf](https://cr.infinite.red/)
|
||||
* **[Microsoft](http://aka.ms/reactnative):** Develops [React Native Windows](https://github.com/Microsoft/react-native-windows) and [React Native macOS](https://github.com/microsoft/react-native-macos) for building apps that target Windows and macOS
|
||||
* **[Software Mansion](https://swmansion.com/):** Maintain core infrastructure including JSC, Animated, and other popular third-party plugins.
|
||||
|
||||
In terms of open source work, pull requests from partners are commonly prioritized. When you are contributing to React Native, you'll most likely meet somebody who works at one of the partner companies and who is a core contributor:
|
||||
|
||||
## Core Contributors
|
||||
|
||||
Core contributors are individuals who contribute to the React Native project. A core contributor is somebody who displayed a lasting commitment to the evolution and maintenance of React Native. The work done by core contributors includes responsibilities mentioned in the “Partners” section above, and concretely means that they:
|
||||
|
||||
* Consistently contribute high quality changes, fixes and improvements
|
||||
* Actively review changes and provide quality feedback to contributors
|
||||
* Manage the release process of React Native by maintaining release branches, communicating changes to users and publishing releases
|
||||
* Love to help out other users with issues on GitHub
|
||||
* Mentor and encourage first time contributors
|
||||
* Identify React Native community members who could be effective core contributors
|
||||
* Help build an inclusive community with people from all backgrounds
|
||||
* Are great at communicating with other contributors and the community in general
|
||||
|
||||
These are behaviors we have observed in our existing core contributors. They aren't strict rules but rather outline their usual responsibilities. We do not expect every core contributor to do all of the above things all the time. Most importantly, we want to create a supportive and friendly environment that fosters collaboration. Above all else, **we are always polite and friendly.**
|
||||
|
||||
Core contributor status is attained after consistently contributing and taking on the responsibilities outlined above and granted by other core contributors. Similarly, after a long period of inactivity, a core contributor may be removed.
|
||||
|
||||
We aim to make contributing to React Native as easy and transparent as possible. All important topics are handled through a [discussion or RFC process on GitHub](https://github.com/react-native-community/discussions-and-proposals). We are always looking for active, enthusiastic members of the React Native community to become core contributors.
|
||||
|
||||
## Community Contributors
|
||||
|
||||
Community contributors are individuals who support projects in the [react-native-community](https://github.com/react-native-community) organization. This organization exists as an incubator for high quality components that extend the capabilities of React Native with functionality that many but not all applications require. Facebook engineers will provide guidance to help build a vibrant community of people and components that make React Native better.
|
||||
|
||||
This structure has multiple benefits:
|
||||
|
||||
* Keep the core of React Native small, which improves performance and reduces the surface area
|
||||
* Provide visibility to projects through shared representation, for example on the React Native website or on Twitter
|
||||
* Ensure a consistent and high standard for code, documentation, user experience, stability and contributions for third-party components
|
||||
* Upgrade the most important components right away when we make breaking changes and move the ecosystem forward at a fast pace
|
||||
* Find new maintainers for projects that are important but were abandoned by previous owners
|
||||
|
||||
Additionally, some companies may choose to sponsor the development of one or many of the packages that are part of the community organization. They will commit to maintain projects, triage issues, fix bugs and develop features. In turn, they will be able to gain visibility for their work, for example through a mention of active maintainers in the README of individual projects after a consistent period of contributions. Such a mention may be removed if maintainers abandon the project.
|
||||
|
||||
If you are working on a popular component and would like to move it to the React Native community, please create an issue on the [discussions-and-proposals repository](https://github.com/react-native-community/discussions-and-proposals).
|
||||
@@ -1,6 +0,0 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
||||
ruby '2.7.4'
|
||||
|
||||
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.5)
|
||||
rexml
|
||||
activesupport (6.1.7)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.8.1)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
algoliasearch (1.27.5)
|
||||
httpclient (~> 2.8, >= 2.8.3)
|
||||
json (>= 1.5.1)
|
||||
atomos (0.1.3)
|
||||
claide (1.1.0)
|
||||
cocoapods (1.11.3)
|
||||
addressable (~> 2.8)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
cocoapods-core (= 1.11.3)
|
||||
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
||||
cocoapods-downloader (>= 1.4.0, < 2.0)
|
||||
cocoapods-plugins (>= 1.0.0, < 2.0)
|
||||
cocoapods-search (>= 1.0.0, < 2.0)
|
||||
cocoapods-trunk (>= 1.4.0, < 2.0)
|
||||
cocoapods-try (>= 1.1.0, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
escape (~> 0.0.4)
|
||||
fourflusher (>= 2.3.0, < 3.0)
|
||||
gh_inspector (~> 1.0)
|
||||
molinillo (~> 0.8.0)
|
||||
nap (~> 1.0)
|
||||
ruby-macho (>= 1.0, < 3.0)
|
||||
xcodeproj (>= 1.21.0, < 2.0)
|
||||
cocoapods-core (1.11.3)
|
||||
activesupport (>= 5.0, < 7)
|
||||
addressable (~> 2.8)
|
||||
algoliasearch (~> 1.0)
|
||||
concurrent-ruby (~> 1.1)
|
||||
fuzzy_match (~> 2.0.4)
|
||||
nap (~> 1.0)
|
||||
netrc (~> 0.11)
|
||||
public_suffix (~> 4.0)
|
||||
typhoeus (~> 1.0)
|
||||
cocoapods-deintegrate (1.0.5)
|
||||
cocoapods-downloader (1.6.3)
|
||||
cocoapods-plugins (1.0.0)
|
||||
nap
|
||||
cocoapods-search (1.0.1)
|
||||
cocoapods-trunk (1.6.0)
|
||||
nap (>= 0.8, < 2.0)
|
||||
netrc (~> 0.11)
|
||||
cocoapods-try (1.2.0)
|
||||
colored2 (3.1.2)
|
||||
concurrent-ruby (1.1.10)
|
||||
escape (0.0.4)
|
||||
ethon (0.16.0)
|
||||
ffi (>= 1.15.0)
|
||||
ffi (1.15.5)
|
||||
fourflusher (2.3.1)
|
||||
fuzzy_match (2.0.4)
|
||||
gh_inspector (1.1.3)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.12.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.6.2)
|
||||
minitest (5.16.3)
|
||||
molinillo (0.8.0)
|
||||
nanaimo (0.3.0)
|
||||
nap (1.1.0)
|
||||
netrc (0.11.0)
|
||||
public_suffix (4.0.7)
|
||||
rexml (3.2.5)
|
||||
ruby-macho (2.5.1)
|
||||
typhoeus (1.4.0)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (2.0.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
xcodeproj (1.22.0)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.3.0)
|
||||
rexml (~> 3.2.4)
|
||||
zeitwerk (2.6.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
cocoapods (~> 1.11, >= 1.11.2)
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.7.4p191
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.27
|
||||
@@ -1,47 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow
|
||||
* @providesModule AccessibilityManagerTest
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
import invariant from 'invariant';
|
||||
import NativeAccessibilityManager from 'react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager';
|
||||
import {DeviceEventEmitter, NativeModules, View} from 'react-native';
|
||||
import * as React from 'react';
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const { View } = ReactNative;
|
||||
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
const {
|
||||
TestModule,
|
||||
AccessibilityManager,
|
||||
} = ReactNative.NativeModules;
|
||||
|
||||
const {TestModule} = NativeModules;
|
||||
|
||||
class AccessibilityManagerTest extends React.Component<{...}> {
|
||||
class AccessibilityManagerTest extends React.Component {
|
||||
componentDidMount() {
|
||||
invariant(
|
||||
NativeAccessibilityManager,
|
||||
"NativeAccessibilityManager doesn't exist",
|
||||
);
|
||||
|
||||
NativeAccessibilityManager.setAccessibilityContentSizeMultipliers({
|
||||
extraSmall: 1.0,
|
||||
small: 2.0,
|
||||
medium: 3.0,
|
||||
large: 4.0,
|
||||
extraLarge: 5.0,
|
||||
extraExtraLarge: 6.0,
|
||||
extraExtraExtraLarge: 7.0,
|
||||
accessibilityMedium: 8.0,
|
||||
accessibilityLarge: 9.0,
|
||||
accessibilityExtraLarge: 10.0,
|
||||
accessibilityExtraExtraLarge: 11.0,
|
||||
accessibilityExtraExtraExtraLarge: 12.0,
|
||||
AccessibilityManager.setAccessibilityContentSizeMultipliers({
|
||||
'extraSmall': 1.0,
|
||||
'small': 2.0,
|
||||
'medium': 3.0,
|
||||
'large': 4.0,
|
||||
'extraLarge': 5.0,
|
||||
'extraExtraLarge': 6.0,
|
||||
'extraExtraExtraLarge': 7.0,
|
||||
'accessibilityMedium': 8.0,
|
||||
'accessibilityLarge': 9.0,
|
||||
'accessibilityExtraLarge': 10.0,
|
||||
'accessibilityExtraExtraLarge': 11.0,
|
||||
'accessibilityExtraExtraExtraLarge': 12.0,
|
||||
});
|
||||
DeviceEventEmitter.addListener('didUpdateDimensions', update => {
|
||||
RCTDeviceEventEmitter.addListener('didUpdateDimensions', update => {
|
||||
TestModule.markTestPassed(update.window.fontScale === 4.0);
|
||||
});
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render(): React.Element<any> {
|
||||
return <View />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @providesModule AppEventsTest
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {NativeAppEventEmitter, StyleSheet, Text, View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
NativeAppEventEmitter,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer');
|
||||
var deepDiffer = require('deepDiffer');
|
||||
|
||||
const TEST_PAYLOAD = {foo: 'bar'};
|
||||
var TEST_PAYLOAD = {foo: 'bar'};
|
||||
|
||||
type AppEvent = {
|
||||
data: Object,
|
||||
ts: number,
|
||||
...
|
||||
};
|
||||
type AppEvent = { data: Object, ts: number, };
|
||||
type State = {
|
||||
sent: 'none' | AppEvent,
|
||||
received: 'none' | AppEvent,
|
||||
elapsed?: string,
|
||||
...
|
||||
};
|
||||
|
||||
class AppEventsTest extends React.Component<{...}, State> {
|
||||
class AppEventsTest extends React.Component {
|
||||
state: State = {sent: 'none', received: 'none'};
|
||||
|
||||
componentDidMount() {
|
||||
NativeAppEventEmitter.addListener('testEvent', this.receiveEvent);
|
||||
const event = {data: TEST_PAYLOAD, ts: Date.now()};
|
||||
var event = {data: TEST_PAYLOAD, ts: Date.now()};
|
||||
TestModule.sendAppEvent('testEvent', event);
|
||||
this.setState({sent: event});
|
||||
}
|
||||
|
||||
receiveEvent: (event: any) => void = (event: any) => {
|
||||
receiveEvent = (event: any) => {
|
||||
if (deepDiffer(event.data, TEST_PAYLOAD)) {
|
||||
throw new Error('Received wrong event: ' + JSON.stringify(event));
|
||||
}
|
||||
const elapsed = Date.now() - event.ts + 'ms';
|
||||
var elapsed = (Date.now() - event.ts) + 'ms';
|
||||
this.setState({received: event, elapsed}, () => {
|
||||
TestModule.markTestCompleted();
|
||||
});
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>{JSON.stringify(this.state, null, ' ')}</Text>
|
||||
<Text>
|
||||
{JSON.stringify(this.state, null, ' ')}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -62,7 +65,7 @@ class AppEventsTest extends React.Component<{...}, State> {
|
||||
|
||||
AppEventsTest.displayName = 'AppEventsTest';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
margin: 40,
|
||||
},
|
||||
|
||||
@@ -1,75 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule AsyncStorageTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {AsyncStorage, Text, View, StyleSheet} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
AsyncStorage,
|
||||
Text,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer');
|
||||
const nullthrows = require('nullthrows');
|
||||
var deepDiffer = require('deepDiffer');
|
||||
|
||||
const DEBUG = false;
|
||||
var DEBUG = false;
|
||||
|
||||
const KEY_1 = 'key_1';
|
||||
const VAL_1 = 'val_1';
|
||||
const KEY_2 = 'key_2';
|
||||
const VAL_2 = 'val_2';
|
||||
const KEY_MERGE = 'key_merge';
|
||||
const VAL_MERGE_1 = {foo: 1, bar: {hoo: 1, boo: 1}, moo: {a: 3}};
|
||||
const VAL_MERGE_2 = {bar: {hoo: 2}, baz: 2, moo: {a: 3}};
|
||||
const VAL_MERGE_EXPECT = {foo: 1, bar: {hoo: 2, boo: 1}, baz: 2, moo: {a: 3}};
|
||||
var KEY_1 = 'key_1';
|
||||
var VAL_1 = 'val_1';
|
||||
var KEY_2 = 'key_2';
|
||||
var VAL_2 = 'val_2';
|
||||
var KEY_MERGE = 'key_merge';
|
||||
var VAL_MERGE_1 = {'foo': 1, 'bar': {'hoo': 1, 'boo': 1}, 'moo': {'a': 3}};
|
||||
var VAL_MERGE_2 = {'bar': {'hoo': 2}, 'baz': 2, 'moo': {'a': 3}};
|
||||
var VAL_MERGE_EXPECT =
|
||||
{'foo': 1, 'bar': {'hoo': 2, 'boo': 1}, 'baz': 2, 'moo': {'a': 3}};
|
||||
|
||||
// setup in componentDidMount
|
||||
let done = (result: ?boolean) => {};
|
||||
let updateMessage = (message: string) => {};
|
||||
var done = (result : ?boolean) => {};
|
||||
var updateMessage = (message : string ) => {};
|
||||
|
||||
function runTestCase(description: string, fn) {
|
||||
function runTestCase(description : string, fn) {
|
||||
updateMessage(description);
|
||||
fn();
|
||||
}
|
||||
|
||||
function expectTrue(condition: boolean, message: string) {
|
||||
function expectTrue(condition : boolean, message : string) {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
// Type-safe wrapper around JSON.stringify
|
||||
function stringify(
|
||||
value:
|
||||
| void
|
||||
| null
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| {...}
|
||||
| $ReadOnlyArray<mixed>,
|
||||
): string {
|
||||
if (typeof value === 'undefined') {
|
||||
return 'undefined';
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function expectEqual(lhs, rhs, testname: string) {
|
||||
function expectEqual(lhs, rhs, testname : string) {
|
||||
expectTrue(
|
||||
!deepDiffer(lhs, rhs),
|
||||
'Error in test ' +
|
||||
testname +
|
||||
': expected\n' +
|
||||
stringify(rhs) +
|
||||
'\ngot\n' +
|
||||
stringify(lhs),
|
||||
'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) +
|
||||
'\ngot\n' + JSON.stringify(lhs)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,19 +61,16 @@ function expectAsyncNoError(place, err) {
|
||||
if (err instanceof Error) {
|
||||
err = err.message;
|
||||
}
|
||||
expectTrue(
|
||||
err === null,
|
||||
'Unexpected error in ' + place + ': ' + stringify(err),
|
||||
);
|
||||
expectTrue(err === null, 'Unexpected error in ' + place + ': ' + JSON.stringify(err));
|
||||
}
|
||||
|
||||
function testSetAndGet() {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, err1 => {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, (err1) => {
|
||||
expectAsyncNoError('testSetAndGet/setItem', err1);
|
||||
AsyncStorage.getItem(KEY_1, (err2, result) => {
|
||||
expectAsyncNoError('testSetAndGet/getItem', err2);
|
||||
expectEqual(result, VAL_1, 'testSetAndGet setItem');
|
||||
updateMessage('get(key_1) correctly returned ' + String(result));
|
||||
updateMessage('get(key_1) correctly returned ' + result);
|
||||
runTestCase('should get null for missing key', testMissingGet);
|
||||
});
|
||||
});
|
||||
@@ -99,14 +80,14 @@ function testMissingGet() {
|
||||
AsyncStorage.getItem(KEY_2, (err, result) => {
|
||||
expectAsyncNoError('testMissingGet/setItem', err);
|
||||
expectEqual(result, null, 'testMissingGet');
|
||||
updateMessage('missing get(key_2) correctly returned ' + String(result));
|
||||
updateMessage('missing get(key_2) correctly returned ' + result);
|
||||
runTestCase('check set twice results in a single key', testSetTwice);
|
||||
});
|
||||
}
|
||||
|
||||
function testSetTwice() {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, () => {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, () => {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, ()=>{
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, ()=>{
|
||||
AsyncStorage.getItem(KEY_1, (err, result) => {
|
||||
expectAsyncNoError('testSetTwice/setItem', err);
|
||||
expectEqual(result, VAL_1, 'testSetTwice');
|
||||
@@ -118,17 +99,16 @@ function testSetTwice() {
|
||||
}
|
||||
|
||||
function testRemoveItem() {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, () => {
|
||||
AsyncStorage.setItem(KEY_2, VAL_2, () => {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, ()=>{
|
||||
AsyncStorage.setItem(KEY_2, VAL_2, ()=>{
|
||||
AsyncStorage.getAllKeys((err, result) => {
|
||||
expectAsyncNoError('testRemoveItem/getAllKeys', err);
|
||||
expectTrue(
|
||||
nullthrows(result).indexOf(KEY_1) >= 0 &&
|
||||
nullthrows(result).indexOf(KEY_2) >= 0,
|
||||
'Missing KEY_1 or KEY_2 in ' + '(' + nullthrows(result).join() + ')',
|
||||
result.indexOf(KEY_1) >= 0 && result.indexOf(KEY_2) >= 0,
|
||||
'Missing KEY_1 or KEY_2 in ' + '(' + result + ')'
|
||||
);
|
||||
updateMessage('testRemoveItem - add two items');
|
||||
AsyncStorage.removeItem(KEY_1, err2 => {
|
||||
AsyncStorage.removeItem(KEY_1, (err2) => {
|
||||
expectAsyncNoError('testRemoveItem/removeItem', err2);
|
||||
updateMessage('delete successful ');
|
||||
AsyncStorage.getItem(KEY_1, (err3, result2) => {
|
||||
@@ -136,17 +116,17 @@ function testRemoveItem() {
|
||||
expectEqual(
|
||||
result2,
|
||||
null,
|
||||
'testRemoveItem: key_1 present after delete',
|
||||
'testRemoveItem: key_1 present after delete'
|
||||
);
|
||||
updateMessage('key properly removed ');
|
||||
AsyncStorage.getAllKeys((err4, result3) => {
|
||||
expectAsyncNoError('testRemoveItem/getAllKeys', err4);
|
||||
expectTrue(
|
||||
nullthrows(result3).indexOf(KEY_1) === -1,
|
||||
'Unexpected: KEY_1 present in ' + nullthrows(result3).join(),
|
||||
);
|
||||
updateMessage('proper length returned.');
|
||||
runTestCase('should merge values', testMerge);
|
||||
expectAsyncNoError('testRemoveItem/getAllKeys', err4);
|
||||
expectTrue(
|
||||
result3.indexOf(KEY_1) === -1,
|
||||
'Unexpected: KEY_1 present in ' + result3
|
||||
);
|
||||
updateMessage('proper length returned.');
|
||||
runTestCase('should merge values', testMerge);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -156,17 +136,13 @@ function testRemoveItem() {
|
||||
}
|
||||
|
||||
function testMerge() {
|
||||
AsyncStorage.setItem(KEY_MERGE, stringify(VAL_MERGE_1), err1 => {
|
||||
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), (err1) => {
|
||||
expectAsyncNoError('testMerge/setItem', err1);
|
||||
AsyncStorage.mergeItem(KEY_MERGE, stringify(VAL_MERGE_2), err2 => {
|
||||
AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), (err2) => {
|
||||
expectAsyncNoError('testMerge/mergeItem', err2);
|
||||
AsyncStorage.getItem(KEY_MERGE, (err3, result) => {
|
||||
expectAsyncNoError('testMerge/setItem', err3);
|
||||
expectEqual(
|
||||
JSON.parse(nullthrows(result)),
|
||||
VAL_MERGE_EXPECT,
|
||||
'testMerge',
|
||||
);
|
||||
expectEqual(JSON.parse(result), VAL_MERGE_EXPECT, 'testMerge');
|
||||
updateMessage('objects deeply merged\nDone!');
|
||||
runTestCase('multi set and get', testOptimizedMultiGet);
|
||||
});
|
||||
@@ -175,54 +151,45 @@ function testMerge() {
|
||||
}
|
||||
|
||||
function testOptimizedMultiGet() {
|
||||
let batch = [
|
||||
[KEY_1, VAL_1],
|
||||
[KEY_2, VAL_2],
|
||||
];
|
||||
let batch = [[KEY_1, VAL_1], [KEY_2, VAL_2]];
|
||||
let keys = batch.map(([key, value]) => key);
|
||||
AsyncStorage.multiSet(batch, err1 => {
|
||||
AsyncStorage.multiSet(batch, (err1) => {
|
||||
// yes, twice on purpose
|
||||
[1, 2].forEach(i => {
|
||||
;[1, 2].forEach((i) => {
|
||||
expectAsyncNoError(`${i} testOptimizedMultiGet/multiSet`, err1);
|
||||
AsyncStorage.multiGet(keys, (err2, result) => {
|
||||
expectAsyncNoError(`${i} testOptimizedMultiGet/multiGet`, err2);
|
||||
expectEqual(result, batch, `${i} testOptimizedMultiGet multiGet`);
|
||||
updateMessage(
|
||||
'multiGet([key_1, key_2]) correctly returned ' + stringify(result),
|
||||
);
|
||||
updateMessage('multiGet([key_1, key_2]) correctly returned ' + JSON.stringify(result));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
|
||||
state: any | {|done: boolean, messages: string|} = {
|
||||
|
||||
class AsyncStorageTest extends React.Component {
|
||||
state = {
|
||||
messages: 'Initializing...',
|
||||
done: false,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
done = () =>
|
||||
this.setState({done: true}, () => {
|
||||
TestModule.markTestCompleted();
|
||||
});
|
||||
updateMessage = msg => {
|
||||
done = () => this.setState({done: true}, () => {
|
||||
TestModule.markTestCompleted();
|
||||
});
|
||||
updateMessage = (msg) => {
|
||||
this.setState({messages: this.state.messages.concat('\n' + msg)});
|
||||
DEBUG && console.log(msg);
|
||||
};
|
||||
AsyncStorage.clear(testSetAndGet);
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{/* $FlowFixMe[incompatible-type] (>=0.54.0 site=react_native_fb,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.
|
||||
*/
|
||||
this.constructor.displayName + ': '}
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
{'\n\n' + this.state.messages}
|
||||
</Text>
|
||||
@@ -231,13 +198,6 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 40,
|
||||
},
|
||||
});
|
||||
|
||||
AsyncStorageTest.displayName = 'AsyncStorageTest';
|
||||
|
||||
module.exports = AsyncStorageTest;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
load("@fbsource//tools/build_defs:js_glob.bzl", "js_glob")
|
||||
load("@fbsource//tools/build_defs/oss:metro_defs.bzl", "rn_library")
|
||||
|
||||
# This file was generated by running
|
||||
# js1 build buckfiles
|
||||
|
||||
rn_library(
|
||||
name = "IntegrationTests",
|
||||
srcs = js_glob(
|
||||
[
|
||||
"**/*",
|
||||
],
|
||||
excludes = [
|
||||
"**/__*__/**",
|
||||
"**/*.command",
|
||||
"**/*.md",
|
||||
"websocket_integration_test_server.js",
|
||||
],
|
||||
),
|
||||
labels = ["supermodule:xplat/default/public.react_native.tests"],
|
||||
skip_processors = True,
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
"//xplat/js:node_modules__invariant",
|
||||
"//xplat/js:node_modules__nullthrows",
|
||||
"//xplat/js/RKJSModules/vendor/react:react",
|
||||
"//xplat/js/react-native-github:react-native",
|
||||
"//xplat/js/react-native-github/packages/assets:assets",
|
||||
],
|
||||
)
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {ExtendedError} from 'react-native/Libraries/Core/ExtendedError';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');
|
||||
const {View} = ReactNative;
|
||||
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
|
||||
class GlobalEvalWithSourceUrlTest extends React.Component<{...}> {
|
||||
componentDidMount() {
|
||||
if (typeof global.globalEvalWithSourceUrl !== 'function') {
|
||||
throw new Error(
|
||||
'Expected to find globalEvalWithSourceUrl function on global object but found ' +
|
||||
typeof global.globalEvalWithSourceUrl,
|
||||
);
|
||||
}
|
||||
const value = global.globalEvalWithSourceUrl('42');
|
||||
if (value !== 42) {
|
||||
throw new Error(
|
||||
'Expected globalEvalWithSourceUrl(expression) to return a value',
|
||||
);
|
||||
}
|
||||
let syntaxError: ?ExtendedError;
|
||||
try {
|
||||
global.globalEvalWithSourceUrl('{');
|
||||
} catch (e) {
|
||||
syntaxError = e;
|
||||
}
|
||||
if (!syntaxError) {
|
||||
throw new Error(
|
||||
'Expected globalEvalWithSourceUrl to throw on a syntax error',
|
||||
);
|
||||
}
|
||||
// Hermes throws an Error instead of a SyntaxError
|
||||
// https://github.com/facebook/hermes/issues/400
|
||||
if (
|
||||
syntaxError.jsEngine !== 'hermes' &&
|
||||
!(syntaxError instanceof SyntaxError)
|
||||
) {
|
||||
throw new Error(
|
||||
'Expected globalEvalWithSourceUrl to throw SyntaxError on a syntax error',
|
||||
);
|
||||
}
|
||||
const url = 'http://example.com/foo.js';
|
||||
let error;
|
||||
try {
|
||||
global.globalEvalWithSourceUrl('throw new Error()', url);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (!error) {
|
||||
throw new Error(
|
||||
'Expected globalEvalWithSourceUrl to throw an Error object',
|
||||
);
|
||||
}
|
||||
const parsedStack = parseErrorStack(error?.stack);
|
||||
if (parsedStack[0].file !== url) {
|
||||
throw new Error(
|
||||
`Expected first eval stack frame to be in ${url} but found ${String(
|
||||
parsedStack[0].file,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
TestModule.markTestCompleted();
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
return <View />;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalEvalWithSourceUrlTest.displayName = 'GlobalEvalWithSourceUrlTest';
|
||||
|
||||
module.exports = GlobalEvalWithSourceUrlTest;
|
||||
@@ -1,19 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow
|
||||
* @providesModule ImageCachePolicyTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {Image, View, Text, StyleSheet} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
Image,
|
||||
View,
|
||||
Text,
|
||||
StyleSheet,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
/*
|
||||
* The reload and force-cache tests don't actually verify that the complete functionality.
|
||||
@@ -27,26 +33,22 @@ const {TestModule} = ReactNative.NativeModules;
|
||||
|
||||
const TESTS = ['only-if-cached', 'default', 'reload', 'force-cache'];
|
||||
|
||||
type Props = {...};
|
||||
type Props = {}
|
||||
type State = {
|
||||
'only-if-cached'?: boolean,
|
||||
default?: boolean,
|
||||
reload?: boolean,
|
||||
'default'?: boolean,
|
||||
'reload'?: boolean,
|
||||
'force-cache'?: boolean,
|
||||
...
|
||||
};
|
||||
}
|
||||
|
||||
class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
state: $FlowFixMe | {...} = {};
|
||||
class ImageCachePolicyTest extends React.Component {
|
||||
state = {}
|
||||
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State): boolean {
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State) {
|
||||
const results: Array<?boolean> = TESTS.map(x => nextState[x]);
|
||||
|
||||
if (!results.includes(undefined)) {
|
||||
const result: boolean = results.reduce(
|
||||
(x, y) => (x === y) === true,
|
||||
true,
|
||||
);
|
||||
const result: boolean = results.reduce((x,y) => x === y === true, true)
|
||||
TestModule.markTestPassed(result);
|
||||
}
|
||||
|
||||
@@ -57,50 +59,42 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
this.setState({[name]: pass});
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{flex: 1}}>
|
||||
<Text>Hello</Text>
|
||||
<Image
|
||||
source={{
|
||||
uri: 'https://facebook.github.io/react/img/logo_small_2x.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'only-if-cached'
|
||||
}}
|
||||
onLoad={() => this.testComplete('only-if-cached', false)}
|
||||
onError={() => this.testComplete('only-if-cached', true)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://raw.githubusercontent.com/facebook/react-native/HEAD/Libraries/NewAppScreen/components/logo.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'only-if-cached',
|
||||
}}
|
||||
onLoad={() => this.testComplete('only-if-cached', false)}
|
||||
onError={() => this.testComplete('only-if-cached', true)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://raw.githubusercontent.com/facebook/react-native/HEAD/Libraries/NewAppScreen/components/logo.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'default',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react/img/logo_small_2x.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'default'
|
||||
}}
|
||||
onLoad={() => this.testComplete('default', true)}
|
||||
onError={() => this.testComplete('default', false)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://raw.githubusercontent.com/facebook/react-native/HEAD/Libraries/NewAppScreen/components/logo.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'reload',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react/img/logo_small_2x.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'reload'
|
||||
}}
|
||||
onLoad={() => this.testComplete('reload', true)}
|
||||
onError={() => this.testComplete('reload', false)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://raw.githubusercontent.com/facebook/react-native/HEAD/Libraries/NewAppScreen/components/logo.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'force-cache',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react/img/logo_small_2x.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'force-cache'
|
||||
}}
|
||||
onLoad={() => this.testComplete('force-cache', true)}
|
||||
onError={() => this.testComplete('force-cache', false)}
|
||||
style={styles.base}
|
||||
@@ -111,9 +105,6 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
base: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
|
||||
@@ -1,38 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow
|
||||
* @providesModule ImageSnapshotTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {Image} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
Image,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
class ImageSnapshotTest extends React.Component<{...}> {
|
||||
class ImageSnapshotTest extends React.Component {
|
||||
componentDidMount() {
|
||||
if (!TestModule.verifySnapshot) {
|
||||
throw new Error('TestModule.verifySnapshot not defined.');
|
||||
}
|
||||
}
|
||||
|
||||
done: (success: boolean) => void = (success: boolean) => {
|
||||
done = (success : boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<Image
|
||||
source={require('./blue_square.png')}
|
||||
defaultSource={require('./red_square.png')}
|
||||
onLoad={() => TestModule.verifySnapshot(this.done)}
|
||||
/>
|
||||
onLoad={() => TestModule.verifySnapshot(this.done)} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule IntegrationTestHarnessTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
var requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
||||
var React = require('react');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
Text,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const {Text, View, StyleSheet} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
class IntegrationTestHarnessTest extends React.Component {
|
||||
props: {
|
||||
shouldThrow?: boolean,
|
||||
waitOneFrame?: boolean,
|
||||
};
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
shouldThrow?: boolean,
|
||||
waitOneFrame?: boolean,
|
||||
|}>;
|
||||
static propTypes = {
|
||||
shouldThrow: PropTypes.bool,
|
||||
waitOneFrame: PropTypes.bool,
|
||||
};
|
||||
|
||||
type State = {|
|
||||
done: boolean,
|
||||
|};
|
||||
|
||||
class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
state: State = {
|
||||
state = {
|
||||
done: false,
|
||||
};
|
||||
|
||||
@@ -38,7 +44,7 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
runTest: () => void = () => {
|
||||
runTest = () => {
|
||||
if (this.props.shouldThrow) {
|
||||
throw new Error('Throwing error because shouldThrow');
|
||||
}
|
||||
@@ -52,15 +58,11 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
});
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{/* $FlowFixMe[incompatible-type] (>=0.54.0 site=react_native_fb,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.
|
||||
*/
|
||||
this.constructor.displayName + ': '}
|
||||
{this.constructor.displayName + ': '}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -68,13 +70,6 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 40,
|
||||
},
|
||||
});
|
||||
|
||||
IntegrationTestHarnessTest.displayName = 'IntegrationTestHarnessTest';
|
||||
|
||||
module.exports = IntegrationTestHarnessTest;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule IntegrationTestsApp
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
require('react-native/Libraries/Core/InitializeCore');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
@@ -23,7 +23,7 @@ const {
|
||||
} = ReactNative;
|
||||
|
||||
// Keep this list in sync with RNTesterIntegrationTests.m
|
||||
const TESTS = [
|
||||
var TESTS = [
|
||||
require('./IntegrationTestHarnessTest'),
|
||||
require('./TimersTest'),
|
||||
require('./AsyncStorageTest'),
|
||||
@@ -36,22 +36,18 @@ const TESTS = [
|
||||
require('./SyncMethodTest'),
|
||||
require('./WebSocketTest'),
|
||||
require('./AccessibilityManagerTest'),
|
||||
require('./GlobalEvalWithSourceUrlTest'),
|
||||
];
|
||||
|
||||
TESTS.forEach(
|
||||
/* $FlowFixMe[incompatible-call] (>=0.54.0 site=react_native_fb,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. */
|
||||
test => AppRegistry.registerComponent(test.displayName, () => test),
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test)
|
||||
);
|
||||
|
||||
// Modules required for integration tests
|
||||
require('./LoggingTestModule');
|
||||
require('LoggingTestModule');
|
||||
|
||||
type Test = any;
|
||||
|
||||
class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
|
||||
class IntegrationTestsApp extends React.Component {
|
||||
state = {
|
||||
test: (null: ?Test),
|
||||
};
|
||||
@@ -60,10 +56,6 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
|
||||
if (this.state.test) {
|
||||
return (
|
||||
<ScrollView>
|
||||
{/* $FlowFixMe[type-as-value] (>=0.53.0 site=react_native_fb,react_
|
||||
* native_oss) This comment suppresses an error when upgrading
|
||||
* Flow's support for React. To see the error delete this comment
|
||||
* and run Flow. */}
|
||||
<this.state.test />
|
||||
</ScrollView>
|
||||
);
|
||||
@@ -72,22 +64,20 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.row}>
|
||||
Click on a test to run it in this shell for easier debugging and
|
||||
development. Run all tests in the testing environment with cmd+U in
|
||||
development. Run all tests in the testing environment with cmd+U in
|
||||
Xcode.
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map(test => [
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
/* $FlowFixMe[incompatible-type] (>=0.115.0 site=react_native_fb)
|
||||
* This comment suppresses an error found when Flow v0.115 was
|
||||
* deployed. To see the error, delete this comment and run Flow.
|
||||
*/
|
||||
style={styles.row}>
|
||||
<Text style={styles.testName}>{test.displayName}</Text>
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
</ScrollView>
|
||||
</View>
|
||||
@@ -95,7 +85,7 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
marginTop: 40,
|
||||
|
||||
@@ -1,34 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @providesModule LayoutEventsTest
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {Image, LayoutAnimation, StyleSheet, Text, View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var createReactClass = require('create-react-class');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
Image,
|
||||
LayoutAnimation,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
||||
|
||||
const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer');
|
||||
var deepDiffer = require('deepDiffer');
|
||||
|
||||
function debug(...args) {
|
||||
// console.log.apply(null, arguments);
|
||||
}
|
||||
|
||||
import type {
|
||||
Layout,
|
||||
LayoutEvent,
|
||||
} from 'react-native/Libraries/Types/CoreEventTypes';
|
||||
|
||||
type Props = $ReadOnly<{||}>;
|
||||
type Layout = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
type LayoutEvent = {
|
||||
nativeEvent: {
|
||||
layout: Layout;
|
||||
};
|
||||
};
|
||||
type Style = {
|
||||
margin?: number,
|
||||
padding?: number,
|
||||
borderColor?: string,
|
||||
borderWidth?: number,
|
||||
backgroundColor?: string,
|
||||
width?: number,
|
||||
};
|
||||
|
||||
type State = {
|
||||
didAnimation: boolean,
|
||||
@@ -36,59 +55,48 @@ type State = {
|
||||
imageLayout?: Layout,
|
||||
textLayout?: Layout,
|
||||
viewLayout?: Layout,
|
||||
viewStyle?: ViewStyleProp,
|
||||
containerStyle?: ViewStyleProp,
|
||||
...
|
||||
viewStyle?: Style,
|
||||
containerStyle?: Style,
|
||||
};
|
||||
|
||||
class LayoutEventsTest extends React.Component<Props, State> {
|
||||
_view: ?React.ElementRef<typeof View>;
|
||||
_img: ?React.ElementRef<typeof Image>;
|
||||
_txt: ?React.ElementRef<typeof Text>;
|
||||
|
||||
state: State = {
|
||||
didAnimation: false,
|
||||
};
|
||||
|
||||
animateViewLayout() {
|
||||
var LayoutEventsTest = createReactClass({
|
||||
displayName: 'LayoutEventsTest',
|
||||
getInitialState(): State {
|
||||
return {
|
||||
didAnimation: false,
|
||||
};
|
||||
},
|
||||
animateViewLayout: function() {
|
||||
debug('animateViewLayout invoked');
|
||||
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring, () => {
|
||||
debug('animateViewLayout done');
|
||||
this.checkLayout(this.addWrapText);
|
||||
});
|
||||
LayoutAnimation.configureNext(
|
||||
LayoutAnimation.Presets.spring,
|
||||
() => {
|
||||
debug('animateViewLayout done');
|
||||
this.checkLayout(this.addWrapText);
|
||||
}
|
||||
);
|
||||
this.setState({viewStyle: {margin: 60}});
|
||||
}
|
||||
|
||||
addWrapText: () => void = () => {
|
||||
},
|
||||
addWrapText: function() {
|
||||
debug('addWrapText invoked');
|
||||
this.setState(
|
||||
{extraText: ' And a bunch more text to wrap around a few lines.'},
|
||||
() => this.checkLayout(this.changeContainer),
|
||||
() => this.checkLayout(this.changeContainer)
|
||||
);
|
||||
};
|
||||
|
||||
changeContainer: () => void = () => {
|
||||
},
|
||||
changeContainer: function() {
|
||||
debug('changeContainer invoked');
|
||||
this.setState({containerStyle: {width: 280}}, () =>
|
||||
this.checkLayout(TestModule.markTestCompleted),
|
||||
this.setState(
|
||||
{containerStyle: {width: 280}},
|
||||
() => this.checkLayout(TestModule.markTestCompleted)
|
||||
);
|
||||
};
|
||||
|
||||
checkLayout: (next?: ?() => void) => void = (next?: ?() => void) => {
|
||||
const view = this._view;
|
||||
const txt = this._txt;
|
||||
const img = this._img;
|
||||
|
||||
if (view == null || txt == null || img == null) {
|
||||
},
|
||||
checkLayout: function(next?: ?Function) {
|
||||
if (!this.isMounted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
view.measure((x, y, width, height) => {
|
||||
this.compare(
|
||||
'view',
|
||||
{x, y, width, height},
|
||||
this.state.viewLayout || null,
|
||||
);
|
||||
this.refs.view.measure((x, y, width, height) => {
|
||||
this.compare('view', {x, y, width, height}, this.state.viewLayout);
|
||||
if (typeof next === 'function') {
|
||||
next();
|
||||
} else if (!this.state.didAnimation) {
|
||||
@@ -97,69 +105,49 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
||||
this.state.didAnimation = true;
|
||||
}
|
||||
});
|
||||
|
||||
txt.measure((x, y, width, height) => {
|
||||
this.refs.txt.measure((x, y, width, height) => {
|
||||
this.compare('txt', {x, y, width, height}, this.state.textLayout);
|
||||
});
|
||||
|
||||
img.measure((x, y, width, height) => {
|
||||
this.refs.img.measure((x, y, width, height) => {
|
||||
this.compare('img', {x, y, width, height}, this.state.imageLayout);
|
||||
});
|
||||
};
|
||||
|
||||
compare(node: string, measured: Layout, onLayout?: ?Layout): void {
|
||||
},
|
||||
compare: function(node: string, measured: any, onLayout: any): void {
|
||||
if (deepDiffer(measured, onLayout)) {
|
||||
const data = {measured, onLayout};
|
||||
var data = {measured, onLayout};
|
||||
throw new Error(
|
||||
node +
|
||||
' onLayout mismatch with measure ' +
|
||||
JSON.stringify(data, null, ' '),
|
||||
node + ' onLayout mismatch with measure ' +
|
||||
JSON.stringify(data, null, ' ')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onViewLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => {
|
||||
},
|
||||
onViewLayout: function(e: LayoutEvent) {
|
||||
debug('received view layout event\n', e.nativeEvent);
|
||||
this.setState({viewLayout: e.nativeEvent.layout}, this.checkLayout);
|
||||
};
|
||||
|
||||
onTextLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => {
|
||||
},
|
||||
onTextLayout: function(e: LayoutEvent) {
|
||||
debug('received text layout event\n', e.nativeEvent);
|
||||
this.setState({textLayout: e.nativeEvent.layout}, this.checkLayout);
|
||||
};
|
||||
|
||||
onImageLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => {
|
||||
},
|
||||
onImageLayout: function(e: LayoutEvent) {
|
||||
debug('received image layout event\n', e.nativeEvent);
|
||||
this.setState({imageLayout: e.nativeEvent.layout}, this.checkLayout);
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
const viewStyle = [styles.view, this.state.viewStyle];
|
||||
const textLayout = this.state.textLayout || {width: '?', height: '?'};
|
||||
const imageLayout = this.state.imageLayout || {x: '?', y: '?'};
|
||||
},
|
||||
render: function() {
|
||||
var viewStyle = [styles.view, this.state.viewStyle];
|
||||
var textLayout = this.state.textLayout || {width: '?', height: '?'};
|
||||
var imageLayout = this.state.imageLayout || {x: '?', y: '?'};
|
||||
debug('viewLayout', this.state.viewLayout);
|
||||
return (
|
||||
<View style={[styles.container, this.state.containerStyle]}>
|
||||
<View
|
||||
ref={ref => {
|
||||
this._view = ref;
|
||||
}}
|
||||
onLayout={this.onViewLayout}
|
||||
style={viewStyle}>
|
||||
<View ref="view" onLayout={this.onViewLayout} style={viewStyle}>
|
||||
<Image
|
||||
ref={ref => {
|
||||
this._img = ref;
|
||||
}}
|
||||
ref="img"
|
||||
onLayout={this.onImageLayout}
|
||||
style={styles.image}
|
||||
source={{uri: 'uie_thumb_big.png'}}
|
||||
/>
|
||||
<Text
|
||||
ref={ref => {
|
||||
this._txt = ref;
|
||||
}}
|
||||
onLayout={this.onTextLayout}
|
||||
style={styles.text}>
|
||||
<Text ref="txt" onLayout={this.onTextLayout} style={styles.text}>
|
||||
A simple piece of text.{this.state.extraText}
|
||||
</Text>
|
||||
<Text>
|
||||
@@ -171,9 +159,9 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
margin: 40,
|
||||
},
|
||||
@@ -198,4 +186,5 @@ const styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
LayoutEventsTest.displayName = 'LayoutEventsTest';
|
||||
|
||||
module.exports = LayoutEventsTest;
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @providesModule LoggingTestModule
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');
|
||||
var BatchedBridge = require('BatchedBridge');
|
||||
|
||||
const invariant = require('invariant');
|
||||
var warning = require('fbjs/lib/warning');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
const LoggingTestModule = {
|
||||
var LoggingTestModule = {
|
||||
logToConsole: function(str) {
|
||||
console.log(str);
|
||||
},
|
||||
logToConsoleAfterWait: function(str, timeout_ms) {
|
||||
logToConsoleAfterWait: function(str,timeout_ms) {
|
||||
setTimeout(function() {
|
||||
console.log(str);
|
||||
}, timeout_ms);
|
||||
},
|
||||
warning: function(str) {
|
||||
console.warn(str);
|
||||
warning(false, str);
|
||||
},
|
||||
invariant: function(str) {
|
||||
invariant(false, str);
|
||||
@@ -33,9 +35,12 @@ const LoggingTestModule = {
|
||||
},
|
||||
throwError: function(str) {
|
||||
throw new Error(str);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
BatchedBridge.registerCallableModule('LoggingTestModule', LoggingTestModule);
|
||||
BatchedBridge.registerCallableModule(
|
||||
'LoggingTestModule',
|
||||
LoggingTestModule
|
||||
);
|
||||
|
||||
module.exports = LoggingTestModule;
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule PromiseTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var { View } = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
class PromiseTest extends React.Component<{...}> {
|
||||
shouldResolve: boolean = false;
|
||||
shouldReject: boolean = false;
|
||||
shouldSucceedAsync: boolean = false;
|
||||
shouldThrowAsync: boolean = false;
|
||||
class PromiseTest extends React.Component {
|
||||
shouldResolve = false;
|
||||
shouldReject = false;
|
||||
shouldSucceedAsync = false;
|
||||
shouldThrowAsync = false;
|
||||
|
||||
componentDidMount() {
|
||||
Promise.all([
|
||||
@@ -27,29 +28,27 @@ class PromiseTest extends React.Component<{...}> {
|
||||
this.testShouldReject(),
|
||||
this.testShouldSucceedAsync(),
|
||||
this.testShouldThrowAsync(),
|
||||
]).then(() =>
|
||||
TestModule.markTestPassed(
|
||||
this.shouldResolve &&
|
||||
this.shouldReject &&
|
||||
this.shouldSucceedAsync &&
|
||||
this.shouldThrowAsync,
|
||||
),
|
||||
);
|
||||
]).then(() => TestModule.markTestPassed(
|
||||
this.shouldResolve && this.shouldReject &&
|
||||
this.shouldSucceedAsync && this.shouldThrowAsync
|
||||
));
|
||||
}
|
||||
|
||||
testShouldResolve: () => any = () => {
|
||||
return TestModule.shouldResolve()
|
||||
.then(() => (this.shouldResolve = true))
|
||||
.catch(() => (this.shouldResolve = false));
|
||||
testShouldResolve = () => {
|
||||
return TestModule
|
||||
.shouldResolve()
|
||||
.then(() => this.shouldResolve = true)
|
||||
.catch(() => this.shouldResolve = false);
|
||||
};
|
||||
|
||||
testShouldReject: () => any = () => {
|
||||
return TestModule.shouldReject()
|
||||
.then(() => (this.shouldReject = false))
|
||||
.catch(() => (this.shouldReject = true));
|
||||
testShouldReject = () => {
|
||||
return TestModule
|
||||
.shouldReject()
|
||||
.then(() => this.shouldReject = false)
|
||||
.catch(() => this.shouldReject = true);
|
||||
};
|
||||
|
||||
testShouldSucceedAsync: () => Promise<any> = async (): Promise<any> => {
|
||||
testShouldSucceedAsync = async (): Promise<any> => {
|
||||
try {
|
||||
await TestModule.shouldResolve();
|
||||
this.shouldSucceedAsync = true;
|
||||
@@ -58,7 +57,7 @@ class PromiseTest extends React.Component<{...}> {
|
||||
}
|
||||
};
|
||||
|
||||
testShouldThrowAsync: () => Promise<any> = async (): Promise<any> => {
|
||||
testShouldThrowAsync = async (): Promise<any> => {
|
||||
try {
|
||||
await TestModule.shouldReject();
|
||||
this.shouldThrowAsync = false;
|
||||
@@ -67,7 +66,7 @@ class PromiseTest extends React.Component<{...}> {
|
||||
}
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
render(): React.Element<any> {
|
||||
return <View />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* 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 PropertiesUpdateTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
View,
|
||||
} = ReactNative;
|
||||
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
class PropertiesUpdateTest extends React.Component {
|
||||
render() {
|
||||
if (this.props.markTestPassed) {
|
||||
TestModule.markTestPassed(true);
|
||||
}
|
||||
return <View />;
|
||||
return (
|
||||
<View/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @providesModule RCTRootViewIntegrationTestApp
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
require('regenerator-runtime/runtime');
|
||||
|
||||
const {
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
|
||||
var {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
@@ -22,14 +25,14 @@ const {
|
||||
} = ReactNative;
|
||||
|
||||
/* Keep this list in sync with RCTRootViewIntegrationTests.m */
|
||||
const TESTS = [
|
||||
var TESTS = [
|
||||
require('./PropertiesUpdateTest'),
|
||||
require('./ReactContentSizeUpdateTest'),
|
||||
require('./SizeFlexibilityUpdateTest'),
|
||||
];
|
||||
|
||||
TESTS.forEach(test =>
|
||||
AppRegistry.registerComponent(test.displayName, () => test),
|
||||
TESTS.forEach(
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test)
|
||||
);
|
||||
|
||||
class RCTRootViewIntegrationTestApp extends React.Component {
|
||||
@@ -49,18 +52,20 @@ class RCTRootViewIntegrationTestApp extends React.Component {
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.row}>
|
||||
Click on a test to run it in this shell for easier debugging and
|
||||
development. Run all tests in the testing environment with cmd+U in
|
||||
development. Run all tests in the testing environment with cmd+U in
|
||||
Xcode.
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map(test => [
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
style={styles.row}>
|
||||
<Text style={styles.testName}>{test.displayName}</Text>
|
||||
<Text style={styles.testName}>
|
||||
{test.displayName}
|
||||
</Text>
|
||||
</TouchableOpacity>,
|
||||
<View style={styles.separator} />,
|
||||
<View style={styles.separator} />
|
||||
])}
|
||||
</ScrollView>
|
||||
</View>
|
||||
@@ -68,7 +73,7 @@ class RCTRootViewIntegrationTestApp extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
marginTop: 40,
|
||||
@@ -86,7 +91,4 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent(
|
||||
'RCTRootViewIntegrationTestApp',
|
||||
() => RCTRootViewIntegrationTestApp,
|
||||
);
|
||||
AppRegistry.registerComponent('RCTRootViewIntegrationTestApp', () => RCTRootViewIntegrationTestApp);
|
||||
|
||||
@@ -1,89 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* 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 ReactContentSizeUpdateTest
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
var React = require('react');
|
||||
var createReactClass = require('create-react-class');
|
||||
var ReactNative = require('react-native');
|
||||
var RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
|
||||
var Subscribable = require('Subscribable');
|
||||
var TimerMixin = require('react-timer-mixin');
|
||||
|
||||
const {View} = ReactNative;
|
||||
var { View } = ReactNative;
|
||||
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
import {type EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const reactViewWidth = 101;
|
||||
const reactViewHeight = 102;
|
||||
const newReactViewWidth = 201;
|
||||
const newReactViewHeight = 202;
|
||||
var reactViewWidth = 101;
|
||||
var reactViewHeight = 102;
|
||||
var newReactViewWidth = 201;
|
||||
var newReactViewHeight = 202;
|
||||
|
||||
type Props = {||};
|
||||
var ReactContentSizeUpdateTest = createReactClass({
|
||||
displayName: 'ReactContentSizeUpdateTest',
|
||||
mixins: [Subscribable.Mixin,
|
||||
TimerMixin],
|
||||
|
||||
type State = {|
|
||||
height: number,
|
||||
width: number,
|
||||
|};
|
||||
|
||||
class ReactContentSizeUpdateTest extends React.Component<Props, State> {
|
||||
_timeoutID: ?TimeoutID = null;
|
||||
_subscription: ?EventSubscription = null;
|
||||
|
||||
state: State = {
|
||||
height: reactViewHeight,
|
||||
width: reactViewWidth,
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
this._subscription = RCTNativeAppEventEmitter.addListener(
|
||||
componentWillMount: function() {
|
||||
this.addListenerOn(
|
||||
RCTNativeAppEventEmitter,
|
||||
'rootViewDidChangeIntrinsicSize',
|
||||
this.rootViewDidChangeIntrinsicSize,
|
||||
this.rootViewDidChangeIntrinsicSize
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this._timeoutID = setTimeout(() => {
|
||||
this.updateViewSize();
|
||||
}, 1000);
|
||||
}
|
||||
getInitialState: function() {
|
||||
return {
|
||||
height: reactViewHeight,
|
||||
width: reactViewWidth,
|
||||
};
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._timeoutID != null) {
|
||||
clearTimeout(this._timeoutID);
|
||||
}
|
||||
|
||||
if (this._subscription != null) {
|
||||
this._subscription.remove();
|
||||
}
|
||||
}
|
||||
|
||||
updateViewSize() {
|
||||
updateViewSize: function() {
|
||||
this.setState({
|
||||
height: newReactViewHeight,
|
||||
width: newReactViewWidth,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
rootViewDidChangeIntrinsicSize: (intrinsicSize: State) => void = (
|
||||
intrinsicSize: State,
|
||||
) => {
|
||||
if (
|
||||
intrinsicSize.height === newReactViewHeight &&
|
||||
intrinsicSize.width === newReactViewWidth
|
||||
) {
|
||||
componentDidMount: function() {
|
||||
this.setTimeout(
|
||||
() => { this.updateViewSize(); },
|
||||
1000
|
||||
);
|
||||
},
|
||||
|
||||
rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
|
||||
if (intrinsicSize.height === newReactViewHeight && intrinsicSize.width === newReactViewWidth) {
|
||||
TestModule.markTestPassed(true);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={{height: this.state.height, width: this.state.width}} />
|
||||
<View style={{'height':this.state.height, 'width':this.state.width}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ReactContentSizeUpdateTest.displayName = 'ReactContentSizeUpdateTest';
|
||||
|
||||
module.exports = ReactContentSizeUpdateTest;
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow
|
||||
* @providesModule SimpleSnapshotTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
||||
|
||||
const {StyleSheet, View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var {
|
||||
StyleSheet,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
class SimpleSnapshotTest extends React.Component<{...}> {
|
||||
class SimpleSnapshotTest extends React.Component {
|
||||
componentDidMount() {
|
||||
if (!TestModule.verifySnapshot) {
|
||||
throw new Error('TestModule.verifySnapshot not defined.');
|
||||
@@ -24,13 +29,13 @@ class SimpleSnapshotTest extends React.Component<{...}> {
|
||||
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
||||
}
|
||||
|
||||
done: (success: boolean) => void = (success: boolean) => {
|
||||
done = (success : boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 100}}>
|
||||
<View style={styles.box1} />
|
||||
<View style={styles.box2} />
|
||||
</View>
|
||||
@@ -38,11 +43,7 @@ class SimpleSnapshotTest extends React.Component<{...}> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 100,
|
||||
},
|
||||
var styles = StyleSheet.create({
|
||||
box1: {
|
||||
width: 80,
|
||||
height: 50,
|
||||
|
||||
@@ -1,59 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* 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 SizeFlexibilityUpdateTest
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
var React = require('react');
|
||||
var createReactClass = require('create-react-class');
|
||||
var ReactNative = require('react-native');
|
||||
var RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
|
||||
var Subscribable = require('Subscribable');
|
||||
var { View } = ReactNative;
|
||||
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
import {type EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const reactViewWidth = 111;
|
||||
const reactViewHeight = 222;
|
||||
var reactViewWidth = 111;
|
||||
var reactViewHeight = 222;
|
||||
|
||||
let finalState = false;
|
||||
var finalState = false;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
width: boolean,
|
||||
height: boolean,
|
||||
both: boolean,
|
||||
none: boolean,
|
||||
|}>;
|
||||
var SizeFlexibilityUpdateTest = createReactClass({
|
||||
displayName: 'SizeFlexibilityUpdateTest',
|
||||
mixins: [Subscribable.Mixin],
|
||||
|
||||
class SizeFlexibilityUpdateTest extends React.Component<Props> {
|
||||
_subscription: ?EventSubscription = null;
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
this._subscription = RCTNativeAppEventEmitter.addListener(
|
||||
componentWillMount: function() {
|
||||
this.addListenerOn(
|
||||
RCTNativeAppEventEmitter,
|
||||
'rootViewDidChangeIntrinsicSize',
|
||||
this.rootViewDidChangeIntrinsicSize,
|
||||
this.rootViewDidChangeIntrinsicSize
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._subscription != null) {
|
||||
this._subscription.remove();
|
||||
}
|
||||
}
|
||||
|
||||
markPassed: () => void = () => {
|
||||
markPassed: function() {
|
||||
TestModule.markTestPassed(true);
|
||||
finalState = true;
|
||||
};
|
||||
},
|
||||
|
||||
rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
|
||||
|
||||
rootViewDidChangeIntrinsicSize: (intrinsicSize: {
|
||||
height: number,
|
||||
width: number,
|
||||
...
|
||||
}) => void = (intrinsicSize: {width: number, height: number, ...}) => {
|
||||
if (finalState) {
|
||||
// If a test reaches its final state, it is not expected to do anything more
|
||||
TestModule.markTestPassed(false);
|
||||
@@ -61,46 +49,38 @@ class SizeFlexibilityUpdateTest extends React.Component<Props> {
|
||||
}
|
||||
|
||||
if (this.props.both) {
|
||||
if (
|
||||
intrinsicSize.width === reactViewWidth &&
|
||||
intrinsicSize.height === reactViewHeight
|
||||
) {
|
||||
if (intrinsicSize.width === reactViewWidth && intrinsicSize.height === reactViewHeight) {
|
||||
this.markPassed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.props.height) {
|
||||
if (
|
||||
intrinsicSize.width !== reactViewWidth &&
|
||||
intrinsicSize.height === reactViewHeight
|
||||
) {
|
||||
if (intrinsicSize.width !== reactViewWidth && intrinsicSize.height === reactViewHeight) {
|
||||
this.markPassed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.props.width) {
|
||||
if (
|
||||
intrinsicSize.width === reactViewWidth &&
|
||||
intrinsicSize.height !== reactViewHeight
|
||||
) {
|
||||
if (intrinsicSize.width === reactViewWidth && intrinsicSize.height !== reactViewHeight) {
|
||||
this.markPassed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.props.none) {
|
||||
if (
|
||||
intrinsicSize.width !== reactViewWidth &&
|
||||
intrinsicSize.height !== reactViewHeight
|
||||
) {
|
||||
if (intrinsicSize.width !== reactViewWidth && intrinsicSize.height !== reactViewHeight) {
|
||||
this.markPassed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
render(): React.Node {
|
||||
return <View style={{height: reactViewHeight, width: reactViewWidth}} />;
|
||||
render() {
|
||||
return (
|
||||
<View style={{'height':reactViewHeight, 'width':reactViewWidth}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SizeFlexibilityUpdateTest.displayName = 'SizeFlexibilityUpdateTest';
|
||||
|
||||
module.exports = SizeFlexibilityUpdateTest;
|
||||
|
||||
@@ -1,49 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow
|
||||
* @providesModule SyncMethodTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var { View } = ReactNative;
|
||||
|
||||
const {TestModule, RNTesterTestModule} = ReactNative.NativeModules;
|
||||
const {
|
||||
TestModule,
|
||||
RNTesterTestModule,
|
||||
} = ReactNative.NativeModules;
|
||||
|
||||
class SyncMethodTest extends React.Component<{...}> {
|
||||
|
||||
class SyncMethodTest extends React.Component {
|
||||
componentDidMount() {
|
||||
if (
|
||||
RNTesterTestModule.echoString('test string value') !== 'test string value'
|
||||
) {
|
||||
throw new Error('Something wrong with echoString sync method');
|
||||
if (RNTesterTestModule.echoString('test string value') !== 'test string value') {
|
||||
throw new Error('Something wrong with sync method export');
|
||||
}
|
||||
if (RNTesterTestModule.methodThatReturnsNil() != null) {
|
||||
throw new Error('Something wrong with methodThatReturnsNil sync method');
|
||||
throw new Error('Something wrong with sync method export');
|
||||
}
|
||||
let response;
|
||||
RNTesterTestModule.methodThatCallsCallbackWithString('test', echo => {
|
||||
response = echo;
|
||||
});
|
||||
requestAnimationFrame(() => {
|
||||
if (response === 'test') {
|
||||
TestModule.markTestCompleted();
|
||||
} else {
|
||||
throw new Error(
|
||||
'Something wrong with methodThatCallsCallbackWithString sync method, ' +
|
||||
'got response ' +
|
||||
JSON.stringify(response),
|
||||
);
|
||||
}
|
||||
});
|
||||
TestModule.markTestCompleted();
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render(): React.Element<any> {
|
||||
return <View />;
|
||||
}
|
||||
}
|
||||
|
||||
+68
-184
@@ -1,280 +1,163 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule TimersTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {StyleSheet, Text, View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var createReactClass = require('create-react-class');
|
||||
var ReactNative = require('react-native');
|
||||
var TimerMixin = require('react-timer-mixin');
|
||||
|
||||
type Props = $ReadOnly<{||}>;
|
||||
var {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
type State = {|
|
||||
count: number,
|
||||
done: boolean,
|
||||
|};
|
||||
var TimersTest = createReactClass({
|
||||
displayName: 'TimersTest',
|
||||
mixins: [TimerMixin],
|
||||
|
||||
type ImmediateID = Object;
|
||||
_nextTest: () => {},
|
||||
_interval: -1,
|
||||
|
||||
class TimersTest extends React.Component<Props, State> {
|
||||
_nextTest = () => {};
|
||||
_interval: ?IntervalID = null;
|
||||
|
||||
_timeoutIDs: Set<TimeoutID> = new Set();
|
||||
_intervalIDs: Set<IntervalID> = new Set();
|
||||
_immediateIDs: Set<ImmediateID> = new Set();
|
||||
_animationFrameIDs: Set<AnimationFrameID> = new Set();
|
||||
|
||||
state: State = {
|
||||
count: 0,
|
||||
done: false,
|
||||
};
|
||||
|
||||
setTimeout(fn: () => void, time: number): TimeoutID {
|
||||
const id = setTimeout(() => {
|
||||
this._timeoutIDs.delete(id);
|
||||
fn();
|
||||
}, time);
|
||||
|
||||
this._timeoutIDs.add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
clearTimeout(id: TimeoutID) {
|
||||
this._timeoutIDs.delete(id);
|
||||
clearTimeout(id);
|
||||
}
|
||||
|
||||
setInterval(fn: () => void, time: number): IntervalID {
|
||||
const id = setInterval(() => {
|
||||
fn();
|
||||
}, time);
|
||||
|
||||
this._intervalIDs.add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
clearInterval(id: IntervalID) {
|
||||
this._intervalIDs.delete(id);
|
||||
clearInterval(id);
|
||||
}
|
||||
|
||||
setImmediate(fn: () => void): ImmediateID {
|
||||
const id = setImmediate(() => {
|
||||
this._immediateIDs.delete(id);
|
||||
fn();
|
||||
});
|
||||
|
||||
this._immediateIDs.add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
requestAnimationFrame(fn: () => void): AnimationFrameID {
|
||||
const id = requestAnimationFrame(() => {
|
||||
this._animationFrameIDs.delete(id);
|
||||
fn();
|
||||
});
|
||||
|
||||
this._animationFrameIDs.add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
cancelAnimationFrame(id: AnimationFrameID): void {
|
||||
this._animationFrameIDs.delete(id);
|
||||
cancelAnimationFrame(id);
|
||||
}
|
||||
getInitialState() {
|
||||
return {
|
||||
count: 0,
|
||||
done: false,
|
||||
};
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testSetTimeout0, 1000);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout0() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testSetTimeout1, 0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout1() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testSetTimeout50, 1);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout50() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testRequestAnimationFrame, 50);
|
||||
}
|
||||
},
|
||||
|
||||
testRequestAnimationFrame() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.requestAnimationFrame(this.testSetInterval0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetInterval0() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this._nextTest = this.testSetInterval20;
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this._interval = this.setInterval(this._incrementInterval, 0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetInterval20() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this._nextTest = this.testSetImmediate;
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this._interval = this.setInterval(this._incrementInterval, 20);
|
||||
}
|
||||
},
|
||||
|
||||
testSetImmediate() {
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setImmediate(this.testClearTimeout0);
|
||||
}
|
||||
},
|
||||
|
||||
testClearTimeout0() {
|
||||
const timeout = this.setTimeout(() => this._fail('testClearTimeout0'), 0);
|
||||
var timeout = this.setTimeout(() => this._fail('testClearTimeout0'), 0);
|
||||
this.clearTimeout(timeout);
|
||||
this.testClearTimeout30();
|
||||
}
|
||||
},
|
||||
|
||||
testClearTimeout30() {
|
||||
const timeout = this.setTimeout(() => this._fail('testClearTimeout30'), 30);
|
||||
var timeout = this.setTimeout(() => this._fail('testClearTimeout30'), 30);
|
||||
this.clearTimeout(timeout);
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testClearMulti, 50);
|
||||
}
|
||||
},
|
||||
|
||||
testClearMulti() {
|
||||
const fails = [];
|
||||
var fails = [];
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-1'), 20));
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-2'), 50));
|
||||
const delayClear = this.setTimeout(
|
||||
() => this._fail('testClearMulti-3'),
|
||||
50,
|
||||
);
|
||||
var delayClear = this.setTimeout(() => this._fail('testClearMulti-3'), 50);
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-4'), 0));
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-5'), 10));
|
||||
|
||||
fails.forEach(timeout => this.clearTimeout(timeout));
|
||||
fails.forEach((timeout) => this.clearTimeout(timeout));
|
||||
this.setTimeout(() => this.clearTimeout(delayClear), 20);
|
||||
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.testOrdering, 50);
|
||||
}
|
||||
},
|
||||
|
||||
testOrdering() {
|
||||
// Clear timers are set first because it's more likely to uncover bugs.
|
||||
let fail0;
|
||||
var fail0;
|
||||
this.setImmediate(() => this.clearTimeout(fail0));
|
||||
fail0 = this.setTimeout(
|
||||
() =>
|
||||
this._fail(
|
||||
'testOrdering-t0, setImmediate should happen before ' +
|
||||
'setTimeout 0',
|
||||
),
|
||||
0,
|
||||
() => this._fail('testOrdering-t0, setImmediate should happen before ' +
|
||||
'setTimeout 0'),
|
||||
0
|
||||
);
|
||||
let failAnim; // This should fail without the t=0 fastpath feature.
|
||||
var failAnim; // This should fail without the t=0 fastpath feature.
|
||||
this.setTimeout(() => this.cancelAnimationFrame(failAnim), 0);
|
||||
failAnim = this.requestAnimationFrame(() =>
|
||||
this._fail(
|
||||
'testOrdering-Anim, setTimeout 0 should happen before ' +
|
||||
'requestAnimationFrame',
|
||||
),
|
||||
failAnim = this.requestAnimationFrame(
|
||||
() => this._fail('testOrdering-Anim, setTimeout 0 should happen before ' +
|
||||
'requestAnimationFrame')
|
||||
);
|
||||
let fail25;
|
||||
this.setTimeout(() => {
|
||||
this.clearTimeout(fail25);
|
||||
}, 20);
|
||||
var fail25;
|
||||
this.setTimeout(() => { this.clearTimeout(fail25); }, 20);
|
||||
fail25 = this.setTimeout(
|
||||
() =>
|
||||
this._fail(
|
||||
'testOrdering-t25, setTimeout 20 should happen before ' +
|
||||
'setTimeout 25',
|
||||
),
|
||||
25,
|
||||
() => this._fail('testOrdering-t25, setTimeout 20 should happen before ' +
|
||||
'setTimeout 25'),
|
||||
25
|
||||
);
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.setTimeout(this.done, 50);
|
||||
}
|
||||
},
|
||||
|
||||
done() {
|
||||
this.setState({done: true}, () => {
|
||||
TestModule.markTestCompleted();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
for (const timeoutID of this._timeoutIDs) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
for (const intervalID of this._intervalIDs) {
|
||||
clearInterval(intervalID);
|
||||
}
|
||||
|
||||
for (const requestAnimationFrameID of this._animationFrameIDs) {
|
||||
cancelAnimationFrame(requestAnimationFrameID);
|
||||
}
|
||||
|
||||
for (const immediateID of this._immediateIDs) {
|
||||
clearImmediate(immediateID);
|
||||
}
|
||||
|
||||
this._timeoutIDs = new Set();
|
||||
this._intervalIDs = new Set();
|
||||
this._animationFrameIDs = new Set();
|
||||
this._immediateIDs = new Set();
|
||||
|
||||
if (this._interval != null) {
|
||||
clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>
|
||||
{this.constructor.name + ': \n'}
|
||||
{this.constructor.displayName + ': \n'}
|
||||
Intervals: {this.state.count + '\n'}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_incrementInterval() {
|
||||
if (this.state.count > 3) {
|
||||
throw new Error('interval incremented past end.');
|
||||
}
|
||||
if (this.state.count === 3) {
|
||||
if (this._interval != null) {
|
||||
this.clearInterval(this._interval);
|
||||
this._interval = null;
|
||||
}
|
||||
// $FlowFixMe[method-unbinding]
|
||||
this.clearInterval(this._interval);
|
||||
this.setState({count: 0}, this._nextTest);
|
||||
return;
|
||||
}
|
||||
this.setState({count: this.state.count + 1});
|
||||
}
|
||||
},
|
||||
|
||||
_fail(caller: string): void {
|
||||
_fail(caller : string) : void {
|
||||
throw new Error('_fail called by ' + caller);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 40,
|
||||
@@ -282,4 +165,5 @@ const styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
TimersTest.displayName = 'TimersTest';
|
||||
|
||||
module.exports = TimersTest;
|
||||
|
||||
@@ -1,37 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @providesModule WebSocketTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var { View } = ReactNative;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
const DEFAULT_WS_URL = 'ws://localhost:5555/';
|
||||
|
||||
const WS_EVENTS = ['close', 'error', 'message', 'open'];
|
||||
const WS_EVENTS = [
|
||||
'close',
|
||||
'error',
|
||||
'message',
|
||||
'open',
|
||||
];
|
||||
const WS_STATES = [
|
||||
/* 0 */ 'CONNECTING',
|
||||
/* 1 */ 'OPEN',
|
||||
/* 2 */ 'CLOSING',
|
||||
/* 3 */ 'CLOSED',
|
||||
];
|
||||
|
||||
type State = {
|
||||
url: string,
|
||||
fetchStatus: ?string,
|
||||
socket: ?WebSocket,
|
||||
socketState: ?number,
|
||||
lastSocketEvent: ?string,
|
||||
lastMessage: ?string | ?ArrayBuffer,
|
||||
testMessage: string,
|
||||
testExpectedResponse: string,
|
||||
...
|
||||
url: string;
|
||||
fetchStatus: ?string;
|
||||
socket: ?WebSocket;
|
||||
socketState: ?number;
|
||||
lastSocketEvent: ?string;
|
||||
lastMessage: ?string | ?ArrayBuffer;
|
||||
testMessage: string;
|
||||
testExpectedResponse: string;
|
||||
};
|
||||
|
||||
class WebSocketTest extends React.Component<{...}, State> {
|
||||
class WebSocketTest extends React.Component {
|
||||
state: State = {
|
||||
url: DEFAULT_WS_URL,
|
||||
fetchStatus: null,
|
||||
@@ -40,12 +51,13 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
lastSocketEvent: null,
|
||||
lastMessage: null,
|
||||
testMessage: 'testMessage',
|
||||
testExpectedResponse: 'testMessage_response',
|
||||
testExpectedResponse: 'testMessage_response'
|
||||
};
|
||||
|
||||
_waitFor = (condition: any, timeout: any, callback: any) => {
|
||||
let remaining = timeout;
|
||||
const timeoutFunction = function() {
|
||||
var remaining = timeout;
|
||||
var t;
|
||||
var timeoutFunction = function() {
|
||||
if (condition()) {
|
||||
callback(true);
|
||||
return;
|
||||
@@ -54,11 +66,11 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
if (remaining === 0) {
|
||||
callback(false);
|
||||
} else {
|
||||
setTimeout(timeoutFunction, 1000);
|
||||
t = setTimeout(timeoutFunction,1000);
|
||||
}
|
||||
};
|
||||
setTimeout(timeoutFunction, 1000);
|
||||
};
|
||||
t = setTimeout(timeoutFunction,1000);
|
||||
}
|
||||
|
||||
_connect = () => {
|
||||
const socket = new WebSocket(this.state.url);
|
||||
@@ -71,11 +83,11 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
_socketIsConnected = () => {
|
||||
return this.state.socketState === 1; //'OPEN'
|
||||
};
|
||||
}
|
||||
|
||||
_socketIsDisconnected = () => {
|
||||
return this.state.socketState === 3; //'CLOSED'
|
||||
};
|
||||
}
|
||||
|
||||
_disconnect = () => {
|
||||
if (!this.state.socket) {
|
||||
@@ -107,43 +119,46 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
};
|
||||
|
||||
_receivedTestExpectedResponse = () => {
|
||||
return this.state.lastMessage === this.state.testExpectedResponse;
|
||||
return (this.state.lastMessage === this.state.testExpectedResponse);
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.testConnect();
|
||||
}
|
||||
|
||||
testConnect: () => void = () => {
|
||||
this._connect();
|
||||
this._waitFor(this._socketIsConnected, 5, connectSucceeded => {
|
||||
testConnect = () => {
|
||||
var component = this;
|
||||
component._connect();
|
||||
component._waitFor(component._socketIsConnected, 5, function(connectSucceeded) {
|
||||
if (!connectSucceeded) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
}
|
||||
this.testSendAndReceive();
|
||||
component.testSendAndReceive();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
testSendAndReceive: () => void = () => {
|
||||
this._sendTestMessage();
|
||||
this._waitFor(this._receivedTestExpectedResponse, 5, messageReceived => {
|
||||
testSendAndReceive = () => {
|
||||
var component = this;
|
||||
component._sendTestMessage();
|
||||
component._waitFor(component._receivedTestExpectedResponse, 5, function(messageReceived) {
|
||||
if (!messageReceived) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
}
|
||||
this.testDisconnect();
|
||||
component.testDisconnect();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
testDisconnect: () => void = () => {
|
||||
this._disconnect();
|
||||
this._waitFor(this._socketIsDisconnected, 5, disconnectSucceeded => {
|
||||
testDisconnect = () => {
|
||||
var component = this;
|
||||
component._disconnect();
|
||||
component._waitFor(component._socketIsDisconnected, 5, function(disconnectSucceeded) {
|
||||
TestModule.markTestPassed(disconnectSucceeded);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
render(): React.Element<any> {
|
||||
return <View />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
# Copyright (c) 2015-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
# 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.
|
||||
|
||||
# Set terminal title
|
||||
echo -en "\033]0;Web Socket Test Server\a"
|
||||
clear
|
||||
|
||||
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
|
||||
THIS_DIR=$(dirname "$0")
|
||||
pushd "$THIS_DIR"
|
||||
./websocket_integration_test_server.js
|
||||
popd
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
* @providesModule websocket_integration_test_server
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/* eslint-env node */
|
||||
@@ -24,13 +26,14 @@ An incoming message of 'exit' will shut down the server.
|
||||
`);
|
||||
|
||||
const server = new WebSocket.Server({port: 5555});
|
||||
server.on('connection', ws => {
|
||||
ws.on('message', message => {
|
||||
server.on('connection', (ws) => {
|
||||
ws.on('message', (message) => {
|
||||
console.log('Received message:', message);
|
||||
if (message === 'exit') {
|
||||
console.log('WebSocket integration test server exit');
|
||||
process.exit(0);
|
||||
}
|
||||
console.log('Cookie:', ws.upgradeReq.headers.cookie);
|
||||
ws.send(message + '_response');
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "JSContextRef.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void nativeProfilerEnableBytecode(void);
|
||||
void nativeProfilerStart(JSContextRef ctx, const char *title);
|
||||
void nativeProfilerEnd(JSContextRef ctx, const char *title, const char *filename);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
#include "JSCLegacyProfiler.h"
|
||||
|
||||
#include "APICast.h"
|
||||
#include "LegacyProfiler.h"
|
||||
#include "OpaqueJSString.h"
|
||||
#include "JSProfilerPrivate.h"
|
||||
#include "JSStringRef.h"
|
||||
#include "String.h"
|
||||
#include "Options.h"
|
||||
|
||||
enum json_gen_status {
|
||||
json_gen_status_ok = 0,
|
||||
json_gen_status_error = 1,
|
||||
};
|
||||
|
||||
enum json_entry {
|
||||
json_entry_key,
|
||||
json_entry_value,
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
struct json_state {
|
||||
FILE *fileOut;
|
||||
bool hasFirst;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
typedef json_state *json_gen;
|
||||
|
||||
static void json_escaped_cstring_printf(json_gen gen, const char *str) {
|
||||
const char *cursor = str;
|
||||
fputc('"', gen->fileOut);
|
||||
while (*cursor) {
|
||||
const char *escape = nullptr;
|
||||
switch (*cursor) {
|
||||
case '"':
|
||||
escape = "\\\"";
|
||||
break;
|
||||
case '\b':
|
||||
escape = "\\b";
|
||||
break;
|
||||
case '\f':
|
||||
escape = "\\f";
|
||||
break;
|
||||
case '\n':
|
||||
escape = "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
escape = "\\r";
|
||||
break;
|
||||
case '\t':
|
||||
escape = "\\t";
|
||||
break;
|
||||
case '\\':
|
||||
escape = "\\\\";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (escape != nullptr) {
|
||||
fwrite(escape, 1, strlen(escape), gen->fileOut);
|
||||
} else {
|
||||
fputc(*cursor, gen->fileOut);
|
||||
}
|
||||
cursor++;
|
||||
}
|
||||
fputc('"', gen->fileOut);
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_key_cstring(json_gen gen, const char *buffer) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
gen->hasFirst = true;
|
||||
|
||||
json_escaped_cstring_printf(gen, buffer);
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_map_open(json_gen gen, json_entry entryType) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (entryType == json_entry_value) {
|
||||
fprintf(gen->fileOut, ":");
|
||||
} else if (entryType == json_entry_key) {
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
}
|
||||
fprintf(gen->fileOut, "{");
|
||||
gen->hasFirst = false;
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_map_close(json_gen gen) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
fprintf(gen->fileOut, "}");
|
||||
gen->hasFirst = true;
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_array_open(json_gen gen, json_entry entryType) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (entryType == json_entry_value) {
|
||||
fprintf(gen->fileOut, ":");
|
||||
} else if (entryType == json_entry_key) {
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
}
|
||||
fprintf(gen->fileOut, "[");
|
||||
gen->hasFirst = false;
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_array_close(json_gen gen) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
fprintf(gen->fileOut, "]");
|
||||
gen->hasFirst = true;
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_keyvalue_cstring(json_gen gen, const char *key, const char *value) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
gen->hasFirst = true;
|
||||
|
||||
fprintf(gen->fileOut, "\"%s\" : ", key);
|
||||
json_escaped_cstring_printf(gen, value);
|
||||
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
|
||||
static json_gen_status json_gen_keyvalue_integer(json_gen gen, const char *key, int value) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
gen->hasFirst = true;
|
||||
|
||||
fprintf(gen->fileOut, "\"%s\": %d", key, value);
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status json_gen_keyvalue_double(json_gen gen, const char *key, double value) {
|
||||
if (gen->fileOut == nullptr) {
|
||||
return json_gen_status_error;
|
||||
}
|
||||
|
||||
if (gen->hasFirst) {
|
||||
fprintf(gen->fileOut, ",");
|
||||
}
|
||||
gen->hasFirst = true;
|
||||
|
||||
fprintf(gen->fileOut, "\"%s\": %.20g", key, value);
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen json_gen_alloc(const char *fileName) {
|
||||
json_gen gen = (json_gen)malloc(sizeof(json_state));
|
||||
memset(gen, 0, sizeof(json_state));
|
||||
gen->fileOut = fopen(fileName, "wb");
|
||||
return gen;
|
||||
}
|
||||
|
||||
static void json_gen_free(json_gen gen) {
|
||||
if (gen->fileOut) {
|
||||
fclose(gen->fileOut);
|
||||
}
|
||||
free(gen);
|
||||
}
|
||||
|
||||
#define GEN_AND_CHECK(expr) \
|
||||
do { \
|
||||
json_gen_status GEN_AND_CHECK_status = (expr); \
|
||||
if (GEN_AND_CHECK_status != json_gen_status_ok) { \
|
||||
return GEN_AND_CHECK_status; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
|
||||
static json_gen_status append_children_array_json(json_gen gen, const JSC::ProfileNode *node);
|
||||
static json_gen_status append_node_json(json_gen gen, const JSC::ProfileNode *node);
|
||||
|
||||
static json_gen_status append_root_json(json_gen gen, const JSC::Profile *profile) {
|
||||
GEN_AND_CHECK(json_gen_map_open(gen, json_entry_key));
|
||||
GEN_AND_CHECK(json_gen_key_cstring(gen, "rootNodes"));
|
||||
#if IOS8
|
||||
GEN_AND_CHECK(append_children_array_json(gen, profile->head()));
|
||||
#else
|
||||
GEN_AND_CHECK(append_children_array_json(gen, profile->rootNode()));
|
||||
#endif
|
||||
GEN_AND_CHECK(json_gen_map_close(gen));
|
||||
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status append_children_array_json(json_gen gen, const JSC::ProfileNode *node) {
|
||||
GEN_AND_CHECK(json_gen_array_open(gen, json_entry_value));
|
||||
for (RefPtr<JSC::ProfileNode> child : node->children()) {
|
||||
GEN_AND_CHECK(append_node_json(gen, child.get()));
|
||||
}
|
||||
GEN_AND_CHECK(json_gen_array_close(gen));
|
||||
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static json_gen_status append_node_json(json_gen gen, const JSC::ProfileNode *node) {
|
||||
GEN_AND_CHECK(json_gen_map_open(gen, json_entry_key));
|
||||
GEN_AND_CHECK(json_gen_keyvalue_integer(gen, "id", node->id()));
|
||||
|
||||
if (!node->functionName().isEmpty()) {
|
||||
GEN_AND_CHECK(json_gen_keyvalue_cstring(gen, "functionName", node->functionName().utf8().data()));
|
||||
}
|
||||
|
||||
if (!node->url().isEmpty()) {
|
||||
GEN_AND_CHECK(json_gen_keyvalue_cstring(gen, "url", node->url().utf8().data()));
|
||||
GEN_AND_CHECK(json_gen_keyvalue_integer(gen, "lineNumber", node->lineNumber()));
|
||||
GEN_AND_CHECK(json_gen_keyvalue_integer(gen, "columnNumber", node->columnNumber()));
|
||||
}
|
||||
|
||||
GEN_AND_CHECK(json_gen_key_cstring(gen, "calls"));
|
||||
GEN_AND_CHECK(json_gen_array_open(gen, json_entry_value));
|
||||
for (const JSC::ProfileNode::Call &call : node->calls()) {
|
||||
GEN_AND_CHECK(json_gen_map_open(gen, json_entry_key));
|
||||
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "startTime", call.startTime()));
|
||||
#if IOS8
|
||||
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "totalTime", call.totalTime()));
|
||||
#else
|
||||
GEN_AND_CHECK(json_gen_keyvalue_double(gen, "totalTime", call.elapsedTime()));
|
||||
#endif
|
||||
GEN_AND_CHECK(json_gen_map_close(gen));
|
||||
}
|
||||
GEN_AND_CHECK(json_gen_array_close(gen));
|
||||
|
||||
if (!node->children().isEmpty()) {
|
||||
GEN_AND_CHECK(json_gen_key_cstring(gen, "children"));
|
||||
GEN_AND_CHECK(append_children_array_json(gen, node));
|
||||
}
|
||||
|
||||
GEN_AND_CHECK(json_gen_map_close(gen));
|
||||
|
||||
return json_gen_status_ok;
|
||||
}
|
||||
|
||||
static void convert_to_json(const JSC::Profile *profile, const char *filename) {
|
||||
json_gen_status status;
|
||||
json_gen gen = json_gen_alloc(filename);
|
||||
|
||||
status = append_root_json(gen, profile);
|
||||
if (status != json_gen_status_ok) {
|
||||
FILE *fileOut = fopen(filename, "wb");
|
||||
if (fileOut != nullptr) {
|
||||
fprintf(fileOut, "{\"error\": %d}", (int)status);
|
||||
fclose(fileOut);
|
||||
}
|
||||
}
|
||||
json_gen_free(gen);
|
||||
}
|
||||
|
||||
// Based on JSEndProfiling, with a little extra code to return the profile as JSON.
|
||||
static void JSEndProfilingAndRender(JSContextRef ctx, const char *title, const char *filename)
|
||||
{
|
||||
JSC::ExecState *exec = toJS(ctx);
|
||||
JSC::LegacyProfiler *profiler = JSC::LegacyProfiler::profiler();
|
||||
RefPtr<JSC::Profile> rawProfile = profiler->stopProfiling(exec, WTF::String(title));
|
||||
convert_to_json(rawProfile.get(), filename);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void nativeProfilerEnableBytecode(void)
|
||||
{
|
||||
JSC::Options::setOption("forceProfilerBytecodeGeneration=true");
|
||||
}
|
||||
|
||||
void nativeProfilerStart(JSContextRef ctx, const char *title) {
|
||||
JSStartProfiling(ctx, JSStringCreateWithUTF8CString(title));
|
||||
}
|
||||
|
||||
void nativeProfilerEnd(JSContextRef ctx, const char *title, const char *filename) {
|
||||
JSEndProfilingAndRender(ctx, title, filename);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
ios9:
|
||||
IOS_VERSION=9 \
|
||||
JSC_VERSION=7601.1.46.3 \
|
||||
WEB_CORE_VERSION=7601.1.46.10 \
|
||||
WTF_VERSION=7601.1.46.3 \
|
||||
make -f Makefile.base
|
||||
|
||||
ios8:
|
||||
IOS_VERSION=8 \
|
||||
JSC_VERSION=7600.1.17 \
|
||||
WEB_CORE_VERSION=7600.1.25 \
|
||||
WTF_VERSION=7600.1.24 \
|
||||
make -f Makefile.base
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(wildcard *.dylib)
|
||||
-rm -rf download
|
||||
@@ -0,0 +1,80 @@
|
||||
HEADER_PATHS := `find download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION) -name '*.h' | xargs -I{} dirname {} | uniq | xargs -I{} echo "-I {}"`
|
||||
|
||||
XCODE_PATH ?= $(shell xcode-select -p)
|
||||
SDK_PATH = $(XCODE_PATH)/Platforms/$1.platform/Developer/SDKs/$1.sdk
|
||||
SDK_VERSION = $(shell plutil -convert json -o - $(call SDK_PATH,iPhoneOS)/SDKSettings.plist | awk -f parseSDKVersion.awk)
|
||||
|
||||
CERT ?= iPhone Developer
|
||||
|
||||
ARCHS = x86_64 arm64 armv7 i386
|
||||
|
||||
PLATFORM = \
|
||||
if [[ "$*" = "x86_64" || "$*" = "i386" ]]; then \
|
||||
PLATFORM=iPhoneSimulator; \
|
||||
else \
|
||||
PLATFORM=iPhoneOS; \
|
||||
fi;
|
||||
|
||||
SYSROOT = -isysroot $(call SDK_PATH,$${PLATFORM})
|
||||
|
||||
IOS_LIBS = \
|
||||
download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION) \
|
||||
download/WebCore/WebCore-$(WEB_CORE_VERSION) \
|
||||
download/WTF/WTF-$(WTF_VERSION) \
|
||||
download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION)/Bytecodes.h
|
||||
|
||||
IOS_EXT=ios$(IOS_VERSION)
|
||||
|
||||
ifneq ($(SDK_VERSION), $(IOS_VERSION))
|
||||
|
||||
all:
|
||||
$(error "Expected to be compiled with iOS SDK version 8, found $(SDK_VERSION)")
|
||||
|
||||
else
|
||||
|
||||
all: RCTJSCProfiler.$(IOS_EXT).dylib /tmp/RCTJSCProfiler
|
||||
cp $^
|
||||
|
||||
endif
|
||||
|
||||
/tmp/RCTJSCProfiler:
|
||||
mkdir -p $@
|
||||
|
||||
RCTJSCProfiler.$(IOS_EXT).dylib: RCTJSCProfiler_unsigned.$(IOS_EXT).dylib
|
||||
cp $< $@
|
||||
codesign -f -s "${CERT}" $@
|
||||
|
||||
.PRECIOUS: RCTJSCProfiler_unsigned.$(IOS_EXT).dylib
|
||||
RCTJSCProfiler_unsigned.$(IOS_EXT).dylib: $(patsubst %,RCTJSCProfiler_%.$(IOS_EXT).dylib,$(ARCHS))
|
||||
lipo -create -output $@ $^
|
||||
|
||||
.PRECIOUS: RCTJSCProfiler_%.$(IOS_EXT).dylib
|
||||
RCTJSCProfiler_%.$(IOS_EXT).dylib: $(IOS_LIBS)
|
||||
$(PLATFORM) \
|
||||
clang -w -dynamiclib -o RCTJSCProfiler_$*.$(IOS_EXT).dylib -std=c++11 \
|
||||
-arch $* \
|
||||
-install_name RCTJSCProfiler.$(IOS_EXT).dylib \
|
||||
-include ./download/JavaScriptCore/JavaScriptCore-$(JSC_VERSION)/config.h \
|
||||
-I download \
|
||||
-I download/WebCore/WebCore-$(WEB_CORE_VERSION)/icu \
|
||||
-I download/WTF/WTF-$(WTF_VERSION) \
|
||||
-DNDEBUG=1 \
|
||||
-DIOS$(IOS_VERSION)=1 \
|
||||
-miphoneos-version-min=8.0 \
|
||||
$(SYSROOT) \
|
||||
$(HEADER_PATHS) \
|
||||
-undefined dynamic_lookup \
|
||||
JSCLegacyProfiler.mm
|
||||
|
||||
.PRECIOUS: %/Bytecodes.h
|
||||
%/Bytecodes.h:
|
||||
python $*/generate-bytecode-files --bytecodes_h $@ $*/bytecode/BytecodeList.json
|
||||
|
||||
.PRECIOUS: download/%
|
||||
download/%: download/%.tar.gz
|
||||
tar -zxvf $< -C `dirname $@` > /dev/null
|
||||
|
||||
.PRECIOUS: %.tar.gz
|
||||
%.tar.gz:
|
||||
mkdir -p `dirname $@`
|
||||
curl -o $@ http://www.opensource.apple.com/tarballs/$(patsubst download/%,%,$@)
|
||||
Executable
+254
@@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import smap
|
||||
import trace_data
|
||||
import urllib
|
||||
|
||||
SECONDS_TO_NANOSECONDS = (1000*1000)
|
||||
SAMPLE_DELTA_IN_SECONDS = 0.0001
|
||||
|
||||
class Marker(object):
|
||||
def __init__(self, _name, _timestamp, _depth, _is_end, _ident, url, line, col):
|
||||
self.name = _name
|
||||
self.timestamp = _timestamp
|
||||
self.depth = _depth
|
||||
self.is_end = _is_end
|
||||
self.ident = _ident
|
||||
self.url = url
|
||||
self.line = line
|
||||
self.col = col
|
||||
|
||||
# sort markers making sure they are ordered by timestamp then depth of function call
|
||||
# and finally that markers of the same ident are sorted in the order begin then end
|
||||
def __cmp__(self, other):
|
||||
if self.timestamp < other.timestamp:
|
||||
return -1
|
||||
if self.timestamp > other.timestamp:
|
||||
return 1
|
||||
if self.depth < other.depth:
|
||||
return -1
|
||||
if self.depth > other.depth:
|
||||
return 1
|
||||
if self.ident == other.ident:
|
||||
if self.is_end:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
# calculate marker name based on combination of function name and location
|
||||
def _calcname(entry):
|
||||
funcname = ""
|
||||
if "functionName" in entry:
|
||||
funcname = funcname + entry["functionName"]
|
||||
return funcname
|
||||
|
||||
def _calcurl(mapcache, entry, map_file):
|
||||
if entry.url not in mapcache:
|
||||
map_url = entry.url.replace('.bundle', '.map')
|
||||
|
||||
if map_url != entry.url:
|
||||
if map_file:
|
||||
print('Loading sourcemap from:' + map_file)
|
||||
map_url = map_file
|
||||
|
||||
try:
|
||||
url_file = urllib.urlopen(map_url)
|
||||
if url_file != None:
|
||||
entries = smap.parse(url_file)
|
||||
mapcache[entry.url] = entries
|
||||
except Exception, e:
|
||||
mapcache[entry.url] = []
|
||||
|
||||
if entry.url in mapcache:
|
||||
source_entry = smap.find(mapcache[entry.url], entry.line, entry.col)
|
||||
if source_entry:
|
||||
entry.url = 'file://' + source_entry.src
|
||||
entry.line = source_entry.src_line
|
||||
entry.col = source_entry.src_col
|
||||
|
||||
def _compute_markers(markers, call_point, depth):
|
||||
name = _calcname(call_point)
|
||||
ident = len(markers)
|
||||
url = ""
|
||||
lineNumber = -1
|
||||
columnNumber = -1
|
||||
if "url" in call_point:
|
||||
url = call_point["url"]
|
||||
if "lineNumber" in call_point:
|
||||
lineNumber = call_point["lineNumber"]
|
||||
if "columnNumber" in call_point:
|
||||
columnNumber = call_point["columnNumber"]
|
||||
|
||||
for call in call_point["calls"]:
|
||||
markers.append(Marker(name, call["startTime"], depth, 0, ident, url, lineNumber, columnNumber))
|
||||
markers.append(Marker(name, call["startTime"] + call["totalTime"], depth, 1, ident, url, lineNumber, columnNumber))
|
||||
ident = ident + 2
|
||||
if "children" in call_point:
|
||||
for child in call_point["children"]:
|
||||
_compute_markers(markers, child, depth+1);
|
||||
|
||||
def _find_child(children, name):
|
||||
for child in children:
|
||||
if child['functionName'] == name:
|
||||
return child
|
||||
return None
|
||||
|
||||
def _add_entry_cpuprofiler_program(newtime, cpuprofiler):
|
||||
curnode = _find_child(cpuprofiler['head']['children'], '(program)')
|
||||
if cpuprofiler['lastTime'] != None:
|
||||
lastTime = cpuprofiler['lastTime']
|
||||
while lastTime < newtime:
|
||||
curnode['hitCount'] += 1
|
||||
cpuprofiler['samples'].append(curnode['callUID'])
|
||||
cpuprofiler['timestamps'].append(int(lastTime*SECONDS_TO_NANOSECONDS))
|
||||
lastTime += SAMPLE_DELTA_IN_SECONDS
|
||||
cpuprofiler['lastTime'] = lastTime
|
||||
else:
|
||||
cpuprofiler['lastTime'] = newtime
|
||||
|
||||
|
||||
def _add_entry_cpuprofiler(stack, newtime, cpuprofiler):
|
||||
index = len(stack) - 1
|
||||
marker = stack[index]
|
||||
|
||||
if marker.name not in cpuprofiler['markers']:
|
||||
cpuprofiler['markers'][marker.name] = cpuprofiler['id']
|
||||
cpuprofiler['callUID'] += 1
|
||||
callUID = cpuprofiler['markers'][marker.name]
|
||||
|
||||
curnode = cpuprofiler['head']
|
||||
index = 0
|
||||
while index < len(stack):
|
||||
newnode = _find_child(curnode['children'], stack[index].name)
|
||||
if newnode == None:
|
||||
newnode = {}
|
||||
newnode['callUID'] = callUID
|
||||
newnode['url'] = marker.url
|
||||
newnode['functionName'] = stack[index].name
|
||||
newnode['hitCount'] = 0
|
||||
newnode['lineNumber'] = marker.line
|
||||
newnode['columnNumber'] = marker.col
|
||||
newnode['scriptId'] = callUID
|
||||
newnode['positionTicks'] = []
|
||||
newnode['id'] = cpuprofiler['id']
|
||||
cpuprofiler['id'] += 1
|
||||
newnode['children'] = []
|
||||
curnode['children'].append(newnode)
|
||||
curnode['deoptReason'] = ''
|
||||
curnode = newnode
|
||||
index += 1
|
||||
|
||||
if cpuprofiler['lastTime'] == None:
|
||||
cpuprofiler['lastTime'] = newtime
|
||||
|
||||
if cpuprofiler['lastTime'] != None:
|
||||
lastTime = cpuprofiler['lastTime']
|
||||
while lastTime < newtime:
|
||||
curnode['hitCount'] += 1
|
||||
if len(curnode['positionTicks']) == 0:
|
||||
ticks = {}
|
||||
ticks['line'] = curnode['callUID']
|
||||
ticks['ticks'] = 0
|
||||
curnode['positionTicks'].append(ticks)
|
||||
curnode['positionTicks'][0]['ticks'] += 1
|
||||
cpuprofiler['samples'].append(curnode['callUID'])
|
||||
cpuprofiler['timestamps'].append(int(lastTime*1000*1000))
|
||||
lastTime += 0.0001
|
||||
cpuprofiler['lastTime'] = lastTime
|
||||
|
||||
def _create_default_cpuprofiler_node(name, _id, _uid):
|
||||
return {'functionName': name,
|
||||
'scriptId':'0',
|
||||
'url':'',
|
||||
'lineNumber':0,
|
||||
'columnNumber':0,
|
||||
'positionTicks':[],
|
||||
'id':_id,
|
||||
'callUID':_uid,
|
||||
'children': [],
|
||||
'hitCount': 0,
|
||||
'deoptReason':''}
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Converts JSON profile format to fbsystrace text output")
|
||||
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
dest = "output_file",
|
||||
default = None,
|
||||
help = "Output file for trace data")
|
||||
parser.add_argument(
|
||||
"-cpuprofiler",
|
||||
dest = "output_cpuprofiler",
|
||||
default = None,
|
||||
help = "Output file for cpuprofiler data")
|
||||
parser.add_argument(
|
||||
"-map",
|
||||
dest = "map_file",
|
||||
default = None,
|
||||
help = "Map file for symbolicating")
|
||||
parser.add_argument( "file", help = "JSON trace input_file")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
markers = []
|
||||
with open(args.file, "r") as trace_file:
|
||||
trace = json.load(trace_file)
|
||||
for root_entry in trace["rootNodes"]:
|
||||
_compute_markers(markers, root_entry, 0)
|
||||
|
||||
mapcache = {}
|
||||
for m in markers:
|
||||
_calcurl(mapcache, m, args.map_file)
|
||||
|
||||
sorted_markers = list(sorted(markers));
|
||||
|
||||
if args.output_cpuprofiler != None:
|
||||
cpuprofiler = {}
|
||||
cpuprofiler['startTime'] = None
|
||||
cpuprofiler['endTime'] = None
|
||||
cpuprofiler['lastTime'] = None
|
||||
cpuprofiler['id'] = 4
|
||||
cpuprofiler['callUID'] = 4
|
||||
cpuprofiler['samples'] = []
|
||||
cpuprofiler['timestamps'] = []
|
||||
cpuprofiler['markers'] = {}
|
||||
cpuprofiler['head'] = _create_default_cpuprofiler_node('(root)', 1, 1)
|
||||
cpuprofiler['head']['children'].append(_create_default_cpuprofiler_node('(root)', 2, 2))
|
||||
cpuprofiler['head']['children'].append(_create_default_cpuprofiler_node('(program)', 3, 3))
|
||||
marker_stack = []
|
||||
with open(args.output_cpuprofiler, 'w') as file_out:
|
||||
for marker in sorted_markers:
|
||||
if len(marker_stack):
|
||||
_add_entry_cpuprofiler(marker_stack, marker.timestamp, cpuprofiler)
|
||||
else:
|
||||
_add_entry_cpuprofiler_program(marker.timestamp, cpuprofiler)
|
||||
if marker.is_end:
|
||||
marker_stack.pop()
|
||||
else:
|
||||
marker_stack.append(marker)
|
||||
cpuprofiler['startTime'] = cpuprofiler['timestamps'][0] / 1000000.0
|
||||
cpuprofiler['endTime'] = cpuprofiler['timestamps'][len(cpuprofiler['timestamps']) - 1] / 1000000.0
|
||||
json.dump(cpuprofiler, file_out, sort_keys=False, indent=4, separators=(',', ': '))
|
||||
|
||||
|
||||
if args.output_file != None:
|
||||
with open(args.output_file,"w") as trace_file:
|
||||
for marker in sorted_markers:
|
||||
start_or_end = None
|
||||
if marker.is_end:
|
||||
start_or_end = "E"
|
||||
else:
|
||||
start_or_end = "B"
|
||||
#output with timestamp at high level of precision
|
||||
trace_file.write("json-0 [000] .... {0:.12f}: tracing_mark_write: {1}|0|{2}\n".format(
|
||||
marker.timestamp,
|
||||
start_or_end,
|
||||
marker.name))
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,10 @@
|
||||
BEGIN {
|
||||
FS = ":"
|
||||
RS = ","
|
||||
}
|
||||
|
||||
/"Version"/ {
|
||||
version = substr($2, 2, length($2) - 2)
|
||||
print int(version)
|
||||
exit 0
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
"""
|
||||
adapted from https://github.com/martine/python-sourcemap into a reuasable module
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2010
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
"""A module for parsing source maps, as output by the Closure and
|
||||
CoffeeScript compilers and consumed by browsers. See
|
||||
http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
|
||||
"""
|
||||
|
||||
import collections
|
||||
import json
|
||||
import sys
|
||||
import bisect
|
||||
|
||||
class entry(object):
|
||||
def __init__(self, dst_line, dst_col, src, src_line, src_col):
|
||||
self.dst_line = dst_line
|
||||
self.dst_col = dst_col
|
||||
self.src = src
|
||||
self.src_line = src_line
|
||||
self.src_col = src_col
|
||||
|
||||
def __cmp__(self, other):
|
||||
#print(self)
|
||||
#print(other)
|
||||
if self.dst_line < other.dst_line:
|
||||
return -1
|
||||
if self.dst_line > other.dst_line:
|
||||
return 1
|
||||
if self.dst_col < other.dst_col:
|
||||
return -1
|
||||
if self.dst_col > other.dst_col:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
SmapState = collections.namedtuple(
|
||||
'SmapState', ['dst_line', 'dst_col',
|
||||
'src', 'src_line', 'src_col',
|
||||
'name'])
|
||||
|
||||
# Mapping of base64 letter -> integer value.
|
||||
B64 = dict((c, i) for i, c in
|
||||
enumerate('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||
'0123456789+/'))
|
||||
|
||||
|
||||
def _parse_vlq(segment):
|
||||
"""Parse a string of VLQ-encoded data.
|
||||
|
||||
Returns:
|
||||
a list of integers.
|
||||
"""
|
||||
|
||||
values = []
|
||||
|
||||
cur, shift = 0, 0
|
||||
for c in segment:
|
||||
val = B64[c]
|
||||
# Each character is 6 bits:
|
||||
# 5 of value and the high bit is the continuation.
|
||||
val, cont = val & 0b11111, val >> 5
|
||||
cur += val << shift
|
||||
shift += 5
|
||||
|
||||
if not cont:
|
||||
# The low bit of the unpacked value is the sign.
|
||||
cur, sign = cur >> 1, cur & 1
|
||||
if sign:
|
||||
cur = -cur
|
||||
values.append(cur)
|
||||
cur, shift = 0, 0
|
||||
|
||||
if cur or shift:
|
||||
raise Exception('leftover cur/shift in vlq decode')
|
||||
|
||||
return values
|
||||
|
||||
|
||||
def _parse_smap(file):
|
||||
"""Given a file-like object, yield SmapState()s as they are read from it."""
|
||||
|
||||
smap = json.load(file)
|
||||
sources = smap['sources']
|
||||
names = smap['names']
|
||||
mappings = smap['mappings']
|
||||
lines = mappings.split(';')
|
||||
|
||||
dst_col, src_id, src_line, src_col, name_id = 0, 0, 0, 0, 0
|
||||
for dst_line, line in enumerate(lines):
|
||||
segments = line.split(',')
|
||||
dst_col = 0
|
||||
for segment in segments:
|
||||
if not segment:
|
||||
continue
|
||||
parsed = _parse_vlq(segment)
|
||||
dst_col += parsed[0]
|
||||
|
||||
src = None
|
||||
name = None
|
||||
if len(parsed) > 1:
|
||||
src_id += parsed[1]
|
||||
src = sources[src_id]
|
||||
src_line += parsed[2]
|
||||
src_col += parsed[3]
|
||||
|
||||
if len(parsed) > 4:
|
||||
name_id += parsed[4]
|
||||
name = names[name_id]
|
||||
|
||||
assert dst_line >= 0
|
||||
assert dst_col >= 0
|
||||
assert src_line >= 0
|
||||
assert src_col >= 0
|
||||
|
||||
yield SmapState(dst_line, dst_col, src, src_line, src_col, name)
|
||||
|
||||
def find(entries, line, col):
|
||||
test = entry(line, col, '', 0, 0)
|
||||
index = bisect.bisect_right(entries, test)
|
||||
if index == 0:
|
||||
return None
|
||||
return entries[index - 1]
|
||||
|
||||
def parse(file):
|
||||
# Simple demo that shows files that most contribute to total size.
|
||||
lookup = []
|
||||
for state in _parse_smap(file):
|
||||
lookup.append(entry(state.dst_line, state.dst_col, state.src, state.src_line, state.src_col))
|
||||
|
||||
sorted_lookup = list(sorted(lookup))
|
||||
return sorted_lookup
|
||||
@@ -0,0 +1,244 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import unittest
|
||||
|
||||
"""
|
||||
# _-----=> irqs-off
|
||||
# / _----=> need-resched
|
||||
# | / _---=> hardirq/softirq
|
||||
# || / _--=> preempt-depth
|
||||
# ||| / delay
|
||||
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
|
||||
# | | | |||| | |
|
||||
<idle>-0 [001] ...2 3269.291072: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=mmcqd/0 next_pid=120 next_prio=120
|
||||
"""
|
||||
TRACE_LINE_PATTERN = re.compile(
|
||||
r'^\s*(?P<task>.+)-(?P<pid>\d+)\s+(?:\((?P<tgid>.+)\)\s+)?\[(?P<cpu>\d+)\]\s+(?:(?P<flags>\S{4})\s+)?(?P<timestamp>[0-9.]+):\s+(?P<function>.+)$')
|
||||
|
||||
"""
|
||||
Example lines from custom app traces:
|
||||
0: B|27295|providerRemove
|
||||
0: E
|
||||
tracing_mark_write: S|27311|NNFColdStart<D-7744962>|1112249168
|
||||
"""
|
||||
APP_TRACE_LINE_PATTERN = re.compile(
|
||||
r'^(?P<type>.+?): (?P<args>.+)$')
|
||||
|
||||
"""
|
||||
Example section names:
|
||||
NNFColdStart
|
||||
NNFColdStart<0><T7744962>
|
||||
NNFColdStart<X>
|
||||
NNFColdStart<T7744962>
|
||||
"""
|
||||
DECORATED_SECTION_NAME_PATTERN = re.compile(r'^(?P<section_name>.*?)(?:<0>)?(?:<(?P<command>.)(?P<argument>.*?)>)?$')
|
||||
|
||||
SYSTRACE_LINE_TYPES = set(['0', 'tracing_mark_write'])
|
||||
|
||||
class TraceLine(object):
|
||||
def __init__(self, task, pid, tgid, cpu, flags, timestamp, function):
|
||||
self.task = task
|
||||
self.pid = pid
|
||||
self.tgid = tgid
|
||||
self.cpu = cpu
|
||||
self.flags = flags
|
||||
self.timestamp = timestamp
|
||||
self.function = function
|
||||
self.canceled = False
|
||||
|
||||
@property
|
||||
def is_app_trace_line(self):
|
||||
return isinstance(self.function, AppTraceFunction)
|
||||
|
||||
def cancel(self):
|
||||
self.canceled = True
|
||||
|
||||
def __str__(self):
|
||||
if self.canceled:
|
||||
return ""
|
||||
elif self.tgid:
|
||||
return "{task:>16s}-{pid:<5d} ({tgid:5s}) [{cpu:03d}] {flags:4s} {timestamp:12f}: {function}\n".format(**vars(self))
|
||||
elif self.flags:
|
||||
return "{task:>16s}-{pid:<5d} [{cpu:03d}] {flags:4s} {timestamp:12f}: {function}\n".format(**vars(self))
|
||||
else:
|
||||
return "{task:>16s}-{pid:<5d} [{cpu:03d}] {timestamp:12.6f}: {function}\n".format(**vars(self))
|
||||
|
||||
|
||||
class AppTraceFunction(object):
|
||||
def __init__(self, type, args):
|
||||
self.type = type
|
||||
self.args = args
|
||||
self.operation = args[0]
|
||||
|
||||
if len(args) >= 2 and args[1]:
|
||||
self.pid = int(args[1])
|
||||
if len(args) >= 3:
|
||||
self._section_name, self.command, self.argument = _parse_section_name(args[2])
|
||||
args[2] = self._section_name
|
||||
else:
|
||||
self._section_name = None
|
||||
self.command = None
|
||||
self.argument = None
|
||||
self.cookie = None
|
||||
|
||||
@property
|
||||
def section_name(self):
|
||||
return self._section_name
|
||||
|
||||
@section_name.setter
|
||||
def section_name(self, value):
|
||||
self._section_name = value
|
||||
self.args[2] = value
|
||||
|
||||
def __str__(self):
|
||||
return "{type}: {args}".format(type=self.type, args='|'.join(self.args))
|
||||
|
||||
|
||||
class AsyncTraceFunction(AppTraceFunction):
|
||||
def __init__(self, type, args):
|
||||
super(AsyncTraceFunction, self).__init__(type, args)
|
||||
|
||||
self.cookie = int(args[3])
|
||||
|
||||
|
||||
TRACE_TYPE_MAP = {
|
||||
'S': AsyncTraceFunction,
|
||||
'T': AsyncTraceFunction,
|
||||
'F': AsyncTraceFunction,
|
||||
}
|
||||
|
||||
def parse_line(line):
|
||||
match = TRACE_LINE_PATTERN.match(line.strip())
|
||||
if not match:
|
||||
return None
|
||||
|
||||
task = match.group("task")
|
||||
pid = int(match.group("pid"))
|
||||
tgid = match.group("tgid")
|
||||
cpu = int(match.group("cpu"))
|
||||
flags = match.group("flags")
|
||||
timestamp = float(match.group("timestamp"))
|
||||
function = match.group("function")
|
||||
|
||||
app_trace = _parse_function(function)
|
||||
if app_trace:
|
||||
function = app_trace
|
||||
|
||||
return TraceLine(task, pid, tgid, cpu, flags, timestamp, function)
|
||||
|
||||
def parse_dextr_line(line):
|
||||
task = line["name"]
|
||||
pid = line["pid"]
|
||||
tgid = line["tid"]
|
||||
cpu = None
|
||||
flags = None
|
||||
timestamp = line["ts"]
|
||||
function = AppTraceFunction("DextrTrace", [line["ph"], line["pid"], line["name"]])
|
||||
|
||||
return TraceLine(task, pid, tgid, cpu, flags, timestamp, function)
|
||||
|
||||
|
||||
def _parse_function(function):
|
||||
line_match = APP_TRACE_LINE_PATTERN.match(function)
|
||||
if not line_match:
|
||||
return None
|
||||
|
||||
type = line_match.group("type")
|
||||
if not type in SYSTRACE_LINE_TYPES:
|
||||
return None
|
||||
|
||||
args = line_match.group("args").split('|')
|
||||
if len(args) == 1 and len(args[0]) == 0:
|
||||
args = None
|
||||
|
||||
constructor = TRACE_TYPE_MAP.get(args[0], AppTraceFunction)
|
||||
return constructor(type, args)
|
||||
|
||||
|
||||
def _parse_section_name(section_name):
|
||||
if section_name is None:
|
||||
return section_name, None, None
|
||||
|
||||
section_name_match = DECORATED_SECTION_NAME_PATTERN.match(section_name)
|
||||
section_name = section_name_match.group("section_name")
|
||||
command = section_name_match.group("command")
|
||||
argument = section_name_match.group("argument")
|
||||
return section_name, command, argument
|
||||
|
||||
|
||||
def _format_section_name(section_name, command, argument):
|
||||
if not command:
|
||||
return section_name
|
||||
|
||||
return "{section_name}<{command}{argument}>".format(**vars())
|
||||
|
||||
|
||||
class RoundTripFormattingTests(unittest.TestCase):
|
||||
def testPlainSectionName(self):
|
||||
section_name = "SectionName12345-5562342fas"
|
||||
|
||||
self.assertEqual(section_name, _format_section_name(*_parse_section_name(section_name)))
|
||||
|
||||
def testDecoratedSectionName(self):
|
||||
section_name = "SectionName12345-5562342fas<D-123456>"
|
||||
|
||||
self.assertEqual(section_name, _format_section_name(*_parse_section_name(section_name)))
|
||||
|
||||
def testSimpleFunction(self):
|
||||
function = "0: E"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testFunctionWithoutCookie(self):
|
||||
function = "0: B|27295|providerRemove"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testFunctionWithCookie(self):
|
||||
function = "0: S|27311|NNFColdStart|1112249168"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testFunctionWithCookieAndArgs(self):
|
||||
function = "0: T|27311|NNFColdStart|1122|Start"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testFunctionWithArgsButNoPid(self):
|
||||
function = "0: E|||foo=bar"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testKitKatFunction(self):
|
||||
function = "tracing_mark_write: B|14127|Looper.dispatchMessage|arg=>>>>> Dispatching to Handler (android.os.Handler) {422ae980} null: 0|Java"
|
||||
|
||||
self.assertEqual(function, str(_parse_function(function)))
|
||||
|
||||
def testNonSysTraceFunctionIgnored(self):
|
||||
function = "sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=mmcqd/0 next_pid=120 next_prio=120"
|
||||
|
||||
self.assertEqual(None, _parse_function(function))
|
||||
|
||||
def testLineWithFlagsAndTGID(self):
|
||||
line = " <idle>-0 ( 550) [000] d..2 7953.258473: cpu_idle: state=1 cpu_id=0\n"
|
||||
|
||||
self.assertEqual(line, str(parse_line(line)))
|
||||
|
||||
def testLineWithFlagsAndNoTGID(self):
|
||||
line = " <idle>-0 (-----) [000] d..2 7953.258473: cpu_idle: state=1 cpu_id=0\n"
|
||||
|
||||
self.assertEqual(line, str(parse_line(line)))
|
||||
|
||||
def testLineWithFlags(self):
|
||||
line = " <idle>-0 [001] ...2 3269.291072: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=mmcqd/0 next_pid=120 next_prio=120\n"
|
||||
|
||||
self.assertEqual(line, str(parse_line(line)))
|
||||
|
||||
def testLineWithoutFlags(self):
|
||||
line = " <idle>-0 [001] 3269.291072: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=mmcqd/0 next_pid=120 next_prio=120\n"
|
||||
|
||||
self.assertEqual(line, str(parse_line(line)))
|
||||
Vendored
+206
@@ -0,0 +1,206 @@
|
||||
import groovy.json.JsonSlurperClassic
|
||||
|
||||
def runPipeline() {
|
||||
try {
|
||||
ansiColor('xterm') {
|
||||
runStages();
|
||||
}
|
||||
} catch(err) {
|
||||
echo "Error: ${err}"
|
||||
currentBuild.result = "FAILED"
|
||||
}
|
||||
}
|
||||
|
||||
def pullDockerImage(imageName) {
|
||||
def result = sh(script: "docker pull ${imageName}", returnStatus: true)
|
||||
|
||||
if (result != 0) {
|
||||
throw new Exception("Failed to pull image[${imageName}]")
|
||||
}
|
||||
}
|
||||
|
||||
def buildDockerfile(dockerfilePath = "Dockerfile", imageName) {
|
||||
def buildCmd = "docker build -f ${dockerfilePath} -t ${imageName} ."
|
||||
echo "${buildCmd}"
|
||||
|
||||
def result = sh(script: buildCmd, returnStatus: true)
|
||||
|
||||
if (result != 0) {
|
||||
throw new Exception("Failed to build image[${imageName}] from '${dockerfilePath}'")
|
||||
}
|
||||
}
|
||||
|
||||
def runCmdOnDockerImage(imageName, cmd, run_opts = '') {
|
||||
def result = sh(script: "docker run ${run_opts} -i ${imageName} sh -c '${cmd}'", returnStatus: true)
|
||||
|
||||
if(result != 0) {
|
||||
throw new Exception("Failed to run cmd[${cmd}] on image[${imageName}]")
|
||||
}
|
||||
}
|
||||
|
||||
def calculateGithubInfo() {
|
||||
return [
|
||||
branch: env.BRANCH_NAME,
|
||||
sha: sh(returnStdout: true, script: 'git rev-parse HEAD').trim(),
|
||||
tag: null,
|
||||
isPR: "${env.CHANGE_URL}".contains('/pull/')
|
||||
]
|
||||
}
|
||||
|
||||
def getParallelInstrumentationTests(testDir, parallelCount, imageName) {
|
||||
def integrationTests = [:]
|
||||
def testCount = sh(script: "ls ${testDir} | wc -l", returnStdout: true).trim().toInteger()
|
||||
def testPerParallel = testCount.intdiv(parallelCount) + 1
|
||||
|
||||
def ignoredTests = 'CatalystNativeJavaToJSReturnValuesTestCase|CatalystUIManagerTestCase|CatalystMeasureLayoutTest|CatalystNativeJavaToJSArgumentsTestCase|CatalystNativeJSToJavaParametersTestCase|ReactScrollViewTestCase|ReactHorizontalScrollViewTestCase|ViewRenderingTestCase';
|
||||
|
||||
for (def x = 0; (x*testPerParallel) < testCount; x++) {
|
||||
def offset = x
|
||||
integrationTests["android integration tests: ${offset}"] = {
|
||||
run: {
|
||||
runCmdOnDockerImage(imageName, "bash /app/ContainerShip/scripts/run-android-docker-instrumentation-tests.sh --offset=${offset} --count=${testPerParallel} --ignore=\"${ignoredTests}\"", '--privileged --rm')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return integrationTests
|
||||
}
|
||||
|
||||
def runStages() {
|
||||
def buildInfo = [
|
||||
image: [
|
||||
name: "facebook/react-native",
|
||||
tag: null
|
||||
],
|
||||
scm: [
|
||||
branch: null,
|
||||
sha: null,
|
||||
tag: null,
|
||||
isPR: false
|
||||
]
|
||||
]
|
||||
|
||||
node {
|
||||
def jsDockerBuild, androidDockerBuild
|
||||
def jsTag, androidTag, jsImageName, androidImageName, parallelInstrumentationTests
|
||||
|
||||
try {
|
||||
stage('Setup') {
|
||||
parallel(
|
||||
'pull images': {
|
||||
pullDockerImage('containership/android-base:latest')
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
checkout scm
|
||||
|
||||
def githubInfo = calculateGithubInfo()
|
||||
buildInfo.scm.branch = githubInfo.branch
|
||||
buildInfo.scm.sha = githubInfo.sha
|
||||
buildInfo.scm.tag = githubInfo.tag
|
||||
buildInfo.scm.isPR = githubInfo.isPR
|
||||
buildInfo.image.tag = "${buildInfo.scm.sha}-${env.BUILD_TAG.replace(" ", "-").replace("/", "-").replace("%2F", "-")}"
|
||||
|
||||
jsTag = "${buildInfo.image.tag}"
|
||||
androidTag = "${buildInfo.image.tag}"
|
||||
jsImageName = "${buildInfo.image.name}-js:${jsTag}"
|
||||
androidImageName = "${buildInfo.image.name}-android:${androidTag}"
|
||||
|
||||
parallelInstrumentationTests = getParallelInstrumentationTests('./ReactAndroid/src/androidTest/java/com/facebook/react/tests', 3, androidImageName)
|
||||
|
||||
parallel(
|
||||
'javascript build': {
|
||||
jsDockerBuild = docker.build("${jsImageName}", "-f ContainerShip/Dockerfile.javascript .")
|
||||
},
|
||||
'android build': {
|
||||
androidDockerBuild = docker.build("${androidImageName}", "-f ContainerShip/Dockerfile.android .")
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
stage('Tests JS') {
|
||||
try {
|
||||
parallel(
|
||||
'javascript flow': {
|
||||
runCmdOnDockerImage(jsImageName, 'yarn run flow -- check', '--rm')
|
||||
},
|
||||
'javascript tests': {
|
||||
runCmdOnDockerImage(jsImageName, 'yarn test --maxWorkers=4', '--rm')
|
||||
},
|
||||
'documentation tests': {
|
||||
runCmdOnDockerImage(jsImageName, 'cd website && yarn test', '--rm')
|
||||
},
|
||||
'documentation generation': {
|
||||
runCmdOnDockerImage(jsImageName, 'cd website && node ./server/generate.js', '--rm')
|
||||
}
|
||||
)
|
||||
} catch(e) {
|
||||
currentBuild.result = "FAILED"
|
||||
echo "Test JS Stage Error: ${e}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests Android') {
|
||||
try {
|
||||
parallel(
|
||||
'android unit tests': {
|
||||
runCmdOnDockerImage(androidImageName, 'bash /app/ContainerShip/scripts/run-android-docker-unit-tests.sh', '--privileged --rm')
|
||||
},
|
||||
'android e2e tests': {
|
||||
runCmdOnDockerImage(androidImageName, 'bash /app/ContainerShip/scripts/run-ci-e2e-tests.sh --android --js', '--privileged --rm')
|
||||
}
|
||||
)
|
||||
} catch(e) {
|
||||
currentBuild.result = "FAILED"
|
||||
echo "Tests Android Stage Error: ${e}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests Android Instrumentation') {
|
||||
// run all tests in parallel
|
||||
try {
|
||||
parallel(parallelInstrumentationTests)
|
||||
} catch(e) {
|
||||
currentBuild.result = "FAILED"
|
||||
echo "Tests Android Instrumentation Stage Error: ${e}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Cleanup') {
|
||||
cleanupImage(jsDockerBuild)
|
||||
cleanupImage(androidDockerBuild)
|
||||
}
|
||||
} catch(err) {
|
||||
cleanupImage(jsDockerBuild)
|
||||
cleanupImage(androidDockerBuild)
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def isMasterBranch() {
|
||||
return env.GIT_BRANCH == 'master'
|
||||
}
|
||||
|
||||
def gitCommit() {
|
||||
return sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
|
||||
}
|
||||
|
||||
def cleanupImage(image) {
|
||||
if (image) {
|
||||
try {
|
||||
sh "docker ps -a | awk '{ print \$1,\$2 }' | grep ${image.id} | awk '{print \$1 }' | xargs -I {} docker rm {}"
|
||||
sh "docker rmi -f ${image.id}"
|
||||
} catch(e) {
|
||||
echo "Error cleaning up ${image.id}"
|
||||
echo "${e}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runPipeline()
|
||||
@@ -1,21 +1,30 @@
|
||||
MIT License
|
||||
BSD License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
For React Native software
|
||||
|
||||
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:
|
||||
Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
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.
|
||||
* 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.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
__tests__
|
||||
@@ -0,0 +1,488 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0CF68B051AF0549300FF9E5C /* ARTGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68ADE1AF0549300FF9E5C /* ARTGroup.m */; };
|
||||
0CF68B061AF0549300FF9E5C /* ARTNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE01AF0549300FF9E5C /* ARTNode.m */; };
|
||||
0CF68B071AF0549300FF9E5C /* ARTRenderable.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE21AF0549300FF9E5C /* ARTRenderable.m */; };
|
||||
0CF68B081AF0549300FF9E5C /* ARTShape.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE41AF0549300FF9E5C /* ARTShape.m */; };
|
||||
0CF68B091AF0549300FF9E5C /* ARTSurfaceView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE61AF0549300FF9E5C /* ARTSurfaceView.m */; };
|
||||
0CF68B0A1AF0549300FF9E5C /* ARTText.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE81AF0549300FF9E5C /* ARTText.m */; };
|
||||
0CF68B0B1AF0549300FF9E5C /* ARTBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEC1AF0549300FF9E5C /* ARTBrush.m */; };
|
||||
0CF68B0C1AF0549300FF9E5C /* ARTLinearGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEE1AF0549300FF9E5C /* ARTLinearGradient.m */; };
|
||||
0CF68B0D1AF0549300FF9E5C /* ARTPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF01AF0549300FF9E5C /* ARTPattern.m */; };
|
||||
0CF68B0E1AF0549300FF9E5C /* ARTRadialGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF21AF0549300FF9E5C /* ARTRadialGradient.m */; };
|
||||
0CF68B0F1AF0549300FF9E5C /* ARTSolidColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF41AF0549300FF9E5C /* ARTSolidColor.m */; };
|
||||
0CF68B101AF0549300FF9E5C /* RCTConvert+ART.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF71AF0549300FF9E5C /* RCTConvert+ART.m */; };
|
||||
0CF68B111AF0549300FF9E5C /* ARTGroupManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFA1AF0549300FF9E5C /* ARTGroupManager.m */; };
|
||||
0CF68B121AF0549300FF9E5C /* ARTNodeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFC1AF0549300FF9E5C /* ARTNodeManager.m */; };
|
||||
0CF68B131AF0549300FF9E5C /* ARTRenderableManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFE1AF0549300FF9E5C /* ARTRenderableManager.m */; };
|
||||
0CF68B141AF0549300FF9E5C /* ARTShapeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B001AF0549300FF9E5C /* ARTShapeManager.m */; };
|
||||
0CF68B151AF0549300FF9E5C /* ARTSurfaceViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B021AF0549300FF9E5C /* ARTSurfaceViewManager.m */; };
|
||||
0CF68B161AF0549300FF9E5C /* ARTTextManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B041AF0549300FF9E5C /* ARTTextManager.m */; };
|
||||
325CF7AD1E5F2ABA00AC9606 /* ARTBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEC1AF0549300FF9E5C /* ARTBrush.m */; };
|
||||
325CF7AE1E5F2ABA00AC9606 /* ARTLinearGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEE1AF0549300FF9E5C /* ARTLinearGradient.m */; };
|
||||
325CF7AF1E5F2ABA00AC9606 /* ARTPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF01AF0549300FF9E5C /* ARTPattern.m */; };
|
||||
325CF7B01E5F2ABA00AC9606 /* ARTRadialGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF21AF0549300FF9E5C /* ARTRadialGradient.m */; };
|
||||
325CF7B11E5F2ABA00AC9606 /* ARTSolidColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF41AF0549300FF9E5C /* ARTSolidColor.m */; };
|
||||
325CF7B21E5F2ABA00AC9606 /* ARTGroupManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFA1AF0549300FF9E5C /* ARTGroupManager.m */; };
|
||||
325CF7B31E5F2ABA00AC9606 /* ARTNodeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFC1AF0549300FF9E5C /* ARTNodeManager.m */; };
|
||||
325CF7B41E5F2ABA00AC9606 /* ARTRenderableManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AFE1AF0549300FF9E5C /* ARTRenderableManager.m */; };
|
||||
325CF7B51E5F2ABA00AC9606 /* ARTShapeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B001AF0549300FF9E5C /* ARTShapeManager.m */; };
|
||||
325CF7B61E5F2ABA00AC9606 /* ARTSurfaceViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B021AF0549300FF9E5C /* ARTSurfaceViewManager.m */; };
|
||||
325CF7B71E5F2ABA00AC9606 /* ARTTextManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68B041AF0549300FF9E5C /* ARTTextManager.m */; };
|
||||
325CF7B81E5F2ABA00AC9606 /* ARTGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68ADE1AF0549300FF9E5C /* ARTGroup.m */; };
|
||||
325CF7B91E5F2ABA00AC9606 /* ARTNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE01AF0549300FF9E5C /* ARTNode.m */; };
|
||||
325CF7BA1E5F2ABA00AC9606 /* ARTRenderable.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE21AF0549300FF9E5C /* ARTRenderable.m */; };
|
||||
325CF7BB1E5F2ABA00AC9606 /* ARTShape.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE41AF0549300FF9E5C /* ARTShape.m */; };
|
||||
325CF7BC1E5F2ABA00AC9606 /* ARTSurfaceView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE61AF0549300FF9E5C /* ARTSurfaceView.m */; };
|
||||
325CF7BD1E5F2ABA00AC9606 /* ARTText.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AE81AF0549300FF9E5C /* ARTText.m */; };
|
||||
325CF7BE1E5F2ABA00AC9606 /* RCTConvert+ART.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF71AF0549300FF9E5C /* RCTConvert+ART.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
0CF68ABF1AF0540F00FF9E5C /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
323A12851E5F266B004975B8 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0CF68AC11AF0540F00FF9E5C /* libART.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libART.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0CF68ADB1AF0549300FF9E5C /* ARTCGFloatArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTCGFloatArray.h; sourceTree = "<group>"; };
|
||||
0CF68ADC1AF0549300FF9E5C /* ARTContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTContainer.h; sourceTree = "<group>"; };
|
||||
0CF68ADD1AF0549300FF9E5C /* ARTGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTGroup.h; sourceTree = "<group>"; };
|
||||
0CF68ADE1AF0549300FF9E5C /* ARTGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTGroup.m; sourceTree = "<group>"; };
|
||||
0CF68ADF1AF0549300FF9E5C /* ARTNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTNode.h; sourceTree = "<group>"; };
|
||||
0CF68AE01AF0549300FF9E5C /* ARTNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTNode.m; sourceTree = "<group>"; };
|
||||
0CF68AE11AF0549300FF9E5C /* ARTRenderable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTRenderable.h; sourceTree = "<group>"; };
|
||||
0CF68AE21AF0549300FF9E5C /* ARTRenderable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTRenderable.m; sourceTree = "<group>"; };
|
||||
0CF68AE31AF0549300FF9E5C /* ARTShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTShape.h; sourceTree = "<group>"; };
|
||||
0CF68AE41AF0549300FF9E5C /* ARTShape.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTShape.m; sourceTree = "<group>"; };
|
||||
0CF68AE51AF0549300FF9E5C /* ARTSurfaceView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTSurfaceView.h; sourceTree = "<group>"; };
|
||||
0CF68AE61AF0549300FF9E5C /* ARTSurfaceView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTSurfaceView.m; sourceTree = "<group>"; };
|
||||
0CF68AE71AF0549300FF9E5C /* ARTText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTText.h; sourceTree = "<group>"; };
|
||||
0CF68AE81AF0549300FF9E5C /* ARTText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTText.m; sourceTree = "<group>"; };
|
||||
0CF68AE91AF0549300FF9E5C /* ARTTextFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTTextFrame.h; sourceTree = "<group>"; };
|
||||
0CF68AEB1AF0549300FF9E5C /* ARTBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTBrush.h; sourceTree = "<group>"; };
|
||||
0CF68AEC1AF0549300FF9E5C /* ARTBrush.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTBrush.m; sourceTree = "<group>"; };
|
||||
0CF68AED1AF0549300FF9E5C /* ARTLinearGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTLinearGradient.h; sourceTree = "<group>"; };
|
||||
0CF68AEE1AF0549300FF9E5C /* ARTLinearGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTLinearGradient.m; sourceTree = "<group>"; };
|
||||
0CF68AEF1AF0549300FF9E5C /* ARTPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTPattern.h; sourceTree = "<group>"; };
|
||||
0CF68AF01AF0549300FF9E5C /* ARTPattern.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTPattern.m; sourceTree = "<group>"; };
|
||||
0CF68AF11AF0549300FF9E5C /* ARTRadialGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTRadialGradient.h; sourceTree = "<group>"; };
|
||||
0CF68AF21AF0549300FF9E5C /* ARTRadialGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTRadialGradient.m; sourceTree = "<group>"; };
|
||||
0CF68AF31AF0549300FF9E5C /* ARTSolidColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTSolidColor.h; sourceTree = "<group>"; };
|
||||
0CF68AF41AF0549300FF9E5C /* ARTSolidColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTSolidColor.m; sourceTree = "<group>"; };
|
||||
0CF68AF61AF0549300FF9E5C /* RCTConvert+ART.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+ART.h"; sourceTree = "<group>"; };
|
||||
0CF68AF71AF0549300FF9E5C /* RCTConvert+ART.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTConvert+ART.m"; sourceTree = "<group>"; };
|
||||
0CF68AF91AF0549300FF9E5C /* ARTGroupManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTGroupManager.h; sourceTree = "<group>"; };
|
||||
0CF68AFA1AF0549300FF9E5C /* ARTGroupManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTGroupManager.m; sourceTree = "<group>"; };
|
||||
0CF68AFB1AF0549300FF9E5C /* ARTNodeManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTNodeManager.h; sourceTree = "<group>"; };
|
||||
0CF68AFC1AF0549300FF9E5C /* ARTNodeManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTNodeManager.m; sourceTree = "<group>"; };
|
||||
0CF68AFD1AF0549300FF9E5C /* ARTRenderableManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTRenderableManager.h; sourceTree = "<group>"; };
|
||||
0CF68AFE1AF0549300FF9E5C /* ARTRenderableManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTRenderableManager.m; sourceTree = "<group>"; };
|
||||
0CF68AFF1AF0549300FF9E5C /* ARTShapeManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTShapeManager.h; sourceTree = "<group>"; };
|
||||
0CF68B001AF0549300FF9E5C /* ARTShapeManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTShapeManager.m; sourceTree = "<group>"; };
|
||||
0CF68B011AF0549300FF9E5C /* ARTSurfaceViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTSurfaceViewManager.h; sourceTree = "<group>"; };
|
||||
0CF68B021AF0549300FF9E5C /* ARTSurfaceViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTSurfaceViewManager.m; sourceTree = "<group>"; };
|
||||
0CF68B031AF0549300FF9E5C /* ARTTextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTTextManager.h; sourceTree = "<group>"; };
|
||||
0CF68B041AF0549300FF9E5C /* ARTTextManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTTextManager.m; sourceTree = "<group>"; };
|
||||
323A12871E5F266B004975B8 /* libART-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libART-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
0CF68ABE1AF0540F00FF9E5C /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
323A12841E5F266B004975B8 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0CF68AB81AF0540F00FF9E5C = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0CF68AEA1AF0549300FF9E5C /* Brushes */,
|
||||
0CF68AF81AF0549300FF9E5C /* ViewManagers */,
|
||||
0CF68ADB1AF0549300FF9E5C /* ARTCGFloatArray.h */,
|
||||
0CF68ADC1AF0549300FF9E5C /* ARTContainer.h */,
|
||||
0CF68ADD1AF0549300FF9E5C /* ARTGroup.h */,
|
||||
0CF68ADE1AF0549300FF9E5C /* ARTGroup.m */,
|
||||
0CF68ADF1AF0549300FF9E5C /* ARTNode.h */,
|
||||
0CF68AE01AF0549300FF9E5C /* ARTNode.m */,
|
||||
0CF68AE11AF0549300FF9E5C /* ARTRenderable.h */,
|
||||
0CF68AE21AF0549300FF9E5C /* ARTRenderable.m */,
|
||||
0CF68AE31AF0549300FF9E5C /* ARTShape.h */,
|
||||
0CF68AE41AF0549300FF9E5C /* ARTShape.m */,
|
||||
0CF68AE51AF0549300FF9E5C /* ARTSurfaceView.h */,
|
||||
0CF68AE61AF0549300FF9E5C /* ARTSurfaceView.m */,
|
||||
0CF68AE71AF0549300FF9E5C /* ARTText.h */,
|
||||
0CF68AE81AF0549300FF9E5C /* ARTText.m */,
|
||||
0CF68AE91AF0549300FF9E5C /* ARTTextFrame.h */,
|
||||
0CF68AF61AF0549300FF9E5C /* RCTConvert+ART.h */,
|
||||
0CF68AF71AF0549300FF9E5C /* RCTConvert+ART.m */,
|
||||
0CF68AC21AF0540F00FF9E5C /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0CF68AC21AF0540F00FF9E5C /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0CF68AC11AF0540F00FF9E5C /* libART.a */,
|
||||
323A12871E5F266B004975B8 /* libART-tvOS.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0CF68AEA1AF0549300FF9E5C /* Brushes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0CF68AEB1AF0549300FF9E5C /* ARTBrush.h */,
|
||||
0CF68AEC1AF0549300FF9E5C /* ARTBrush.m */,
|
||||
0CF68AED1AF0549300FF9E5C /* ARTLinearGradient.h */,
|
||||
0CF68AEE1AF0549300FF9E5C /* ARTLinearGradient.m */,
|
||||
0CF68AEF1AF0549300FF9E5C /* ARTPattern.h */,
|
||||
0CF68AF01AF0549300FF9E5C /* ARTPattern.m */,
|
||||
0CF68AF11AF0549300FF9E5C /* ARTRadialGradient.h */,
|
||||
0CF68AF21AF0549300FF9E5C /* ARTRadialGradient.m */,
|
||||
0CF68AF31AF0549300FF9E5C /* ARTSolidColor.h */,
|
||||
0CF68AF41AF0549300FF9E5C /* ARTSolidColor.m */,
|
||||
);
|
||||
path = Brushes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0CF68AF81AF0549300FF9E5C /* ViewManagers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0CF68AF91AF0549300FF9E5C /* ARTGroupManager.h */,
|
||||
0CF68AFA1AF0549300FF9E5C /* ARTGroupManager.m */,
|
||||
0CF68AFB1AF0549300FF9E5C /* ARTNodeManager.h */,
|
||||
0CF68AFC1AF0549300FF9E5C /* ARTNodeManager.m */,
|
||||
0CF68AFD1AF0549300FF9E5C /* ARTRenderableManager.h */,
|
||||
0CF68AFE1AF0549300FF9E5C /* ARTRenderableManager.m */,
|
||||
0CF68AFF1AF0549300FF9E5C /* ARTShapeManager.h */,
|
||||
0CF68B001AF0549300FF9E5C /* ARTShapeManager.m */,
|
||||
0CF68B011AF0549300FF9E5C /* ARTSurfaceViewManager.h */,
|
||||
0CF68B021AF0549300FF9E5C /* ARTSurfaceViewManager.m */,
|
||||
0CF68B031AF0549300FF9E5C /* ARTTextManager.h */,
|
||||
0CF68B041AF0549300FF9E5C /* ARTTextManager.m */,
|
||||
);
|
||||
path = ViewManagers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
0CF68AC01AF0540F00FF9E5C /* ART */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0CF68AD51AF0540F00FF9E5C /* Build configuration list for PBXNativeTarget "ART" */;
|
||||
buildPhases = (
|
||||
0CF68ABD1AF0540F00FF9E5C /* Sources */,
|
||||
0CF68ABE1AF0540F00FF9E5C /* Frameworks */,
|
||||
0CF68ABF1AF0540F00FF9E5C /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = ART;
|
||||
productName = ART;
|
||||
productReference = 0CF68AC11AF0540F00FF9E5C /* libART.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
323A12861E5F266B004975B8 /* ART-tvOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 323A128D1E5F266B004975B8 /* Build configuration list for PBXNativeTarget "ART-tvOS" */;
|
||||
buildPhases = (
|
||||
323A12831E5F266B004975B8 /* Sources */,
|
||||
323A12841E5F266B004975B8 /* Frameworks */,
|
||||
323A12851E5F266B004975B8 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "ART-tvOS";
|
||||
productName = "ART-tvOS";
|
||||
productReference = 323A12871E5F266B004975B8 /* libART-tvOS.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
0CF68AB91AF0540F00FF9E5C /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0620;
|
||||
TargetAttributes = {
|
||||
0CF68AC01AF0540F00FF9E5C = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
};
|
||||
323A12861E5F266B004975B8 = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 0CF68ABC1AF0540F00FF9E5C /* Build configuration list for PBXProject "ART" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 0CF68AB81AF0540F00FF9E5C;
|
||||
productRefGroup = 0CF68AC21AF0540F00FF9E5C /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
0CF68AC01AF0540F00FF9E5C /* ART */,
|
||||
323A12861E5F266B004975B8 /* ART-tvOS */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
0CF68ABD1AF0540F00FF9E5C /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0CF68B161AF0549300FF9E5C /* ARTTextManager.m in Sources */,
|
||||
0CF68B111AF0549300FF9E5C /* ARTGroupManager.m in Sources */,
|
||||
0CF68B0D1AF0549300FF9E5C /* ARTPattern.m in Sources */,
|
||||
0CF68B0A1AF0549300FF9E5C /* ARTText.m in Sources */,
|
||||
0CF68B121AF0549300FF9E5C /* ARTNodeManager.m in Sources */,
|
||||
0CF68B051AF0549300FF9E5C /* ARTGroup.m in Sources */,
|
||||
0CF68B131AF0549300FF9E5C /* ARTRenderableManager.m in Sources */,
|
||||
0CF68B091AF0549300FF9E5C /* ARTSurfaceView.m in Sources */,
|
||||
0CF68B0E1AF0549300FF9E5C /* ARTRadialGradient.m in Sources */,
|
||||
0CF68B151AF0549300FF9E5C /* ARTSurfaceViewManager.m in Sources */,
|
||||
0CF68B081AF0549300FF9E5C /* ARTShape.m in Sources */,
|
||||
0CF68B071AF0549300FF9E5C /* ARTRenderable.m in Sources */,
|
||||
0CF68B101AF0549300FF9E5C /* RCTConvert+ART.m in Sources */,
|
||||
0CF68B061AF0549300FF9E5C /* ARTNode.m in Sources */,
|
||||
0CF68B0F1AF0549300FF9E5C /* ARTSolidColor.m in Sources */,
|
||||
0CF68B0C1AF0549300FF9E5C /* ARTLinearGradient.m in Sources */,
|
||||
0CF68B0B1AF0549300FF9E5C /* ARTBrush.m in Sources */,
|
||||
0CF68B141AF0549300FF9E5C /* ARTShapeManager.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
323A12831E5F266B004975B8 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
325CF7B71E5F2ABA00AC9606 /* ARTTextManager.m in Sources */,
|
||||
325CF7B21E5F2ABA00AC9606 /* ARTGroupManager.m in Sources */,
|
||||
325CF7AF1E5F2ABA00AC9606 /* ARTPattern.m in Sources */,
|
||||
325CF7BD1E5F2ABA00AC9606 /* ARTText.m in Sources */,
|
||||
325CF7B31E5F2ABA00AC9606 /* ARTNodeManager.m in Sources */,
|
||||
325CF7B81E5F2ABA00AC9606 /* ARTGroup.m in Sources */,
|
||||
325CF7B41E5F2ABA00AC9606 /* ARTRenderableManager.m in Sources */,
|
||||
325CF7BC1E5F2ABA00AC9606 /* ARTSurfaceView.m in Sources */,
|
||||
325CF7B01E5F2ABA00AC9606 /* ARTRadialGradient.m in Sources */,
|
||||
325CF7B61E5F2ABA00AC9606 /* ARTSurfaceViewManager.m in Sources */,
|
||||
325CF7BB1E5F2ABA00AC9606 /* ARTShape.m in Sources */,
|
||||
325CF7BA1E5F2ABA00AC9606 /* ARTRenderable.m in Sources */,
|
||||
325CF7BE1E5F2ABA00AC9606 /* RCTConvert+ART.m in Sources */,
|
||||
325CF7B91E5F2ABA00AC9606 /* ARTNode.m in Sources */,
|
||||
325CF7B11E5F2ABA00AC9606 /* ARTSolidColor.m in Sources */,
|
||||
325CF7AE1E5F2ABA00AC9606 /* ARTLinearGradient.m in Sources */,
|
||||
325CF7AD1E5F2ABA00AC9606 /* ARTBrush.m in Sources */,
|
||||
325CF7B51E5F2ABA00AC9606 /* ARTShapeManager.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0CF68AD31AF0540F00FF9E5C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0CF68AD41AF0540F00FF9E5C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
0CF68AD61AF0540F00FF9E5C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0CF68AD71AF0540F00FF9E5C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
323A128E1E5F266B004975B8 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
323A128F1E5F266B004975B8 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
0CF68ABC1AF0540F00FF9E5C /* Build configuration list for PBXProject "ART" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0CF68AD31AF0540F00FF9E5C /* Debug */,
|
||||
0CF68AD41AF0540F00FF9E5C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
0CF68AD51AF0540F00FF9E5C /* Build configuration list for PBXNativeTarget "ART" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0CF68AD61AF0540F00FF9E5C /* Debug */,
|
||||
0CF68AD71AF0540F00FF9E5C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
323A128D1E5F266B004975B8 /* Build configuration list for PBXNativeTarget "ART-tvOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
323A128E1E5F266B004975B8 /* Debug */,
|
||||
323A128F1E5F266B004975B8 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 0CF68AB91AF0540F00FF9E5C /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// A little helper to make sure we have the right memory allocation ready for use.
|
||||
// We assume that we will only this in one place so no reference counting is necessary.
|
||||
// Needs to be freed when dealloced.
|
||||
|
||||
// This is fragile since this relies on these values not getting reused. Consider
|
||||
// wrapping these in an Obj-C class or some ARC hackery to get refcounting.
|
||||
|
||||
typedef struct {
|
||||
size_t count;
|
||||
CGFloat *array;
|
||||
} ARTCGFloatArray;
|
||||
@@ -0,0 +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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol ARTContainer <NSObject>
|
||||
|
||||
// This is used as a hook for child to mark it's parent as dirty.
|
||||
// This bubbles up to the root which gets marked as dirty.
|
||||
- (void)invalidate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ARTContainer.h"
|
||||
#import "ARTNode.h"
|
||||
|
||||
@interface ARTGroup : ARTNode <ARTContainer>
|
||||
|
||||
@property (nonatomic, assign) CGRect clipping;
|
||||
|
||||
@end
|
||||
@@ -0,0 +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.
|
||||
*/
|
||||
|
||||
#import "ARTGroup.h"
|
||||
|
||||
@implementation ARTGroup
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
|
||||
if (!CGRectIsEmpty(self.clipping)) {
|
||||
CGContextClipToRect(context, self.clipping);
|
||||
}
|
||||
|
||||
for (ARTNode *node in self.subviews) {
|
||||
[node renderTo:context];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <React/UIView+React.h>
|
||||
|
||||
/**
|
||||
* ART nodes are implemented as empty UIViews but this is just an implementation detail to fit
|
||||
* into the existing view management. They should also be shadow views and painted on a background
|
||||
* thread.
|
||||
*/
|
||||
|
||||
@interface ARTNode : UIView
|
||||
|
||||
@property (nonatomic, assign) CGFloat opacity;
|
||||
|
||||
- (void)invalidate;
|
||||
- (void)renderTo:(CGContextRef)context;
|
||||
|
||||
/**
|
||||
* renderTo will take opacity into account and draw renderLayerTo off-screen if there is opacity
|
||||
* specified, then composite that onto the context. renderLayerTo always draws at opacity=1.
|
||||
* @abstract
|
||||
*/
|
||||
- (void)renderLayerTo:(CGContextRef)context;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "ARTNode.h"
|
||||
|
||||
#import "ARTContainer.h"
|
||||
|
||||
@implementation ARTNode
|
||||
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
[super insertReactSubview:subview atIndex:atIndex];
|
||||
[self insertSubview:subview atIndex:atIndex];
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
[super removeReactSubview:subview];
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)didUpdateReactSubviews
|
||||
{
|
||||
// Do nothing, as subviews are inserted by insertReactSubview:
|
||||
}
|
||||
|
||||
- (void)setOpacity:(CGFloat)opacity
|
||||
{
|
||||
[self invalidate];
|
||||
_opacity = opacity;
|
||||
}
|
||||
|
||||
- (void)setTransform:(CGAffineTransform)transform
|
||||
{
|
||||
[self invalidate];
|
||||
super.transform = transform;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
id<ARTContainer> container = (id<ARTContainer>)self.superview;
|
||||
[container invalidate];
|
||||
}
|
||||
|
||||
- (void)renderTo:(CGContextRef)context
|
||||
{
|
||||
if (self.opacity <= 0) {
|
||||
// Nothing to paint
|
||||
return;
|
||||
}
|
||||
if (self.opacity >= 1) {
|
||||
// Just paint at full opacity
|
||||
CGContextSaveGState(context);
|
||||
CGContextConcatCTM(context, self.transform);
|
||||
CGContextSetAlpha(context, 1);
|
||||
[self renderLayerTo:context];
|
||||
CGContextRestoreGState(context);
|
||||
return;
|
||||
}
|
||||
// This needs to be painted on a layer before being composited.
|
||||
CGContextSaveGState(context);
|
||||
CGContextConcatCTM(context, self.transform);
|
||||
CGContextSetAlpha(context, self.opacity);
|
||||
CGContextBeginTransparencyLayer(context, NULL);
|
||||
[self renderLayerTo:context];
|
||||
CGContextEndTransparencyLayer(context);
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
// abstract
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ARTBrush.h"
|
||||
#import "ARTCGFloatArray.h"
|
||||
#import "ARTNode.h"
|
||||
|
||||
@interface ARTRenderable : ARTNode
|
||||
|
||||
@property (nonatomic, strong) ARTBrush *fill;
|
||||
@property (nonatomic, assign) CGColorRef stroke;
|
||||
@property (nonatomic, assign) CGFloat strokeWidth;
|
||||
@property (nonatomic, assign) CGLineCap strokeCap;
|
||||
@property (nonatomic, assign) CGLineJoin strokeJoin;
|
||||
@property (nonatomic, assign) ARTCGFloatArray strokeDash;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "ARTRenderable.h"
|
||||
|
||||
@implementation ARTRenderable
|
||||
|
||||
- (void)setFill:(ARTBrush *)fill
|
||||
{
|
||||
[self invalidate];
|
||||
_fill = fill;
|
||||
}
|
||||
|
||||
- (void)setStroke:(CGColorRef)stroke
|
||||
{
|
||||
if (stroke == _stroke) {
|
||||
return;
|
||||
}
|
||||
[self invalidate];
|
||||
CGColorRelease(_stroke);
|
||||
_stroke = CGColorRetain(stroke);
|
||||
}
|
||||
|
||||
- (void)setStrokeWidth:(CGFloat)strokeWidth
|
||||
{
|
||||
[self invalidate];
|
||||
_strokeWidth = strokeWidth;
|
||||
}
|
||||
|
||||
- (void)setStrokeCap:(CGLineCap)strokeCap
|
||||
{
|
||||
[self invalidate];
|
||||
_strokeCap = strokeCap;
|
||||
}
|
||||
|
||||
- (void)setStrokeJoin:(CGLineJoin)strokeJoin
|
||||
{
|
||||
[self invalidate];
|
||||
_strokeJoin = strokeJoin;
|
||||
}
|
||||
|
||||
- (void)setStrokeDash:(ARTCGFloatArray)strokeDash
|
||||
{
|
||||
if (strokeDash.array == _strokeDash.array) {
|
||||
return;
|
||||
}
|
||||
if (_strokeDash.array) {
|
||||
free(_strokeDash.array);
|
||||
}
|
||||
[self invalidate];
|
||||
_strokeDash = strokeDash;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CGColorRelease(_stroke);
|
||||
if (_strokeDash.array) {
|
||||
free(_strokeDash.array);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)renderTo:(CGContextRef)context
|
||||
{
|
||||
if (self.opacity <= 0 || self.opacity >= 1 || (self.fill && self.stroke)) {
|
||||
// If we have both fill and stroke, we will need to paint this using normal compositing
|
||||
[super renderTo: context];
|
||||
return;
|
||||
}
|
||||
// This is a terminal with only one painting. Therefore we don't need to paint this
|
||||
// off-screen. We can just composite it straight onto the buffer.
|
||||
CGContextSaveGState(context);
|
||||
CGContextConcatCTM(context, self.transform);
|
||||
CGContextSetAlpha(context, self.opacity);
|
||||
[self renderLayerTo:context];
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
// abstract
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 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 ARTSerializablePath
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
// TODO: Move this into an ART mode called "serialized" or something
|
||||
|
||||
var Class = require('art/core/class.js');
|
||||
var Path = require('art/core/path.js');
|
||||
|
||||
var MOVE_TO = 0;
|
||||
var CLOSE = 1;
|
||||
var LINE_TO = 2;
|
||||
var CURVE_TO = 3;
|
||||
var ARC = 4;
|
||||
|
||||
var SerializablePath = Class(Path, {
|
||||
|
||||
initialize: function(path) {
|
||||
this.reset();
|
||||
if (path instanceof SerializablePath) {
|
||||
this.path = path.path.slice(0);
|
||||
} else if (path) {
|
||||
if (path.applyToPath) {
|
||||
path.applyToPath(this);
|
||||
} else {
|
||||
this.push(path);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onReset: function() {
|
||||
this.path = [];
|
||||
},
|
||||
|
||||
onMove: function(sx, sy, x, y) {
|
||||
this.path.push(MOVE_TO, x, y);
|
||||
},
|
||||
|
||||
onLine: function(sx, sy, x, y) {
|
||||
this.path.push(LINE_TO, x, y);
|
||||
},
|
||||
|
||||
onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y) {
|
||||
this.path.push(CURVE_TO, p1x, p1y, p2x, p2y, x, y);
|
||||
},
|
||||
|
||||
_arcToBezier: Path.prototype.onArc,
|
||||
|
||||
onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation) {
|
||||
if (rx !== ry || rotation) {
|
||||
return this._arcToBezier(
|
||||
sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation
|
||||
);
|
||||
}
|
||||
this.path.push(ARC, cx, cy, rx, sa, ea, ccw ? 0 : 1);
|
||||
},
|
||||
|
||||
onClose: function() {
|
||||
this.path.push(CLOSE);
|
||||
},
|
||||
|
||||
toJSON: function() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = SerializablePath;
|
||||
@@ -0,0 +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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ARTRenderable.h"
|
||||
|
||||
@interface ARTShape : ARTRenderable
|
||||
|
||||
@property (nonatomic, assign) CGPathRef d;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "ARTShape.h"
|
||||
|
||||
@implementation ARTShape
|
||||
|
||||
- (void)setD:(CGPathRef)d
|
||||
{
|
||||
if (d == _d) {
|
||||
return;
|
||||
}
|
||||
[self invalidate];
|
||||
CGPathRelease(_d);
|
||||
_d = CGPathRetain(d);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CGPathRelease(_d);
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
if ((!self.fill && !self.stroke) || !self.d) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGPathDrawingMode mode = kCGPathStroke;
|
||||
if (self.fill) {
|
||||
if ([self.fill applyFillColor:context]) {
|
||||
mode = kCGPathFill;
|
||||
} else {
|
||||
CGContextSaveGState(context);
|
||||
CGContextAddPath(context, self.d);
|
||||
CGContextClip(context);
|
||||
[self.fill paint:context];
|
||||
CGContextRestoreGState(context);
|
||||
if (!self.stroke) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self.stroke) {
|
||||
CGContextSetStrokeColorWithColor(context, self.stroke);
|
||||
CGContextSetLineWidth(context, self.strokeWidth);
|
||||
CGContextSetLineCap(context, self.strokeCap);
|
||||
CGContextSetLineJoin(context, self.strokeJoin);
|
||||
ARTCGFloatArray dash = self.strokeDash;
|
||||
if (dash.count) {
|
||||
CGContextSetLineDash(context, 0, dash.array, dash.count);
|
||||
}
|
||||
if (mode == kCGPathFill) {
|
||||
mode = kCGPathFillStroke;
|
||||
}
|
||||
}
|
||||
|
||||
CGContextAddPath(context, self.d);
|
||||
CGContextDrawPath(context, mode);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "ARTContainer.h"
|
||||
|
||||
@interface ARTSurfaceView : UIView <ARTContainer>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "ARTSurfaceView.h"
|
||||
|
||||
#import <React/RCTLog.h>
|
||||
|
||||
#import "ARTNode.h"
|
||||
|
||||
@implementation ARTSurfaceView
|
||||
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
[super insertReactSubview:subview atIndex:atIndex];
|
||||
[self insertSubview:subview atIndex:atIndex];
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
[super removeReactSubview:subview];
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)didUpdateReactSubviews
|
||||
{
|
||||
// Do nothing, as subviews are inserted by insertReactSubview:
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
for (ARTNode *node in self.subviews) {
|
||||
[node renderTo:context];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reactSetInheritedBackgroundColor:(UIColor *)inheritedBackgroundColor
|
||||
{
|
||||
self.backgroundColor = inheritedBackgroundColor;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "ARTRenderable.h"
|
||||
#import "ARTTextFrame.h"
|
||||
|
||||
@interface ARTText : ARTRenderable
|
||||
|
||||
@property (nonatomic, assign) CTTextAlignment alignment;
|
||||
@property (nonatomic, assign) ARTTextFrame textFrame;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "ARTText.h"
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
@implementation ARTText
|
||||
|
||||
- (void)setAlignment:(CTTextAlignment)alignment
|
||||
{
|
||||
[self invalidate];
|
||||
_alignment = alignment;
|
||||
}
|
||||
|
||||
static void ARTFreeTextFrame(ARTTextFrame frame)
|
||||
{
|
||||
if (frame.count) {
|
||||
// We must release each line before freeing up this struct
|
||||
for (int i = 0; i < frame.count; i++) {
|
||||
CFRelease(frame.lines[i]);
|
||||
}
|
||||
free(frame.lines);
|
||||
free(frame.widths);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTextFrame:(ARTTextFrame)frame
|
||||
{
|
||||
if (frame.lines != _textFrame.lines) {
|
||||
ARTFreeTextFrame(_textFrame);
|
||||
}
|
||||
[self invalidate];
|
||||
_textFrame = frame;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
ARTFreeTextFrame(_textFrame);
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
ARTTextFrame frame = self.textFrame;
|
||||
|
||||
if ((!self.fill && !self.stroke) || !frame.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
// to-do: draw along a path
|
||||
|
||||
CGTextDrawingMode mode = kCGTextStroke;
|
||||
if (self.fill) {
|
||||
if ([self.fill applyFillColor:context]) {
|
||||
mode = kCGTextFill;
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < frame.count; i++) {
|
||||
CGContextSaveGState(context);
|
||||
// Inverse the coordinate space since CoreText assumes a bottom-up coordinate space
|
||||
CGContextScaleCTM(context, 1.0, -1.0);
|
||||
CGContextSetTextDrawingMode(context, kCGTextClip);
|
||||
[self renderLineTo:context atIndex:i];
|
||||
// Inverse the coordinate space back to the original before filling
|
||||
CGContextScaleCTM(context, 1.0, -1.0);
|
||||
[self.fill paint:context];
|
||||
// Restore the state so that the next line can be clipped separately
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
if (!self.stroke) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self.stroke) {
|
||||
CGContextSetStrokeColorWithColor(context, self.stroke);
|
||||
CGContextSetLineWidth(context, self.strokeWidth);
|
||||
CGContextSetLineCap(context, self.strokeCap);
|
||||
CGContextSetLineJoin(context, self.strokeJoin);
|
||||
ARTCGFloatArray dash = self.strokeDash;
|
||||
if (dash.count) {
|
||||
CGContextSetLineDash(context, 0, dash.array, dash.count);
|
||||
}
|
||||
if (mode == kCGTextFill) {
|
||||
mode = kCGTextFillStroke;
|
||||
}
|
||||
}
|
||||
|
||||
CGContextSetTextDrawingMode(context, mode);
|
||||
|
||||
// Inverse the coordinate space since CoreText assumes a bottom-up coordinate space
|
||||
CGContextScaleCTM(context, 1.0, -1.0);
|
||||
for (int i = 0; i < frame.count; i++) {
|
||||
[self renderLineTo:context atIndex:i];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)renderLineTo:(CGContextRef)context atIndex:(int)index
|
||||
{
|
||||
ARTTextFrame frame = self.textFrame;
|
||||
CGFloat shift;
|
||||
switch (self.alignment) {
|
||||
case kCTTextAlignmentRight:
|
||||
shift = frame.widths[index];
|
||||
break;
|
||||
case kCTTextAlignmentCenter:
|
||||
shift = (frame.widths[index] / 2);
|
||||
break;
|
||||
default:
|
||||
shift = 0;
|
||||
break;
|
||||
}
|
||||
// We should consider snapping this shift to device pixels to improve rendering quality
|
||||
// when a line has subpixel width.
|
||||
CGContextSetTextPosition(context, -shift, -frame.baseLine - frame.lineHeight * index);
|
||||
CTLineRef line = frame.lines[index];
|
||||
CTLineDraw(line, context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
// A little helper to make sure we have a set of lines including width ready for use.
|
||||
// We assume that we will only this in one place so no reference counting is necessary.
|
||||
// Needs to be freed when dealloced.
|
||||
|
||||
// This is fragile since this relies on these values not getting reused. Consider
|
||||
// wrapping these in an Obj-C class or some ARC hackery to get refcounting.
|
||||
|
||||
typedef struct {
|
||||
size_t count;
|
||||
CGFloat baseLine; // Distance from the origin to the base line of the first line
|
||||
CGFloat lineHeight; // Distance between lines
|
||||
CTLineRef *lines;
|
||||
CGFloat *widths; // Width of each line
|
||||
} ARTTextFrame;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user