mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f465017fe8 | ||
|
|
02a61a8d8e | ||
|
|
33650db050 | ||
|
|
cc1499e124 | ||
|
|
7cb831d164 | ||
|
|
e6c1fb7212 | ||
|
|
e56089af1d | ||
|
|
e258e5f214 | ||
|
|
3259353fce |
@@ -1,48 +0,0 @@
|
||||
environment:
|
||||
ANDROID_HOME: "C:\\android-sdk-windows"
|
||||
ANDROID_NDK: "C:\\android-sdk-windows\\android-ndk-r17c"
|
||||
ANDROID_BUILD_VERSION: 28
|
||||
ANDROID_TOOLS_VERSION: 28.0.3
|
||||
|
||||
GRADLE_OPTS: -Dorg.gradle.daemon=false
|
||||
|
||||
SDK_TOOLS_URL: https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip
|
||||
NDK_TOOLS_URL: https://dl.google.com/android/repository/android-ndk-r17c-windows-x86_64.zip
|
||||
|
||||
matrix:
|
||||
- nodejs_version: 8
|
||||
- nodejs_version: 10
|
||||
|
||||
install:
|
||||
# Install Android SDK Tools
|
||||
- mkdir "%ANDROID_HOME%"
|
||||
- appveyor DownloadFile "%SDK_TOOLS_URL%" -FileName "%TMP%/sdk-tools.zip"
|
||||
- 7z x "%TMP%/sdk-tools.zip" -o"%ANDROID_HOME%" > nul
|
||||
- set PATH=%PATH%;"%ANDROID_HOME%\tools\bin"
|
||||
|
||||
- yes 2> nul | sdkmanager --licenses > nul
|
||||
- sdkmanager "system-images;android-19;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"
|
||||
|
||||
- appveyor DownloadFile "%NDK_TOOLS_URL%" -FileName "%TMP%/ndk.zip"
|
||||
- 7z x "%TMP%/ndk.zip" -o"%ANDROID_HOME%" > nul
|
||||
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
- node --version
|
||||
- yarn --version
|
||||
- appveyor-retry yarn install
|
||||
|
||||
build_script:
|
||||
- gradlew.bat RNTester:android:app:assembleRelease
|
||||
|
||||
test_script:
|
||||
- npm test
|
||||
|
||||
cache:
|
||||
- node_modules
|
||||
- "%LOCALAPPDATA%/Yarn"
|
||||
- "%USERPROFILE%/.gradle/caches"
|
||||
- "%USERPROFILE%/.gradle/wrapper"
|
||||
+1
-2
@@ -1,13 +1,12 @@
|
||||
|
||||
[android]
|
||||
target = android-28
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[download]
|
||||
max_number_of_retries = 3
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
google = https://dl.google.com/dl/android/maven2/
|
||||
|
||||
[alias]
|
||||
rntester = //RNTester/android/app:app
|
||||
|
||||
@@ -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.
|
||||
+357
-566
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,3 @@ indent_size = 2
|
||||
|
||||
[*.gradle]
|
||||
indent_size = 4
|
||||
|
||||
[BUCK]
|
||||
indent_size = 4
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
|
||||
"parser": "babel-eslint",
|
||||
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
|
||||
"env": {
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"jasmine": true,
|
||||
},
|
||||
|
||||
"plugins": [
|
||||
"eslint-comments",
|
||||
"flowtype",
|
||||
"prettier",
|
||||
"react",
|
||||
"react-native",
|
||||
"jest"
|
||||
"react"
|
||||
],
|
||||
|
||||
// Map from global var to bool specifying if it can be redefined
|
||||
@@ -52,21 +53,35 @@
|
||||
"setTimeout": false,
|
||||
"window": false,
|
||||
"XMLHttpRequest": false,
|
||||
"pit": false,
|
||||
"jasmine": true
|
||||
"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": [1, "always-multiline"], // allow or disallow trailing commas
|
||||
|
||||
// This must be disallowed in this repo because the minimum supported
|
||||
// version of node is 4 which doesn't support trailing commas.
|
||||
// Once the minimum supported version is 8 or greater this can be changed
|
||||
"comma-dangle": [2, { // disallow trailing commas in object literals
|
||||
"arrays": "ignore",
|
||||
"objects": "ignore",
|
||||
"imports": "ignore",
|
||||
"exports": "ignore",
|
||||
"functions": "never"
|
||||
}],
|
||||
|
||||
"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-class-members": 2, // Disallow duplicate name in class members
|
||||
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals
|
||||
"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
|
||||
@@ -80,7 +95,7 @@
|
||||
"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": 2, // disallow unreachable statements after a return, throw, continue, or break statement
|
||||
"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
|
||||
@@ -101,7 +116,7 @@
|
||||
"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": 2, // disallow use of eval()
|
||||
"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
|
||||
@@ -114,7 +129,7 @@
|
||||
"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": 2, // disallow use of new operator for Function object
|
||||
"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";
|
||||
@@ -145,7 +160,7 @@
|
||||
"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", ignoreRestSiblings: true}], // disallow declaration of variables that are not used in the code
|
||||
"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
|
||||
@@ -159,18 +174,6 @@
|
||||
"no-restricted-modules": 1, // restrict usage of specified node modules (off by default)
|
||||
"no-sync": 0, // disallow use of synchronous methods (off by default)
|
||||
|
||||
// ESLint Comments Plugin
|
||||
// The following rules are made available via `eslint-plugin-eslint-comments`
|
||||
"eslint-comments/no-aggregating-enable": 1, // disallows eslint-enable comments for multiple eslint-disable comments
|
||||
"eslint-comments/no-unlimited-disable": 1, // disallows eslint-disable comments without rule names
|
||||
"eslint-comments/no-unused-disable": 1, // disallow disables that don't cover any errors
|
||||
"eslint-comments/no-unused-enable": 1, // // disallow enables that don't enable anything or enable rules that weren't disabled
|
||||
|
||||
// Flow Plugin
|
||||
// The following rules are made available via `eslint-plugin-flowtype`
|
||||
"flowtype/define-flow-type": 1,
|
||||
"flowtype/use-flow-type": 1,
|
||||
|
||||
// Prettier Plugin
|
||||
// https://github.com/prettier/eslint-plugin-prettier
|
||||
"prettier/prettier": [2, "fb", "@format"],
|
||||
@@ -180,12 +183,12 @@
|
||||
|
||||
"key-spacing": 0,
|
||||
"keyword-spacing": 1, // enforce spacing before and after keywords
|
||||
"jsx-quotes": [1, "prefer-double"], // enforces the usage of double quotes for all JSX attribute values which doesn’t contain a double quote
|
||||
"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, // enforces consistent naming when capturing the current execution context (off by default)
|
||||
"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)
|
||||
@@ -193,7 +196,6 @@
|
||||
"new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments
|
||||
"no-nested-ternary": 0, // disallow nested ternary expressions (off by default)
|
||||
"no-array-constructor": 1, // disallow use of the Array constructor
|
||||
"no-empty-character-class": 1, // disallow the use of empty character classes in regular expressions
|
||||
"no-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
|
||||
@@ -242,34 +244,6 @@
|
||||
"react/prop-types": 0,
|
||||
"react/react-in-jsx-scope": 1,
|
||||
"react/self-closing-comp": 1,
|
||||
"react/wrap-multilines": 0,
|
||||
|
||||
// React-Native Plugin
|
||||
// The following rules are made available via `eslint-plugin-react-native`
|
||||
|
||||
"react-native/no-inline-styles": 1,
|
||||
|
||||
// Jest Plugin
|
||||
// The following rules are made available via `eslint-plugin-jest`.
|
||||
"jest/no-disabled-tests": 1,
|
||||
"jest/no-focused-tests": 1,
|
||||
"jest/no-identical-title": 1,
|
||||
"jest/valid-expect": 1,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"local-cli/**/*.js",
|
||||
],
|
||||
"rules": {
|
||||
"lint/extra-arrow-initializer": 0,
|
||||
"no-alert": 0,
|
||||
"no-console-disallow": 0,
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
"react/wrap-multilines": 0
|
||||
}
|
||||
}
|
||||
|
||||
+7
-54
@@ -6,7 +6,7 @@
|
||||
.*/local-cli/templates/.*
|
||||
|
||||
; Ignore the Dangerfile
|
||||
<PROJECT_ROOT>/bots/dangerfile.js
|
||||
<PROJECT_ROOT>/danger/dangerfile.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
@@ -22,10 +22,8 @@
|
||||
; Ignore polyfills
|
||||
.*/Libraries/polyfills/.*
|
||||
|
||||
; These should not be required directly
|
||||
; require from fbjs/lib instead: require('fbjs/lib/invariant')
|
||||
.*/node_modules/invariant/.*
|
||||
.*/node_modules/warning/.*
|
||||
; Ignore metro
|
||||
.*/node_modules/metro/.*
|
||||
|
||||
[include]
|
||||
|
||||
@@ -37,27 +35,7 @@ flow-github/
|
||||
[options]
|
||||
emoji=true
|
||||
|
||||
esproposal.optional_chaining=enable
|
||||
esproposal.nullish_coalescing=enable
|
||||
|
||||
module.system=haste
|
||||
module.system.haste.use_name_reducers=true
|
||||
# keep the following in sync with server/haste/hasteImpl.js
|
||||
# get basename
|
||||
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
|
||||
# strip .js or .js.flow suffix
|
||||
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
|
||||
# strip .ios suffix
|
||||
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
|
||||
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
|
||||
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
|
||||
module.system.haste.paths.blacklist=.*/__tests__/.*
|
||||
module.system.haste.paths.blacklist=.*/__mocks__/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
|
||||
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
|
||||
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
@@ -68,37 +46,12 @@ suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*[react_native_oss|react_native_fb][a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*[react_native_oss|react_native_fb][a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
[lints]
|
||||
all=warn
|
||||
unnecessary-optional-chain=off
|
||||
|
||||
# There is an ESLint rule for this
|
||||
unclear-type=off
|
||||
|
||||
sketchy-null=off
|
||||
sketchy-null-number=warn
|
||||
sketchy-null-mixed=warn
|
||||
|
||||
# This is noisy for now. We *do* still want to warn on importing types
|
||||
# from untyped files, which is covered by untyped-type-import
|
||||
untyped-import=off
|
||||
|
||||
[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.85.0
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/metro/.*
|
||||
^0.61.0
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
[ignore]
|
||||
; We fork some components by platform
|
||||
.*/*[.]ios.js
|
||||
|
||||
; Ignore templates for 'react-native init'
|
||||
.*/local-cli/templates/.*
|
||||
|
||||
; Ignore the Dangerfile
|
||||
<PROJECT_ROOT>/bots/dangerfile.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Ignore unexpected extra "@providesModule"
|
||||
.*/node_modules/.*/node_modules/fbjs/.*
|
||||
|
||||
; 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
|
||||
|
||||
; Ignore polyfills
|
||||
.*/Libraries/polyfills/.*
|
||||
|
||||
; These should not be required directly
|
||||
; require from fbjs/lib instead: require('fbjs/lib/invariant')
|
||||
.*/node_modules/invariant/.*
|
||||
.*/node_modules/warning/.*
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
Libraries/react-native/react-native-interface.js
|
||||
flow/
|
||||
flow-github/
|
||||
|
||||
[options]
|
||||
emoji=true
|
||||
|
||||
esproposal.optional_chaining=enable
|
||||
esproposal.nullish_coalescing=enable
|
||||
|
||||
module.system=haste
|
||||
module.system.haste.use_name_reducers=true
|
||||
# keep the following in sync with server/haste/hasteImpl.js
|
||||
# get basename
|
||||
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
|
||||
# strip .js or .js.flow suffix
|
||||
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
|
||||
# strip .android suffix
|
||||
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
|
||||
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
|
||||
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
|
||||
module.system.haste.paths.blacklist=.*/__tests__/.*
|
||||
module.system.haste.paths.blacklist=.*/__mocks__/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
|
||||
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
|
||||
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
|
||||
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
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_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_android\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_android\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
[lints]
|
||||
all=warn
|
||||
unnecessary-optional-chain=off
|
||||
|
||||
# There is an ESLint rule for this
|
||||
unclear-type=off
|
||||
|
||||
sketchy-null=off
|
||||
sketchy-null-number=warn
|
||||
sketchy-null-mixed=warn
|
||||
|
||||
# This is noisy for now. We *do* still want to warn on importing types
|
||||
# from untyped files, which is covered by untyped-type-import
|
||||
untyped-import=off
|
||||
|
||||
[strict]
|
||||
deprecated-type
|
||||
nonstrict-import
|
||||
sketchy-null
|
||||
unclear-type
|
||||
unsafe-getters-setters
|
||||
untyped-import
|
||||
untyped-type-import
|
||||
|
||||
[version]
|
||||
^0.85.0
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/metro/.*
|
||||
+2
-1
@@ -1,3 +1,5 @@
|
||||
docs/* @hramos
|
||||
blog/* @hramos
|
||||
Libraries/Animated/* @janicduplessis
|
||||
Libraries/NativeAnimation/* @janicduplessis
|
||||
Libraries/Image/* @shergin
|
||||
@@ -7,7 +9,6 @@ React/Views/* @shergin
|
||||
React/Modules/* @shergin
|
||||
React/CxxBridge/* @mhorowitz
|
||||
ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis
|
||||
**/*.md @hramos
|
||||
package.json @hramos
|
||||
local-cli/core/* @grabbou @kureev
|
||||
local-cli/link/* @grabbou @kureev
|
||||
|
||||
+121
-2
@@ -1,3 +1,122 @@
|
||||
GitHub Issues in the `facebook/react-native` repository are used exclusively for tracking bugs in React Native.
|
||||
<!--
|
||||
PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION.
|
||||
-->
|
||||
|
||||
Please take a look at the issue templates at https://github.com/facebook/react-native/issues/new/choose before submitting a new issue. Following one of the issue templates will ensure maintainers can route your request efficiently. Thanks!
|
||||
### 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,
|
||||
the Community page at http://facebook.github.io/react-native/help.html list various resources
|
||||
that should help you get started.
|
||||
|
||||
Now scroll below!
|
||||
-->
|
||||
|
||||
### Have you read the [Contributing Guidelines](https://facebook.github.io/react-native/docs/contributing.html)?
|
||||
|
||||
(Write your answer here.)
|
||||
|
||||
### Environment
|
||||
|
||||
<!--
|
||||
In your terminal run `react-native info` and paste its contents here. Next, specify your target platform, like this:
|
||||
|
||||
Environment:
|
||||
OS: macOS Sierra 10.12.6
|
||||
Node: 8.4.0
|
||||
Yarn: 0.27.5
|
||||
npm: 5.4.0
|
||||
Watchman: 4.7.0
|
||||
Xcode: Xcode 8.3.3 Build version 8E3004b
|
||||
Android Studio: 2.3 AI-162.4069837
|
||||
|
||||
Packages: (wanted => installed)
|
||||
react-native: 0.48.1 => 0.48.1
|
||||
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
|
||||
|
||||
Target Platform: iOS (10.3)
|
||||
|
||||
***Make sure you are on v0.48.0 or greater of react-native, otherwise you may get this error:
|
||||
|
||||
Unrecognized command 'info'
|
||||
Run react-native --help to see list of all available commands
|
||||
-->
|
||||
|
||||
### 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,18 +0,0 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: Report a reproducible bug or regression in the core React Native library.
|
||||
---
|
||||
|
||||
<!-- Requirements: please go through this checklist before opening a new issue -->
|
||||
- [ ] Review the documentation: https://facebook.github.io/react-native
|
||||
- [ ] Search for existing issues: https://github.com/facebook/react-native/issues
|
||||
- [ ] Use the latest React Native release: https://github.com/facebook/react-native/releases
|
||||
|
||||
## Environment
|
||||
Run `react-native info` in your terminal and paste its contents here.
|
||||
|
||||
## Description
|
||||
Describe your issue in detail. Include screenshots if needed. If this is a regression, let us know.
|
||||
|
||||
## Reproducible Demo
|
||||
Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve
|
||||
@@ -1,18 +0,0 @@
|
||||
---
|
||||
name: 🗣 Start a Discussion
|
||||
about: Use https://github.com/react-native-community/discussions-and-proposals to propose changes or discuss feature requests.
|
||||
---
|
||||
|
||||
Use https://github.com/react-native-community/discussions-and-proposals to propose changes or discuss feature requests. This helps us ensure bug reports and regressions are given the priority they require.
|
||||
|
||||
You may also use https://discuss.reactjs.org/ for discussions on topics that are not necessarily served by the Bug Report template.
|
||||
|
||||
---
|
||||
|
||||
# For Discussion
|
||||
|
||||
<!--
|
||||
If you feel strongly about having your discussion in the main React Native repository, you may write your proposal here.
|
||||
|
||||
Please note that there is a high probability your issue will be closed by a maintainer, who may kindly ask you to move the discussion elsewhere.
|
||||
-->
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
name: 📖 Documentation Issue
|
||||
about: Report issues with the docs at https://github.com/facebook/react-native-website/issues.
|
||||
|
||||
---
|
||||
|
||||
--------------^ Click "Preview" for a nicer view!
|
||||
|
||||
GitHub Issues in the `facebook/react-native` repository are used exclusively for tracking bugs in React Native.
|
||||
|
||||
If you would like to report an issue in the React Native documentation, or anything related to the [React Native website](http://facebook.github.io/react-native), please visit https://github.com/facebook/react-native-website/issues.
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
name: 💬 Question
|
||||
about: If you need help with your React Native app, the right place to go depends on the type of help that you need.
|
||||
|
||||
---
|
||||
|
||||
--------------^ Click "Preview" for a nicer view!
|
||||
|
||||
GitHub Issues in the `facebook/react-native` repository are used exclusively for tracking bugs in React Native. GitHub may not be the ideal place to ask questions about using React Native, but we have compiled a list of resources that should help.
|
||||
|
||||
### Get help with your React Native app or ask code-level questions
|
||||
|
||||
Many members of the community use Stack Overflow to ask questions. Read through the [existing questions](http://stackoverflow.com/questions/tagged/react-native?sort=frequent) tagged with **react-native** or [ask your own](http://stackoverflow.com/questions/ask?tags=react-native)!
|
||||
|
||||
### Talk about best practices or propose changes to React Native
|
||||
|
||||
For longer-form conversations about React Native, we’ve set up a [discussion forum at **discuss.reactjs.org**](https://discuss.reactjs.org/t/welcome-react-native-community-group/10239). This forum is a great place for discussion about best practices and application architecture as well as the future of React Native.
|
||||
|
||||
### Chat with React and React Native community members
|
||||
|
||||
If you need an answer right away, check out the [Reactiflux Discord](https://discord.gg/0ZcbPKXt5bZjGY5n) community. There are usually a number of React Native experts there who can help out or point you to somewhere you might want to look.
|
||||
@@ -1,45 +1,50 @@
|
||||
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
|
||||
<!--
|
||||
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
|
||||
|
||||
Help us understand your motivation by explaining why you decided to make this change.
|
||||
|
||||
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
|
||||
You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
|
||||
|
||||
_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
|
||||
Happy contributing!
|
||||
|
||||
Test Plan:
|
||||
----------
|
||||
Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!
|
||||
-->
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
Help reviewers and the release process by writing your own changelog entry. When the change doesn't impact React Native developers, it may be ommitted from the changelog for brevity. See below for an example.
|
||||
## Motivation
|
||||
|
||||
[CATEGORY] [TYPE] - Message
|
||||
(Write your motivation here.)
|
||||
|
||||
## Test Plan
|
||||
|
||||
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
|
||||
|
||||
## Related PRs
|
||||
|
||||
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.)
|
||||
|
||||
## Release Notes
|
||||
<!--
|
||||
Help reviewers and the release process by writing your own release notes
|
||||
|
||||
CATEGORY may be:
|
||||
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
|
||||
|
||||
- [General]
|
||||
- [iOS]
|
||||
- [Android]
|
||||
CATEGORY
|
||||
[----------] TYPE
|
||||
[ CLI ] [-------------] LOCATION
|
||||
[ DOCS ] [ BREAKING ] [-------------]
|
||||
[ GENERAL ] [ BUGFIX ] [-{Component}-]
|
||||
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
|
||||
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
|
||||
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
|
||||
[----------] [-------------] [-------------] |-----------|
|
||||
|
||||
TYPE may be:
|
||||
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
|
||||
|
||||
- [Added] for new features.
|
||||
- [Changed] for changes in existing functionality.
|
||||
- [Deprecated] for soon-to-be removed features.
|
||||
- [Removed] for now removed features.
|
||||
- [Fixed] for any bug fixes.
|
||||
- [Security] in case of vulnerabilities.
|
||||
EXAMPLES:
|
||||
|
||||
For more detail, see https://keepachangelog.com/en/1.0.0/#how
|
||||
|
||||
MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.
|
||||
|
||||
EXAMPLES:
|
||||
|
||||
[General] [Added] - Add snapToOffsets prop to ScrollView component
|
||||
[General] [Fixed] - Fix various issues in snapToInterval on ScrollView component
|
||||
[iOS] [Fixed] - Fix crash in RCTImagePicker
|
||||
|
||||
-->
|
||||
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
|
||||
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
|
||||
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
|
||||
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
|
||||
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
|
||||
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Configuration for probot-no-response - https://github.com/probot/no-response
|
||||
|
||||
# Number of days of inactivity before an Issue is closed for lack of response
|
||||
daysUntilClose: 14
|
||||
# Label requiring a response
|
||||
responseRequiredLabel: Needs more information
|
||||
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
|
||||
closeComment: >
|
||||
Closing this issue as more information is needed to debug this and we have not heard back from the author.
|
||||
+7
-11
@@ -1,24 +1,20 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 90
|
||||
daysUntilStale: 60
|
||||
# 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
|
||||
- For Discussion
|
||||
- Core Team
|
||||
- "Help Wanted :octocat:"
|
||||
- ":warning:Regression"
|
||||
- ":clock1:PR Pending"
|
||||
- Core Team
|
||||
# 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 "For Discussion" or "Good first issue" and I will leave it open.
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs.
|
||||
Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people.
|
||||
If you think this issue should definitely remain open, please let us know why.
|
||||
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
|
||||
closeComment: false
|
||||
|
||||
+1
-12
@@ -36,9 +36,6 @@ buck-out
|
||||
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
|
||||
/ReactAndroid/src/main/gen
|
||||
|
||||
# Watchman
|
||||
.watchmanconfig
|
||||
|
||||
# Android
|
||||
.idea
|
||||
.gradle
|
||||
@@ -50,8 +47,7 @@ local.properties
|
||||
node_modules
|
||||
*.log
|
||||
.nvm
|
||||
/bots/node_modules/
|
||||
package-lock.json
|
||||
/danger/node_modules/
|
||||
|
||||
# OS X
|
||||
.DS_Store
|
||||
@@ -62,10 +58,3 @@ package-lock.json
|
||||
|
||||
/coverage
|
||||
/third-party
|
||||
|
||||
# Root dir shouldn't have Xcode project
|
||||
/*.xcodeproj
|
||||
|
||||
# ReactCommon subdir shouldn't have Xcode project
|
||||
/ReactCommon/**/*.xcodeproj
|
||||
RNTester/build
|
||||
|
||||
+42
-4
@@ -1,5 +1,43 @@
|
||||
# Code of Conduct
|
||||
# [Open Source Code of Conduct](https://code.facebook.com/codeofconduct)
|
||||
|
||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to.
|
||||
Please read the [full text](https://code.fb.com/codeofconduct/)
|
||||
so that you can understand what actions will and will not be tolerated.
|
||||
This code of conduct outlines our expectations for participants within the **Facebook Open Source** community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community.
|
||||
|
||||
Our open source community strives to:
|
||||
|
||||
* **Be friendly and patient.**
|
||||
* **Be welcoming:** We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
|
||||
* **Be considerate:** Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we’re a world-wide community, so you might not be communicating in someone else’s primary language.
|
||||
* **Be respectful:** Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one.
|
||||
* **Be careful in the words that you choose:** we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren’t acceptable. This includes, but is not limited to:
|
||||
* Violent threats or language directed against another person.
|
||||
* Discriminatory jokes and language.
|
||||
* Posting sexually explicit or violent material.
|
||||
* Posting (or threatening to post) other people’s personally identifying information (“doxing”).
|
||||
* Personal insults, especially those using racist or sexist terms.
|
||||
* Unwelcome sexual attention.
|
||||
* Advocating for, or encouraging, any of the above behavior.
|
||||
* Repeated harassment of others. In general, if someone asks you to stop, then stop.
|
||||
* **When we disagree, try to understand why:** Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively.
|
||||
* **Remember that we’re different.** The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.
|
||||
|
||||
This code is not exhaustive or complete. It serves to distill our common understanding of a collaborative, shared environment, and goals. We expect it to be followed in spirit as much as in the letter.
|
||||
|
||||
## Diversity Statement
|
||||
|
||||
We encourage everyone to participate and are committed to building a community for all. Although we may not be able to satisfy everyone, we all agree that everyone is equal. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong.
|
||||
|
||||
Although this list cannot be exhaustive, we explicitly honor diversity in age, gender, gender identity or expression, culture, ethnicity, language, national origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate discrimination based on any of the protected characteristics above, including participants with disabilities.
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
If you experience or witness unacceptable behavior—or have any other concerns—please report it by contacting us via opensource@fb.com. All reports will be handled with discretion. In your report please include:
|
||||
|
||||
* Your contact information.
|
||||
* Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public IRC logger), please include a link.
|
||||
* Any additional information that may be helpful.
|
||||
|
||||
After filing a report, a representative will contact you personally. If the person who is harassing you is part of the response team, they will recuse themselves from handling your incident. A representative will then review the incident, follow up with any additional questions, and make a decision as to how to respond. We will respect confidentiality requests for the purpose of protecting victims of abuse.
|
||||
|
||||
Anyone asked to stop unacceptable behavior is expected to comply immediately. If an individual engages in unacceptable behavior, the representative may take any action they deem appropriate, up to and including a permanent ban from our community without warning.
|
||||
|
||||
_This Code Of Conduct follows the [template](http://todogroup.org/opencodeofconduct/) established by the [TODO Group](http://todogroup.org/)._
|
||||
|
||||
+182
-23
@@ -1,41 +1,196 @@
|
||||
# Contributing to React Native
|
||||
|
||||
We want to make contributing to this project as easy and transparent as possible. Read on to learn more about our development process and how to propose bug fixes and improvements. The [How to Contribute](https://facebook.github.io/react-native/docs/contributing.html) guide on the website goes into more detail for each of these areas.
|
||||
<!-- generated_contributing_start -->
|
||||
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 using Facebook's mobile apps. If you're interested in contributing to React Native, hopefully this document makes the process for contributing clear.
|
||||
|
||||
## Our Development Process
|
||||
## [Code of Conduct](https://code.facebook.com/codeofconduct)
|
||||
|
||||
Most 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. The change will eventually sync back to GitHub as a single commit once it has passed Facebook's internal tests.
|
||||
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.
|
||||
|
||||
## Pull Requests
|
||||
## Get involved
|
||||
|
||||
There are many ways to contribute to React Native, and many of them do not involve writing any code. Here's a few ideas to get started:
|
||||
|
||||
* Simply start using React Native. Go through the [Getting Started](http://facebook.github.io/react-native/docs/getting-started.html) guide. Does everything work as expected? If not, we're always looking for improvements. Let us know by [opening an issue](http://facebook.github.io/react-native/docs/contributing.html#reporting-new-issues).
|
||||
* Look through the [open issues](https://github.com/facebook/react-native/issues). Provide workarounds, ask for clarification, or suggest labels. Help [triage issues](http://facebook.github.io/react-native/docs/contributing.html#triaging-issues-and-pull-requests).
|
||||
* If you find an issue you would like to fix, [open a pull request](http://facebook.github.io/react-native/docs/contributing.html#your-first-pull-request). Issues tagged as [_Good first issue_](https://github.com/facebook/react-native/labels/Good%20first%20issue) are a good place to get started.
|
||||
* Read through the [React Native docs](http://facebook.github.io/react-native/docs). If you find anything that is confusing or can be improved, you can make edits by clicking "Improve this page" at the bottom of most docs.
|
||||
* Browse [Stack Overflow](https://stackoverflow.com/questions/tagged/react-native) and answer questions. This will help you get familiarized with common pitfalls or misunderstandings, which can be useful when contributing updates to the documentation.
|
||||
* Take a look at the [features requested](https://react-native.canny.io/feature-requests) by others in the community and consider opening a pull request if you see something you want to work on.
|
||||
|
||||
Contributions are very welcome. If you think you need help planning your contribution, please hop into [#react-native](https://discord.gg/0ZcbPKXt5bZjGY5n) and let people know you're looking for a mentor.
|
||||
|
||||
Core contributors to React Native meet monthly and post their meeting notes on the [React Native blog](https://facebook.github.io/react-native/blog). You can also find ad hoc discussions in the [React Native Core Contributors](https://www.facebook.com/groups/reactnativeoss/) Facebook group.
|
||||
|
||||
### Triaging issues and pull requests
|
||||
|
||||
One great way you can contribute to the project without writing any code is to help triage issues and pull requests as they come in.
|
||||
|
||||
* Ask for more information if the issue does not provide all the details required by the template.
|
||||
* Suggest [labels](https://github.com/facebook/react-native/labels) that can help categorize issues.
|
||||
* Flag issues that are stale or that should be closed.
|
||||
* Ask for test plans and review code.
|
||||
|
||||
You can learn more about handling issues in the [maintainer's guide](docs/maintainers.html#handling-issues).
|
||||
|
||||
## Our development process
|
||||
|
||||
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.
|
||||
|
||||
When a change made on GitHub is approved, it will first be imported into Facebook's internal source control. The change will eventually sync back to GitHub as a single commit once it has passed all internal tests.
|
||||
|
||||
### Branch organization
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## Bugs
|
||||
|
||||
We use [GitHub Issues](https://github.com/facebook/react-native/issues) for our public bugs. If you would like to report a problem, take a look around and see if someone already opened an issue about it. If you a are certain this is a new, unreported bug, you can submit a [bug report](http://facebook.github.io/react-native/docs/contributing.html#reporting-new-issues).
|
||||
|
||||
If you have questions about using React Native, the [Community page](http://facebook.github.io/react-native/support.html) list various resources that should help you get started.
|
||||
|
||||
We also have a [place where you can request features or enhancements](https://react-native.canny.io/feature-requests). If you see anything you'd like to be implemented, vote it up and explain your use case.
|
||||
|
||||
## Reporting new issues
|
||||
|
||||
When [opening a new issue](https://github.com/facebook/react-native/issues/new), always make sure to fill out the [issue template](https://raw.githubusercontent.com/facebook/react-native/master/.github/ISSUE_TEMPLATE.md). **This step is very important!** Not doing so may result in your issue getting closed. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.
|
||||
|
||||
* **One issue, one bug:** Please report a single bug per issue.
|
||||
* **Provide a Snack:** The best way to get attention on your issue is to provide a reduced test case. You can use [Snack](https://snack.expo.io/) to demonstrate the issue.
|
||||
* **Provide reproduction steps:** List all the steps necessary to reproduce the issue. Provide a Snack or upload a sample project to GitHub. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort.
|
||||
* **Try out the latest version:** Verify that the issue can be reproduced locally by updating your project to use [React Native from `master`](http://facebook.github.io/react-native/versions.html). The bug may have already been fixed!
|
||||
|
||||
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) or reaching out to the community through [other channels](https://facebook.github.io/react-native/support.html).
|
||||
|
||||
### Security bugs
|
||||
|
||||
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.
|
||||
|
||||
## Pull requests
|
||||
|
||||
### Your first pull request
|
||||
|
||||
So you have decided to contribute code back to upstream by opening a pull request. You've invested a good chunk of time, and we appreciate it. We will do our best to work with you and get the PR looked at.
|
||||
|
||||
Working on your first Pull Request? You can learn how from this free video series:
|
||||
|
||||
[**How to Contribute to an Open Source Project on GitHub**](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
|
||||
|
||||
We have a list of [beginner friendly issues](https://github.com/facebook/react-native/labels/Good%20First%20Task) to help you get your feet wet in the React Native codebase and familiar with our contribution process. This is a great place to get started.
|
||||
|
||||
### Proposing a change
|
||||
|
||||
If you would like to request a new feature or enhancement but are not yet thinking about opening a pull request, we have a [place to track feature requests](https://react-native.canny.io/feature-requests).
|
||||
|
||||
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?title=%5BProposal%5D) that includes `[Proposal]` in the title. This lets us reach an agreement on your proposal before you put significant effort into it. These types of issues should be rare. If you have been contributing to the project long enough, you will probably already have access to the [React Native Core Contributors](https://www.facebook.com/groups/reactnativeoss/) Facebook Group, where this sort of discussion is usually held.
|
||||
|
||||
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.
|
||||
|
||||
### Sending a pull request
|
||||
|
||||
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.
|
||||
|
||||
Please make sure the following is done when submitting a pull request:
|
||||
|
||||
1. Fork the repo and create your branch from `master`.
|
||||
2. If you've added code that should be tested, add tests.
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Ensure the test suite passes.
|
||||
5. Make sure your code lints.
|
||||
6. If you haven't already, complete the Contributor License Agreement ("CLA").
|
||||
1. Fork [the repository](https://github.com/facebook/react-native) 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**](https://facebook.github.io/react-native/docs/contributing.html#test-plan) in your pull request description. Make sure to [test your changes](https://facebook.github.io/react-native/docs/testing.html)!
|
||||
4. Make sure your code lints (`npm run lint`).
|
||||
5. If you haven't already, [sign the CLA](https://code.facebook.com/cla).
|
||||
|
||||
## Contributor License Agreement ("CLA")
|
||||
All pull requests should be opened against the `master` branch. After opening your pull request, ensure [**all tests pass**](https://facebook.github.io/react-native/docs/contributing.html#contrinuous-integration-tests) on Circle CI. If a test fails and you believe it is unrelated to your change, leave a comment on the pull request explaining why.
|
||||
|
||||
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects.
|
||||
> **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.
|
||||
|
||||
Complete your CLA here: <https://code.facebook.com/cla>
|
||||
#### Test plan
|
||||
|
||||
## Issues
|
||||
A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI.
|
||||
|
||||
We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.
|
||||
* If you've added code that should be tested, add tests!
|
||||
* If you've changed APIs, update the documentation.
|
||||
|
||||
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.
|
||||
See [What is a Test Plan?](https://medium.com/@martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9) to learn more.
|
||||
|
||||
## Coding Style
|
||||
#### Continuous integration tests
|
||||
|
||||
We use Prettier to format our JavaScript code. This saves you time and energy as you can let Prettier fix up any formatting issues automatically through its editor integrations, or by manually running `npm run prettier`. We also use a linter to catch styling issues that may exist in your code. You can check the status of your code styling by simply running `npm run lint`.
|
||||
Make sure all **tests pass** on [Circle CI][circle]. PRs that break tests are unlikely to be merged. Learn more about [testing your changes here](https://facebook.github.io/react-native/docs/testing.html).
|
||||
|
||||
However, there are still some styles that the linter cannot pick up, notably in Java or Objective-C code.
|
||||
[circle]: http://circleci.com/gh/facebook/react-native
|
||||
|
||||
**Objective-C:**
|
||||
#### 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, the Facebook GitHub Bot will reply with a link to the CLA form. You may also [complete your CLA here](https://code.facebook.com/cla).
|
||||
|
||||
### What happens next?
|
||||
|
||||
The core team will be monitoring for pull requests. Read [what to expect from maintainers](https://facebook.github.io/react-native/docs/maintainers.html#handling-pull-requests) to understand what may happen after you open a pull request.
|
||||
|
||||
## 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 `npm run lint`.
|
||||
|
||||
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;
|
||||
* ES6 standards
|
||||
* 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
|
||||
@@ -43,13 +198,17 @@ However, there are still some styles that the linter cannot pick up, notably in
|
||||
* *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:**
|
||||
#### 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 the LICENSE file in the root directory of this source tree.
|
||||
By contributing to React Native, you agree that your contributions will be licensed under its BSD license.
|
||||
<!-- generated_contributing_end -->
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
# 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.
|
||||
|
||||
# React Native Android Unit Tests
|
||||
#
|
||||
# This image builds upon the React Native Base Android Development Environment
|
||||
# image. Ideally, this image would be rebuilt with any new commit to the master
|
||||
# branch. Doing so will catch issues such as BUCK failing to fetch dependencies
|
||||
# or run tests, as well as unit test failures.
|
||||
FROM reactnativeci/android-base:latest
|
||||
|
||||
LABEL Description="This image prepares and runs React Native's Android tests."
|
||||
LABEL maintainer="Héctor Ramos <hector@fb.com>"
|
||||
FROM containership/android-base:latest
|
||||
|
||||
# set default environment variables
|
||||
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
|
||||
ENV GRADLE_OPTS="-Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
|
||||
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
|
||||
|
||||
# add ReactAndroid directory
|
||||
@@ -23,7 +9,6 @@ ADD .buckconfig /app/.buckconfig
|
||||
ADD .buckjavaargs /app/.buckjavaargs
|
||||
ADD ReactAndroid /app/ReactAndroid
|
||||
ADD ReactCommon /app/ReactCommon
|
||||
ADD ReactNative /app/ReactNative
|
||||
ADD keystores /app/keystores
|
||||
|
||||
# set workdir
|
||||
@@ -50,18 +35,20 @@ ADD react.gradle /app/react.gradle
|
||||
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
|
||||
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 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
RUN apt-get install apt-transport-https
|
||||
RUN apt-get update
|
||||
RUN apt-get install yarn
|
||||
RUN yarn
|
||||
RUN npm install
|
||||
RUN npm install github@0.2.4
|
||||
|
||||
WORKDIR /app/website
|
||||
RUN npm install
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -1,41 +1,18 @@
|
||||
# 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.
|
||||
|
||||
# React Native Base Android Development Environment
|
||||
#
|
||||
# This image provides a base Android development environment for React Native,
|
||||
# including, but not limited to, the Android SDK, Android NDK, Node, and BUCK.
|
||||
# These are required in order to run React Native's Android unit and integration
|
||||
# tests.
|
||||
#
|
||||
# This image is not currently built automatically as part of React Native's CI
|
||||
# infrastructure. It should not be necessary to rebuild this image while the
|
||||
# Android dependencies (Android SDK version, build tools version, etc) remain
|
||||
# equal. The operations performed to build this image are those that tend to
|
||||
# remain stable across commits in any given React Native release.
|
||||
|
||||
FROM library/ubuntu:16.04
|
||||
|
||||
LABEL Description="This image provides a base Android development environment for React Native, and may be used to run tests."
|
||||
LABEL maintainer="Héctor Ramos <hector@fb.com>"
|
||||
|
||||
# set default build arguments
|
||||
ARG SDK_VERSION=sdk-tools-linux-3859397.zip
|
||||
ARG ANDROID_BUILD_VERSION=28
|
||||
ARG ANDROID_TOOLS_VERSION=28.0.3
|
||||
ARG BUCK_VERSION=v2018.10.29.01
|
||||
ARG NDK_VERSION=17c
|
||||
ARG NODE_VERSION=8.10.0
|
||||
ARG WATCHMAN_VERSION=4.9.0
|
||||
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}/tools/bin:${ANDROID_HOME}/platform-tools
|
||||
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}
|
||||
|
||||
@@ -43,41 +20,82 @@ ENV PATH=${PATH}:${ANDROID_NDK}
|
||||
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 && \
|
||||
npm config set progress=false
|
||||
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 --branch $BUCK_VERSION --depth=1
|
||||
RUN git clone https://github.com/facebook/buck.git /opt/buck
|
||||
WORKDIR /opt/buck
|
||||
RUN git checkout $BUCK_VERSION
|
||||
|
||||
# build buck
|
||||
RUN ant
|
||||
|
||||
# Full reference at https://dl.google.com/android/repository/repository2-1.xml
|
||||
# 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 && \
|
||||
cd /opt/android && \
|
||||
curl --silent https://dl.google.com/android/repository/${SDK_VERSION} > android.zip && \
|
||||
unzip android.zip && \
|
||||
rm android.zip
|
||||
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 && \
|
||||
cd /opt/ndk && \
|
||||
curl --silent https://dl.google.com/android/repository/android-ndk-r$NDK_VERSION-linux-x86_64.zip > ndk.zip && \
|
||||
unzip ndk.zip && \
|
||||
rm ndk.zip
|
||||
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
|
||||
RUN sdkmanager "system-images;android-19;google_apis;armeabi-v7a" \
|
||||
"platforms;android-$ANDROID_BUILD_VERSION" \
|
||||
"build-tools;$ANDROID_TOOLS_VERSION" \
|
||||
"add-ons;addon-google_apis-google-23" \
|
||||
"extras;android;m2repository"
|
||||
|
||||
# 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
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# 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.
|
||||
|
||||
FROM library/node:6.9.2
|
||||
|
||||
ENV YARN_VERSION=0.27.5
|
||||
|
||||
@@ -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,10 +41,10 @@ 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;
|
||||
|
||||
@@ -87,7 +91,7 @@ return async.mapSeries(testClasses, (clazz, callback) => {
|
||||
|
||||
return async.retry(test_opts.RETRIES, (retryCb) => {
|
||||
const test_process = child_process.spawn('./ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
|
||||
stdio: 'inherit',
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
@@ -111,7 +115,7 @@ return async.mapSeries(testClasses, (clazz, callback) => {
|
||||
}, (err) => {
|
||||
return callback(null, {
|
||||
name: clazz,
|
||||
status: err ? 'failure' : 'success',
|
||||
status: err ? 'failure' : 'success'
|
||||
});
|
||||
});
|
||||
}, (err, results) => {
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/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
|
||||
@@ -12,7 +6,7 @@ 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
|
||||
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 &
|
||||
@@ -34,9 +28,8 @@ watchman shutdown-server
|
||||
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
|
||||
# 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
|
||||
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 "$*"
|
||||
node ./ContainerShip/scripts/run-android-ci-instrumentation-tests.js $*
|
||||
exit $?
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/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}"
|
||||
@@ -15,4 +9,4 @@ mount -o remount,exec /dev/shm
|
||||
set -x
|
||||
|
||||
# run unit tests
|
||||
buck test ReactAndroid/src/test/... --config build.threads="$UNIT_TESTS_BUILD_THREADS"
|
||||
buck test ReactAndroid/src/test/... --config build.threads=$UNIT_TESTS_BUILD_THREADS
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/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
|
||||
|
||||
@@ -18,12 +12,11 @@ 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)
|
||||
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"
|
||||
# Version of react-native-dummy to test against
|
||||
REACT_DUMMY_PLATFORM=react-native-dummy@0.1.0
|
||||
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
|
||||
@@ -34,7 +27,7 @@ watchman shutdown-server
|
||||
# $2 -- command to run
|
||||
function retry() {
|
||||
local -r -i max_attempts="$1"; shift
|
||||
local -r cmd="$*"
|
||||
local -r cmd="$@"
|
||||
local -i attempt_num=1
|
||||
|
||||
until $cmd; do
|
||||
@@ -82,7 +75,7 @@ while :; do
|
||||
done
|
||||
|
||||
function e2e_suite() {
|
||||
cd "$ROOT"
|
||||
cd $ROOT
|
||||
|
||||
if [ $RUN_ANDROID -eq 0 ] && [ $RUN_IOS -eq 0 ] && [ $RUN_JS -eq 0 ]; then
|
||||
echo "No e2e tests specified!"
|
||||
@@ -95,8 +88,8 @@ function e2e_suite() {
|
||||
# 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)"
|
||||
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
|
||||
@@ -105,8 +98,8 @@ function e2e_suite() {
|
||||
|
||||
# can skip cli install for non sudo mode
|
||||
if [ $RUN_CLI_INSTALL -ne 0 ]; then
|
||||
if ! npm install -g "$CLI_PACKAGE"
|
||||
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
|
||||
@@ -118,7 +111,7 @@ function e2e_suite() {
|
||||
|
||||
# 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
|
||||
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
|
||||
@@ -131,10 +124,9 @@ function e2e_suite() {
|
||||
fi
|
||||
|
||||
# emulator setup
|
||||
emulator64-arm -avd "$AVD_UUID" -no-skin -no-audio -no-window -no-boot-anim &
|
||||
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)
|
||||
@@ -143,23 +135,23 @@ function e2e_suite() {
|
||||
|
||||
set -ex
|
||||
|
||||
if ! ./gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"
|
||||
then
|
||||
./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
|
||||
|
||||
if ! npm pack
|
||||
then
|
||||
npm pack
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to pack react-native"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd "$TEMP_DIR"
|
||||
cd $TEMP_DIR
|
||||
|
||||
if ! retry "$RETRY_COUNT" react-native init EndToEndTest --version "$PACKAGE" --npm
|
||||
then
|
||||
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
|
||||
@@ -172,21 +164,20 @@ function e2e_suite() {
|
||||
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
|
||||
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
|
||||
cp $SCRIPTS/android-e2e-test.js android-e2e-test.js
|
||||
|
||||
(
|
||||
cd android || exit
|
||||
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 &
|
||||
@@ -197,8 +188,9 @@ function e2e_suite() {
|
||||
buck build android/app
|
||||
|
||||
# hack to get node unhung (kill buckd)
|
||||
if ! kill -9 "$(pgrep java)"
|
||||
then
|
||||
kill -9 $(pgrep java)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "could not execute Buck build, is it installed and in PATH?"
|
||||
return 1
|
||||
fi
|
||||
@@ -209,23 +201,23 @@ function e2e_suite() {
|
||||
sleep 15
|
||||
|
||||
echo "Executing android e2e test"
|
||||
if ! retry "$RETRY_COUNT" node node_modules/.bin/_mocha android-e2e-test.js
|
||||
then
|
||||
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
|
||||
if kill -0 $SERVER_PID; then
|
||||
echo "Killing packager $SERVER_PID"
|
||||
kill -9 "$SERVER_PID"
|
||||
kill -9 $SERVER_PID
|
||||
fi
|
||||
|
||||
# kill appium process
|
||||
if kill -0 "$APPIUM_PID"; then
|
||||
if kill -0 $APPIUM_PID; then
|
||||
echo "Killing appium $APPIUM_PID"
|
||||
kill -9 "$APPIUM_PID"
|
||||
kill -9 $APPIUM_PID
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -238,37 +230,24 @@ function e2e_suite() {
|
||||
# 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
|
||||
react-native bundle --max-workers 1 --platform android --dev true --entry-file index.js --bundle-output android-bundle.js
|
||||
if [ $? -ne 0 ]; 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
|
||||
react-native bundle --max-workers 1 --platform ios --dev true --entry-file index.js --bundle-output ios-bundle.js
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not build iOS bundle"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! retry "$RETRY_COUNT" npm install --save "$REACT_DUMMY_PLATFORM" --silent >> /dev/null
|
||||
then
|
||||
echo "Failed to install react-native-dummy"
|
||||
echo "Most common reason is npm registry connectivity, try again"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! react-native bundle --max-workers 1 --platform dummy --dev true --entry-file index.js --bundle-output dummy-bundle.js
|
||||
then
|
||||
echo "Could not build dummy bundle"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# directory cleanup
|
||||
rm "$IOS_MARKER"
|
||||
rm "$ANDROID_MARKER"
|
||||
rm $IOS_MARKER
|
||||
rm $ANDROID_MARKER
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
retry "$RETRY_COUNT" e2e_suite
|
||||
retry $RETRY_COUNT e2e_suite
|
||||
|
||||
@@ -1,12 +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
|
||||
#
|
||||
@@ -16,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
|
||||
@@ -31,7 +24,7 @@ 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:
|
||||
@@ -45,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()
|
||||
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ See <https://docs.docker.com/engine/installation/> for more information on how t
|
||||
|
||||
We have added a number of default run scripts to the `package.json` file to simplify building and running your tests.
|
||||
|
||||
`npm run docker-setup-android` - Pulls down the base android docker image used for running the tests
|
||||
`npm run test-android-setup` - Pulls down the base android docker image used for running the tests
|
||||
|
||||
`npm run docker-build-android` - Builds the docker image used to run 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)
|
||||
|
||||
@@ -35,7 +35,7 @@ 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 dependencies for running android and the emulators (~9GB).
|
||||
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.
|
||||
|
||||
@@ -1,36 +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 AccessibilityManagerTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {View} = ReactNative;
|
||||
const { View } = ReactNative;
|
||||
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
const {TestModule, AccessibilityManager} = ReactNative.NativeModules;
|
||||
const {
|
||||
TestModule,
|
||||
AccessibilityManager,
|
||||
} = ReactNative.NativeModules;
|
||||
|
||||
|
||||
class AccessibilityManagerTest extends React.Component<{}> {
|
||||
componentDidMount() {
|
||||
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,
|
||||
'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,
|
||||
});
|
||||
RCTDeviceEventEmitter.addListener('didUpdateDimensions', update => {
|
||||
TestModule.markTestPassed(update.window.fontScale === 4.0);
|
||||
|
||||
@@ -1,25 +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 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('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,
|
||||
@@ -31,7 +37,7 @@ class AppEventsTest extends React.Component<{}, State> {
|
||||
|
||||
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});
|
||||
}
|
||||
@@ -40,7 +46,7 @@ class AppEventsTest extends React.Component<{}, State> {
|
||||
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();
|
||||
});
|
||||
@@ -49,7 +55,9 @@ class AppEventsTest extends React.Component<{}, State> {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>{JSON.stringify(this.state, null, ' ')}</Text>
|
||||
<Text>
|
||||
{JSON.stringify(this.state, null, ' ')}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -57,7 +65,7 @@ class AppEventsTest extends React.Component<{}, State> {
|
||||
|
||||
AppEventsTest.displayName = 'AppEventsTest';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
margin: 40,
|
||||
},
|
||||
|
||||
@@ -1,57 +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('deepDiffer');
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function expectEqual(lhs, rhs, testname: string) {
|
||||
function expectEqual(lhs, rhs, testname : string) {
|
||||
expectTrue(
|
||||
!deepDiffer(lhs, rhs),
|
||||
'Error in test ' +
|
||||
testname +
|
||||
': expected\n' +
|
||||
JSON.stringify(rhs) +
|
||||
'\ngot\n' +
|
||||
JSON.stringify(lhs),
|
||||
'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) +
|
||||
'\ngot\n' + JSON.stringify(lhs)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,14 +61,11 @@ function expectAsyncNoError(place, err) {
|
||||
if (err instanceof Error) {
|
||||
err = err.message;
|
||||
}
|
||||
expectTrue(
|
||||
err === null,
|
||||
'Unexpected error in ' + place + ': ' + JSON.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);
|
||||
@@ -87,8 +86,8 @@ function testMissingGet() {
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -100,16 +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(
|
||||
result.indexOf(KEY_1) >= 0 && result.indexOf(KEY_2) >= 0,
|
||||
'Missing KEY_1 or KEY_2 in ' + '(' + result + ')',
|
||||
'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) => {
|
||||
@@ -117,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(
|
||||
result3.indexOf(KEY_1) === -1,
|
||||
'Unexpected: KEY_1 present in ' + result3,
|
||||
);
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -137,9 +136,9 @@ function testRemoveItem() {
|
||||
}
|
||||
|
||||
function testMerge() {
|
||||
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), err1 => {
|
||||
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), (err1) => {
|
||||
expectAsyncNoError('testMerge/setItem', err1);
|
||||
AsyncStorage.mergeItem(KEY_MERGE, JSON.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);
|
||||
@@ -154,23 +153,21 @@ function testMerge() {
|
||||
function testOptimizedMultiGet() {
|
||||
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 ' +
|
||||
JSON.stringify(result),
|
||||
);
|
||||
updateMessage('multiGet([key_1, key_2]) correctly returned ' + JSON.stringify(result));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> {
|
||||
state = {
|
||||
messages: 'Initializing...',
|
||||
@@ -178,11 +175,10 @@ class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> {
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
@@ -191,12 +187,13 @@ class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This
|
||||
{
|
||||
/* $FlowFixMe(>=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>
|
||||
@@ -205,13 +202,6 @@ class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 40,
|
||||
},
|
||||
});
|
||||
|
||||
AsyncStorageTest.displayName = 'AsyncStorageTest';
|
||||
|
||||
module.exports = AsyncStorageTest;
|
||||
|
||||
@@ -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,25 +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 = {};
|
||||
state = {}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -58,48 +61,40 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{flex: 1}}>
|
||||
<Text>Hello</Text>
|
||||
<Image
|
||||
source={{
|
||||
uri: 'https://facebook.github.io/react-native/img/favicon.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://facebook.github.io/react-native/img/favicon.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://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'default',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'default'
|
||||
}}
|
||||
onLoad={() => this.testComplete('default', true)}
|
||||
onError={() => this.testComplete('default', false)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'reload',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'reload'
|
||||
}}
|
||||
onLoad={() => this.testComplete('reload', true)}
|
||||
onError={() => this.testComplete('reload', false)}
|
||||
style={styles.base}
|
||||
/>
|
||||
<Image
|
||||
source={{
|
||||
uri:
|
||||
'https://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' +
|
||||
Date.now(),
|
||||
cache: 'force-cache',
|
||||
}}
|
||||
uri: 'https://facebook.github.io/react-native/img/favicon.png?cacheBust=notinCache' + Date.now(),
|
||||
cache: 'force-cache'
|
||||
}}
|
||||
onLoad={() => this.testComplete('force-cache', true)}
|
||||
onError={() => this.testComplete('force-cache', false)}
|
||||
style={styles.base}
|
||||
@@ -110,9 +105,6 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
base: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
/**
|
||||
* 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<{}> {
|
||||
componentDidMount() {
|
||||
@@ -22,7 +26,7 @@ class ImageSnapshotTest extends React.Component<{}> {
|
||||
}
|
||||
}
|
||||
|
||||
done = (success: boolean) => {
|
||||
done = (success : boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
|
||||
@@ -31,8 +35,7 @@ class ImageSnapshotTest extends React.Component<{}> {
|
||||
<Image
|
||||
source={require('./blue_square.png')}
|
||||
defaultSource={require('./red_square.png')}
|
||||
onLoad={() => TestModule.verifySnapshot(this.done)}
|
||||
/>
|
||||
onLoad={() => TestModule.verifySnapshot(this.done)} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +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 requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {Text, View, StyleSheet} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
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;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
class IntegrationTestHarnessTest extends React.Component<{
|
||||
shouldThrow?: boolean,
|
||||
waitOneFrame?: boolean,
|
||||
|}>;
|
||||
}, $FlowFixMeState> {
|
||||
static propTypes = {
|
||||
shouldThrow: PropTypes.bool,
|
||||
waitOneFrame: PropTypes.bool,
|
||||
};
|
||||
|
||||
type State = {|
|
||||
done: boolean,
|
||||
|};
|
||||
|
||||
class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
state = {
|
||||
done: false,
|
||||
};
|
||||
@@ -54,12 +61,13 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 40}}>
|
||||
<Text>
|
||||
{/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This
|
||||
{
|
||||
/* $FlowFixMe(>=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>
|
||||
@@ -67,13 +75,6 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
padding: 40,
|
||||
},
|
||||
});
|
||||
|
||||
IntegrationTestHarnessTest.displayName = 'IntegrationTestHarnessTest';
|
||||
|
||||
module.exports = IntegrationTestHarnessTest;
|
||||
|
||||
@@ -1,18 +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';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
@@ -22,7 +23,7 @@ const {
|
||||
} = ReactNative;
|
||||
|
||||
// Keep this list in sync with RNTesterIntegrationTests.m
|
||||
const TESTS = [
|
||||
var TESTS = [
|
||||
require('./IntegrationTestHarnessTest'),
|
||||
require('./TimersTest'),
|
||||
require('./AsyncStorageTest'),
|
||||
@@ -42,7 +43,7 @@ TESTS.forEach(
|
||||
/* $FlowFixMe(>=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
|
||||
@@ -70,18 +71,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})}
|
||||
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>
|
||||
@@ -89,7 +92,7 @@ class IntegrationTestsApp extends React.Component<{}, $FlowFixMeState> {
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'white',
|
||||
marginTop: 40,
|
||||
|
||||
@@ -1,31 +1,43 @@
|
||||
/**
|
||||
* 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 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 'StyleSheet';
|
||||
|
||||
const deepDiffer = require('deepDiffer');
|
||||
var deepDiffer = require('deepDiffer');
|
||||
|
||||
function debug(...args) {
|
||||
// console.log.apply(null, arguments);
|
||||
}
|
||||
|
||||
import type {Layout, LayoutEvent} from 'CoreEventTypes';
|
||||
|
||||
type Props = $ReadOnly<{||}>;
|
||||
type Style = {
|
||||
margin?: number,
|
||||
padding?: number,
|
||||
borderColor?: string,
|
||||
borderWidth?: number,
|
||||
backgroundColor?: string,
|
||||
width?: number,
|
||||
};
|
||||
|
||||
type State = {
|
||||
didAnimation: boolean,
|
||||
@@ -33,58 +45,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 = () => {
|
||||
},
|
||||
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 = () => {
|
||||
},
|
||||
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) => {
|
||||
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) {
|
||||
@@ -93,69 +95,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) => {
|
||||
},
|
||||
onViewLayout: function(e: LayoutEvent) {
|
||||
debug('received view layout event\n', e.nativeEvent);
|
||||
this.setState({viewLayout: e.nativeEvent.layout}, this.checkLayout);
|
||||
};
|
||||
|
||||
onTextLayout = (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) => {
|
||||
},
|
||||
onImageLayout: function(e: LayoutEvent) {
|
||||
debug('received image layout event\n', e.nativeEvent);
|
||||
this.setState({imageLayout: e.nativeEvent.layout}, this.checkLayout);
|
||||
};
|
||||
|
||||
render() {
|
||||
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>
|
||||
@@ -167,9 +149,9 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
margin: 40,
|
||||
},
|
||||
@@ -193,4 +175,6 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
LayoutEventsTest.displayName = 'LayoutEventsTest';
|
||||
|
||||
module.exports = LayoutEventsTest;
|
||||
|
||||
@@ -1,24 +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
|
||||
* @providesModule LoggingTestModule
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const BatchedBridge = require('BatchedBridge');
|
||||
var BatchedBridge = require('BatchedBridge');
|
||||
|
||||
const warning = require('fbjs/lib/warning');
|
||||
const invariant = require('fbjs/lib/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);
|
||||
@@ -34,9 +35,12 @@ const LoggingTestModule = {
|
||||
},
|
||||
throwError: function(str) {
|
||||
throw new Error(str);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
BatchedBridge.registerCallableModule('LoggingTestModule', LoggingTestModule);
|
||||
BatchedBridge.registerCallableModule(
|
||||
'LoggingTestModule',
|
||||
LoggingTestModule
|
||||
);
|
||||
|
||||
module.exports = LoggingTestModule;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/**
|
||||
* 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 = false;
|
||||
@@ -27,26 +28,24 @@ 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 = () => {
|
||||
return TestModule.shouldResolve()
|
||||
.then(() => (this.shouldResolve = true))
|
||||
.catch(() => (this.shouldResolve = false));
|
||||
return TestModule
|
||||
.shouldResolve()
|
||||
.then(() => this.shouldResolve = true)
|
||||
.catch(() => this.shouldResolve = false);
|
||||
};
|
||||
|
||||
testShouldReject = () => {
|
||||
return TestModule.shouldReject()
|
||||
.then(() => (this.shouldReject = false))
|
||||
.catch(() => (this.shouldReject = true));
|
||||
return TestModule
|
||||
.shouldReject()
|
||||
.then(() => this.shouldReject = false)
|
||||
.catch(() => this.shouldReject = true);
|
||||
};
|
||||
|
||||
testShouldSucceedAsync = async (): Promise<any> => {
|
||||
|
||||
@@ -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
|
||||
* 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 React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
|
||||
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 EmitterSubscription from 'EmitterSubscription';
|
||||
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: ?EmitterSubscription = null;
|
||||
|
||||
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) => {
|
||||
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() {
|
||||
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,24 +1,28 @@
|
||||
/**
|
||||
* 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 SimpleSnapshotTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
const requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
||||
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<{}> {
|
||||
componentDidMount() {
|
||||
@@ -28,13 +32,13 @@ class SimpleSnapshotTest extends React.Component<{}> {
|
||||
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
||||
}
|
||||
|
||||
done = (success: boolean) => {
|
||||
done = (success : boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={{backgroundColor: 'white', padding: 100}}>
|
||||
<View style={styles.box1} />
|
||||
<View style={styles.box2} />
|
||||
</View>
|
||||
@@ -42,11 +46,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,60 +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
|
||||
* 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 React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const RCTNativeAppEventEmitter = require('RCTNativeAppEventEmitter');
|
||||
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 EmitterSubscription from 'EmitterSubscription';
|
||||
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: ?EmitterSubscription = 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 = () => {
|
||||
markPassed: function() {
|
||||
TestModule.markTestPassed(true);
|
||||
finalState = true;
|
||||
};
|
||||
},
|
||||
|
||||
rootViewDidChangeIntrinsicSize: function(intrinsicSize) {
|
||||
|
||||
rootViewDidChangeIntrinsicSize = (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);
|
||||
@@ -62,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() {
|
||||
return <View style={{height: reactViewHeight, width: reactViewWidth}} />;
|
||||
return (
|
||||
<View style={{'height':reactViewHeight, 'width':reactViewWidth}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SizeFlexibilityUpdateTest.displayName = 'SizeFlexibilityUpdateTest';
|
||||
|
||||
module.exports = SizeFlexibilityUpdateTest;
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
/**
|
||||
* 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<{}> {
|
||||
componentDidMount() {
|
||||
if (
|
||||
RNTesterTestModule.echoString('test string value') !== 'test string value'
|
||||
) {
|
||||
if (RNTesterTestModule.echoString('test string value') !== 'test string value') {
|
||||
throw new Error('Something wrong with sync method export');
|
||||
}
|
||||
if (RNTesterTestModule.methodThatReturnsNil() != null) {
|
||||
|
||||
+71
-169
@@ -1,270 +1,172 @@
|
||||
/**
|
||||
* 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');
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
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 = {
|
||||
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() {
|
||||
this.setTimeout(this.testSetTimeout0, 1000);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout0() {
|
||||
this.setTimeout(this.testSetTimeout1, 0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout1() {
|
||||
this.setTimeout(this.testSetTimeout50, 1);
|
||||
}
|
||||
},
|
||||
|
||||
testSetTimeout50() {
|
||||
this.setTimeout(this.testRequestAnimationFrame, 50);
|
||||
}
|
||||
},
|
||||
|
||||
testRequestAnimationFrame() {
|
||||
this.requestAnimationFrame(this.testSetInterval0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetInterval0() {
|
||||
this._nextTest = this.testSetInterval20;
|
||||
this._interval = this.setInterval(this._incrementInterval, 0);
|
||||
}
|
||||
},
|
||||
|
||||
testSetInterval20() {
|
||||
this._nextTest = this.testSetImmediate;
|
||||
this._interval = this.setInterval(this._incrementInterval, 20);
|
||||
}
|
||||
},
|
||||
|
||||
testSetImmediate() {
|
||||
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);
|
||||
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);
|
||||
|
||||
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
|
||||
);
|
||||
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() {
|
||||
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;
|
||||
}
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
TimersTest.displayName = 'TimersTest';
|
||||
|
||||
module.exports = TimersTest;
|
||||
|
||||
@@ -1,33 +1,45 @@
|
||||
/**
|
||||
* 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> {
|
||||
@@ -39,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;
|
||||
@@ -53,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);
|
||||
@@ -70,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) {
|
||||
@@ -106,7 +119,7 @@ class WebSocketTest extends React.Component<{}, State> {
|
||||
};
|
||||
|
||||
_receivedTestExpectedResponse = () => {
|
||||
return this.state.lastMessage === this.state.testExpectedResponse;
|
||||
return (this.state.lastMessage === this.state.testExpectedResponse);
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -114,33 +127,36 @@ class WebSocketTest extends React.Component<{}, State> {
|
||||
}
|
||||
|
||||
testConnect = () => {
|
||||
this._connect();
|
||||
this._waitFor(this._socketIsConnected, 5, connectSucceeded => {
|
||||
var component = this;
|
||||
component._connect();
|
||||
component._waitFor(component._socketIsConnected, 5, function(connectSucceeded) {
|
||||
if (!connectSucceeded) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
}
|
||||
this.testSendAndReceive();
|
||||
component.testSendAndReceive();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
testSendAndReceive = () => {
|
||||
this._sendTestMessage();
|
||||
this._waitFor(this._receivedTestExpectedResponse, 5, messageReceived => {
|
||||
var component = this;
|
||||
component._sendTestMessage();
|
||||
component._waitFor(component._receivedTestExpectedResponse, 5, function(messageReceived) {
|
||||
if (!messageReceived) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
}
|
||||
this.testDisconnect();
|
||||
component.testDisconnect();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
testDisconnect = () => {
|
||||
this._disconnect();
|
||||
this._waitFor(this._socketIsDisconnected, 5, disconnectSucceeded => {
|
||||
var component = this;
|
||||
component._disconnect();
|
||||
component._waitFor(component._socketIsDisconnected, 5, function(disconnectSucceeded) {
|
||||
TestModule.markTestPassed(disconnectSucceeded);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
return <View />;
|
||||
|
||||
@@ -1,71 +1,57 @@
|
||||
/**
|
||||
* 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 WebViewTest
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {WebView} = ReactNative;
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {
|
||||
WebView,
|
||||
} = ReactNative;
|
||||
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
var { TestModule } = ReactNative.NativeModules;
|
||||
|
||||
class WebViewTest extends React.Component {
|
||||
|
||||
render() {
|
||||
let firstMessageReceived = false;
|
||||
let secondMessageReceived = false;
|
||||
var firstMessageReceived = false;
|
||||
var secondMessageReceived = false;
|
||||
function processMessage(e) {
|
||||
const message = e.nativeEvent.data;
|
||||
if (message === 'First') {
|
||||
firstMessageReceived = true;
|
||||
}
|
||||
if (message === 'Second') {
|
||||
secondMessageReceived = true;
|
||||
}
|
||||
var message = e.nativeEvent.data;
|
||||
if (message === 'First') {firstMessageReceived = true;}
|
||||
if (message === 'Second') {secondMessageReceived = true;}
|
||||
|
||||
// got both messages
|
||||
if (firstMessageReceived && secondMessageReceived) {
|
||||
TestModule.markTestPassed(true);
|
||||
}
|
||||
if (firstMessageReceived && secondMessageReceived) {TestModule.markTestPassed(true);}
|
||||
// wait for next message
|
||||
else if (firstMessageReceived && !secondMessageReceived) {
|
||||
return;
|
||||
}
|
||||
else if (firstMessageReceived && !secondMessageReceived) {return;}
|
||||
// first message got lost
|
||||
else if (!firstMessageReceived && secondMessageReceived) {
|
||||
throw new Error('First message got lost');
|
||||
}
|
||||
else if (!firstMessageReceived && secondMessageReceived) {throw new Error('First message got lost');}
|
||||
}
|
||||
const html =
|
||||
'Hello world' +
|
||||
'<script>' +
|
||||
"window.setTimeout(function(){window.postMessage('First'); window.postMessage('Second')}, 0)" +
|
||||
'</script>';
|
||||
var html = 'Hello world'
|
||||
+ '<script>'
|
||||
+ "window.setTimeout(function(){window.postMessage('First'); window.postMessage('Second')}, 0)"
|
||||
+ '</script>';
|
||||
|
||||
// fail if messages didn't get through;
|
||||
window.setTimeout(function() {
|
||||
throw new Error(
|
||||
firstMessageReceived
|
||||
? 'Both messages got lost'
|
||||
: 'Second message got lost',
|
||||
);
|
||||
}, 10000);
|
||||
window.setTimeout(function() { throw new Error(firstMessageReceived ? 'Both messages got lost' : 'Second message got lost');}, 10000);
|
||||
|
||||
const source = {
|
||||
var source = {
|
||||
html: html,
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<WebView
|
||||
source={source}
|
||||
onMessage={processMessage}
|
||||
originWhitelist={['about:blank']}
|
||||
/>
|
||||
onMessage = {processMessage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,13 +1,15 @@
|
||||
#!/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';
|
||||
|
||||
@@ -27,8 +29,8 @@ 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');
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"rules": {
|
||||
// This folder currently runs through babel and doesn't need to be
|
||||
// compatible with node 4
|
||||
"comma-dangle": 0
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
__tests__
|
||||
@@ -245,7 +245,7 @@
|
||||
0CF68AB91AF0540F00FF9E5C /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0940;
|
||||
LastUpgradeCheck = 0620;
|
||||
TargetAttributes = {
|
||||
0CF68AC01AF0540F00FF9E5C = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
@@ -336,31 +336,19 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -373,7 +361,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -389,37 +377,26 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
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_NO_COMMON_BLOCKS = YES;
|
||||
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 = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
// A little helper to make sure we have the right memory allocation ready for use.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTGroup.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <React/UIView+React.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTNode.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTRenderable.h"
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
/**
|
||||
* 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 ARTSerializablePath
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// TODO: Move this into an ART mode called "serialized" or something
|
||||
|
||||
const Class = require('art/core/class.js');
|
||||
const Path = require('art/core/path.js');
|
||||
var Class = require('art/core/class.js');
|
||||
var Path = require('art/core/path.js');
|
||||
|
||||
const MOVE_TO = 0;
|
||||
const CLOSE = 1;
|
||||
const LINE_TO = 2;
|
||||
const CURVE_TO = 3;
|
||||
const ARC = 4;
|
||||
var MOVE_TO = 0;
|
||||
var CLOSE = 1;
|
||||
var LINE_TO = 2;
|
||||
var CURVE_TO = 3;
|
||||
var ARC = 4;
|
||||
|
||||
var SerializablePath = Class(Path, {
|
||||
|
||||
const SerializablePath = Class(Path, {
|
||||
initialize: function(path) {
|
||||
this.reset();
|
||||
if (path instanceof SerializablePath) {
|
||||
@@ -55,18 +57,7 @@ const SerializablePath = Class(Path, {
|
||||
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,
|
||||
sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation
|
||||
);
|
||||
}
|
||||
this.path.push(ARC, cx, cy, rx, sa, ea, ccw ? 0 : 1);
|
||||
@@ -78,7 +69,8 @@ const SerializablePath = Class(Path, {
|
||||
|
||||
toJSON: function() {
|
||||
return this.path;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = SerializablePath;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTShape.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTSurfaceView.h"
|
||||
@@ -13,15 +15,6 @@
|
||||
|
||||
@implementation ARTSurfaceView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.opaque = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
[super insertReactSubview:subview atIndex:atIndex];
|
||||
@@ -53,4 +46,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reactSetInheritedBackgroundColor:(UIColor *)inheritedBackgroundColor
|
||||
{
|
||||
self.backgroundColor = inheritedBackgroundColor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTText.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTBrush.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTBrush.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTLinearGradient.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTBrush.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTPattern.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTBrush.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTRadialGradient.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTBrush.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTSolidColor.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "RCTConvert+ART.h"
|
||||
|
||||
+131
-153
@@ -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
|
||||
* @providesModule ReactNativeART
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const Color = require('art/core/color');
|
||||
const Path = require('ARTSerializablePath');
|
||||
const Transform = require('art/core/transform');
|
||||
var Color = require('art/core/color');
|
||||
var Path = require('ARTSerializablePath');
|
||||
var Transform = require('art/core/transform');
|
||||
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
|
||||
const createReactNativeComponentClass = require('createReactNativeComponentClass');
|
||||
const merge = require('merge');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
var createReactNativeComponentClass = require('createReactNativeComponentClass');
|
||||
var merge = require('merge');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
// Diff Helpers
|
||||
|
||||
@@ -30,7 +31,7 @@ function arrayDiffer(a, b) {
|
||||
if (a.length !== b.length) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) {
|
||||
return true;
|
||||
}
|
||||
@@ -64,64 +65,65 @@ function fontAndLinesDiffer(a, b) {
|
||||
|
||||
// Native Attributes
|
||||
|
||||
const SurfaceViewAttributes = merge(ReactNativeViewAttributes.UIView, {
|
||||
var SurfaceViewAttributes = merge(ReactNativeViewAttributes.UIView, {
|
||||
// This should contain pixel information such as width, height and
|
||||
// resolution to know what kind of buffer needs to be allocated.
|
||||
// Currently we rely on UIViews and style to figure that out.
|
||||
});
|
||||
|
||||
const NodeAttributes = {
|
||||
transform: {diff: arrayDiffer},
|
||||
var NodeAttributes = {
|
||||
transform: { diff: arrayDiffer },
|
||||
opacity: true,
|
||||
};
|
||||
|
||||
const GroupAttributes = merge(NodeAttributes, {
|
||||
clipping: {diff: arrayDiffer},
|
||||
var GroupAttributes = merge(NodeAttributes, {
|
||||
clipping: { diff: arrayDiffer }
|
||||
});
|
||||
|
||||
const RenderableAttributes = merge(NodeAttributes, {
|
||||
fill: {diff: arrayDiffer},
|
||||
stroke: {diff: arrayDiffer},
|
||||
var RenderableAttributes = merge(NodeAttributes, {
|
||||
fill: { diff: arrayDiffer },
|
||||
stroke: { diff: arrayDiffer },
|
||||
strokeWidth: true,
|
||||
strokeCap: true,
|
||||
strokeJoin: true,
|
||||
strokeDash: {diff: arrayDiffer},
|
||||
strokeDash: { diff: arrayDiffer },
|
||||
});
|
||||
|
||||
const ShapeAttributes = merge(RenderableAttributes, {
|
||||
d: {diff: arrayDiffer},
|
||||
var ShapeAttributes = merge(RenderableAttributes, {
|
||||
d: { diff: arrayDiffer },
|
||||
});
|
||||
|
||||
const TextAttributes = merge(RenderableAttributes, {
|
||||
var TextAttributes = merge(RenderableAttributes, {
|
||||
alignment: true,
|
||||
frame: {diff: fontAndLinesDiffer},
|
||||
path: {diff: arrayDiffer},
|
||||
frame: { diff: fontAndLinesDiffer },
|
||||
path: { diff: arrayDiffer }
|
||||
});
|
||||
|
||||
// Native Components
|
||||
|
||||
const NativeSurfaceView = createReactNativeComponentClass(
|
||||
'ARTSurfaceView',
|
||||
var NativeSurfaceView = createReactNativeComponentClass('ARTSurfaceView',
|
||||
() => ({
|
||||
validAttributes: SurfaceViewAttributes,
|
||||
uiViewClassName: 'ARTSurfaceView',
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
const NativeGroup = createReactNativeComponentClass('ARTGroup', () => ({
|
||||
validAttributes: GroupAttributes,
|
||||
uiViewClassName: 'ARTGroup',
|
||||
}));
|
||||
var NativeGroup = createReactNativeComponentClass('ARTGroup',
|
||||
() => ({
|
||||
validAttributes: GroupAttributes,
|
||||
uiViewClassName: 'ARTGroup',
|
||||
}));
|
||||
|
||||
const NativeShape = createReactNativeComponentClass('ARTShape', () => ({
|
||||
validAttributes: ShapeAttributes,
|
||||
uiViewClassName: 'ARTShape',
|
||||
}));
|
||||
var NativeShape = createReactNativeComponentClass('ARTShape',
|
||||
() => ({
|
||||
validAttributes: ShapeAttributes,
|
||||
uiViewClassName: 'ARTShape',
|
||||
}));
|
||||
|
||||
const NativeText = createReactNativeComponentClass('ARTText', () => ({
|
||||
validAttributes: TextAttributes,
|
||||
uiViewClassName: 'ARTText',
|
||||
}));
|
||||
var NativeText = createReactNativeComponentClass('ARTText',
|
||||
() => ({
|
||||
validAttributes: TextAttributes,
|
||||
uiViewClassName: 'ARTText',
|
||||
}));
|
||||
|
||||
// Utilities
|
||||
|
||||
@@ -146,15 +148,15 @@ class Surface extends React.Component {
|
||||
};
|
||||
|
||||
getChildContext() {
|
||||
return {isInSurface: true};
|
||||
return { isInSurface: true };
|
||||
}
|
||||
|
||||
render() {
|
||||
const height = extractNumber(this.props.height, 0);
|
||||
const width = extractNumber(this.props.width, 0);
|
||||
|
||||
var props = this.props;
|
||||
var w = extractNumber(props.width, 0);
|
||||
var h = extractNumber(props.height, 0);
|
||||
return (
|
||||
<NativeSurfaceView style={[this.props.style, {height, width}]}>
|
||||
<NativeSurfaceView style={[props.style, { width: w, height: h }]}>
|
||||
{this.props.children}
|
||||
</NativeSurfaceView>
|
||||
);
|
||||
@@ -173,13 +175,13 @@ function extractNumber(value, defaultValue) {
|
||||
return +value;
|
||||
}
|
||||
|
||||
const pooledTransform = new Transform();
|
||||
var pooledTransform = new Transform();
|
||||
|
||||
function extractTransform(props) {
|
||||
const scaleX =
|
||||
props.scaleX != null ? props.scaleX : props.scale != null ? props.scale : 1;
|
||||
const scaleY =
|
||||
props.scaleY != null ? props.scaleY : props.scale != null ? props.scale : 1;
|
||||
var scaleX = props.scaleX != null ? props.scaleX :
|
||||
props.scale != null ? props.scale : 1;
|
||||
var scaleY = props.scaleY != null ? props.scaleY :
|
||||
props.scale != null ? props.scale : 1;
|
||||
|
||||
pooledTransform
|
||||
.transformTo(1, 0, 0, 1, 0, 0)
|
||||
@@ -192,12 +194,9 @@ function extractTransform(props) {
|
||||
}
|
||||
|
||||
return [
|
||||
pooledTransform.xx,
|
||||
pooledTransform.yx,
|
||||
pooledTransform.xy,
|
||||
pooledTransform.yy,
|
||||
pooledTransform.x,
|
||||
pooledTransform.y,
|
||||
pooledTransform.xx, pooledTransform.yx,
|
||||
pooledTransform.xy, pooledTransform.yy,
|
||||
pooledTransform.x, pooledTransform.y,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -223,10 +222,10 @@ class Group extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const props = this.props;
|
||||
var props = this.props;
|
||||
invariant(
|
||||
this.context.isInSurface,
|
||||
'ART: <Group /> must be a child of a <Surface />',
|
||||
'ART: <Group /> must be a child of a <Surface />'
|
||||
);
|
||||
return (
|
||||
<NativeGroup
|
||||
@@ -240,14 +239,14 @@ class Group extends React.Component {
|
||||
|
||||
class ClippingRectangle extends React.Component {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const x = extractNumber(props.x, 0);
|
||||
const y = extractNumber(props.y, 0);
|
||||
const w = extractNumber(props.width, 0);
|
||||
const h = extractNumber(props.height, 0);
|
||||
const clipping = [x, y, w, h];
|
||||
var props = this.props;
|
||||
var x = extractNumber(props.x, 0);
|
||||
var y = extractNumber(props.y, 0);
|
||||
var w = extractNumber(props.width, 0);
|
||||
var h = extractNumber(props.height, 0);
|
||||
var clipping = [x, y, w, h];
|
||||
// The current clipping API requires x and y to be ignored in the transform
|
||||
const propsExcludingXAndY = merge(props);
|
||||
var propsExcludingXAndY = merge(props);
|
||||
delete propsExcludingXAndY.x;
|
||||
delete propsExcludingXAndY.y;
|
||||
return (
|
||||
@@ -263,13 +262,13 @@ class ClippingRectangle extends React.Component {
|
||||
|
||||
// Renderables
|
||||
|
||||
const SOLID_COLOR = 0;
|
||||
const LINEAR_GRADIENT = 1;
|
||||
const RADIAL_GRADIENT = 2;
|
||||
const PATTERN = 3;
|
||||
var SOLID_COLOR = 0;
|
||||
var LINEAR_GRADIENT = 1;
|
||||
var RADIAL_GRADIENT = 2;
|
||||
var PATTERN = 3;
|
||||
|
||||
function insertColorIntoArray(color, targetArray, atIndex) {
|
||||
const c = new Color(color);
|
||||
var c = new Color(color);
|
||||
targetArray[atIndex + 0] = c.red / 255;
|
||||
targetArray[atIndex + 1] = c.green / 255;
|
||||
targetArray[atIndex + 2] = c.blue / 255;
|
||||
@@ -277,14 +276,14 @@ function insertColorIntoArray(color, targetArray, atIndex) {
|
||||
}
|
||||
|
||||
function insertColorsIntoArray(stops, targetArray, atIndex) {
|
||||
let i = 0;
|
||||
var i = 0;
|
||||
if ('length' in stops) {
|
||||
while (i < stops.length) {
|
||||
insertColorIntoArray(stops[i], targetArray, atIndex + i * 4);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
for (const offset in stops) {
|
||||
for (var offset in stops) {
|
||||
insertColorIntoArray(stops[offset], targetArray, atIndex + i * 4);
|
||||
i++;
|
||||
}
|
||||
@@ -293,17 +292,17 @@ function insertColorsIntoArray(stops, targetArray, atIndex) {
|
||||
}
|
||||
|
||||
function insertOffsetsIntoArray(stops, targetArray, atIndex, multi, reverse) {
|
||||
let offsetNumber;
|
||||
let i = 0;
|
||||
var offsetNumber;
|
||||
var i = 0;
|
||||
if ('length' in stops) {
|
||||
while (i < stops.length) {
|
||||
offsetNumber = (i / (stops.length - 1)) * multi;
|
||||
offsetNumber = i / (stops.length - 1) * multi;
|
||||
targetArray[atIndex + i] = reverse ? 1 - offsetNumber : offsetNumber;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
for (const offsetString in stops) {
|
||||
offsetNumber = +offsetString * multi;
|
||||
for (var offsetString in stops) {
|
||||
offsetNumber = (+offsetString) * multi;
|
||||
targetArray[atIndex + i] = reverse ? 1 - offsetNumber : offsetNumber;
|
||||
i++;
|
||||
}
|
||||
@@ -312,21 +311,21 @@ function insertOffsetsIntoArray(stops, targetArray, atIndex, multi, reverse) {
|
||||
}
|
||||
|
||||
function insertColorStopsIntoArray(stops, targetArray, atIndex) {
|
||||
const lastIndex = insertColorsIntoArray(stops, targetArray, atIndex);
|
||||
var lastIndex = insertColorsIntoArray(stops, targetArray, atIndex);
|
||||
insertOffsetsIntoArray(stops, targetArray, lastIndex, 1, false);
|
||||
}
|
||||
|
||||
function insertDoubleColorStopsIntoArray(stops, targetArray, atIndex) {
|
||||
let lastIndex = insertColorsIntoArray(stops, targetArray, atIndex);
|
||||
var lastIndex = insertColorsIntoArray(stops, targetArray, atIndex);
|
||||
lastIndex = insertColorsIntoArray(stops, targetArray, lastIndex);
|
||||
lastIndex = insertOffsetsIntoArray(stops, targetArray, lastIndex, 0.5, false);
|
||||
insertOffsetsIntoArray(stops, targetArray, lastIndex, 0.5, true);
|
||||
}
|
||||
|
||||
function applyBoundingBoxToBrushData(brushData, props) {
|
||||
const type = brushData[0];
|
||||
const width = +props.width;
|
||||
const height = +props.height;
|
||||
var type = brushData[0];
|
||||
var width = +props.width;
|
||||
var height = +props.height;
|
||||
if (type === LINEAR_GRADIENT) {
|
||||
brushData[1] *= width;
|
||||
brushData[2] *= height;
|
||||
@@ -360,7 +359,7 @@ function extractBrush(colorOrBrush, props) {
|
||||
}
|
||||
return colorOrBrush._brush;
|
||||
}
|
||||
const c = new Color(colorOrBrush);
|
||||
var c = new Color(colorOrBrush);
|
||||
return [SOLID_COLOR, c.red / 255, c.green / 255, c.blue / 255, c.alpha];
|
||||
}
|
||||
|
||||
@@ -368,29 +367,23 @@ function extractColor(color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
const c = new Color(color);
|
||||
var c = new Color(color);
|
||||
return [c.red / 255, c.green / 255, c.blue / 255, c.alpha];
|
||||
}
|
||||
|
||||
function extractStrokeCap(strokeCap) {
|
||||
switch (strokeCap) {
|
||||
case 'butt':
|
||||
return 0;
|
||||
case 'square':
|
||||
return 2;
|
||||
default:
|
||||
return 1; // round
|
||||
case 'butt': return 0;
|
||||
case 'square': return 2;
|
||||
default: return 1; // round
|
||||
}
|
||||
}
|
||||
|
||||
function extractStrokeJoin(strokeJoin) {
|
||||
switch (strokeJoin) {
|
||||
case 'miter':
|
||||
return 0;
|
||||
case 'bevel':
|
||||
return 2;
|
||||
default:
|
||||
return 1; // round
|
||||
case 'miter': return 0;
|
||||
case 'bevel': return 2;
|
||||
default: return 1; // round
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,23 +392,11 @@ function extractStrokeJoin(strokeJoin) {
|
||||
// Note: ART has a notion of width and height on Shape but AFAIK it's a noop in
|
||||
// ReactART.
|
||||
|
||||
export type ShapeProps = {|
|
||||
fill?: mixed,
|
||||
stroke?: mixed,
|
||||
strokeCap?: mixed,
|
||||
strokeDash?: mixed,
|
||||
strokeJoin?: mixed,
|
||||
strokeWidth?: mixed,
|
||||
x?: number,
|
||||
y?: number,
|
||||
opacity?: mixed,
|
||||
|};
|
||||
|
||||
class Shape extends React.Component<ShapeProps> {
|
||||
class Shape extends React.Component {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const path = props.d || childrenAsString(props.children);
|
||||
const d = (path instanceof Path ? path : new Path(path)).toJSON();
|
||||
var props = this.props;
|
||||
var path = props.d || childrenAsString(props.children);
|
||||
var d = (path instanceof Path ? path : new Path(path)).toJSON();
|
||||
return (
|
||||
<NativeShape
|
||||
fill={extractBrush(props.fill, props)}
|
||||
@@ -426,6 +407,7 @@ class Shape extends React.Component<ShapeProps> {
|
||||
strokeJoin={extractStrokeJoin(props.strokeJoin)}
|
||||
strokeWidth={extractNumber(props.strokeWidth, 1)}
|
||||
transform={extractTransform(props)}
|
||||
|
||||
d={d}
|
||||
/>
|
||||
);
|
||||
@@ -434,34 +416,33 @@ class Shape extends React.Component<ShapeProps> {
|
||||
|
||||
// Text
|
||||
|
||||
const cachedFontObjectsFromString = {};
|
||||
var cachedFontObjectsFromString = {};
|
||||
|
||||
const fontFamilyPrefix = /^[\s"']*/;
|
||||
const fontFamilySuffix = /[\s"']*$/;
|
||||
var fontFamilyPrefix = /^[\s"']*/;
|
||||
var fontFamilySuffix = /[\s"']*$/;
|
||||
|
||||
function extractSingleFontFamily(fontFamilyString) {
|
||||
// ART on the web allows for multiple font-families to be specified.
|
||||
// For compatibility, we extract the first font-family, hoping
|
||||
// we'll get a match.
|
||||
return fontFamilyString
|
||||
.split(',')[0]
|
||||
.replace(fontFamilyPrefix, '')
|
||||
.replace(fontFamilySuffix, '');
|
||||
return fontFamilyString.split(',')[0]
|
||||
.replace(fontFamilyPrefix, '')
|
||||
.replace(fontFamilySuffix, '');
|
||||
}
|
||||
|
||||
function parseFontString(font) {
|
||||
if (cachedFontObjectsFromString.hasOwnProperty(font)) {
|
||||
return cachedFontObjectsFromString[font];
|
||||
}
|
||||
const regexp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?)[ptexm\%]*(?:\s*\/.*?)?\s+)?\s*\"?([^\"]*)/i;
|
||||
const match = regexp.exec(font);
|
||||
var regexp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?)[ptexm\%]*(?:\s*\/.*?)?\s+)?\s*\"?([^\"]*)/i;
|
||||
var match = regexp.exec(font);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
const fontFamily = extractSingleFontFamily(match[3]);
|
||||
const fontSize = +match[2] || 12;
|
||||
const isBold = /bold/.exec(match[1]);
|
||||
const isItalic = /italic/.exec(match[1]);
|
||||
var fontFamily = extractSingleFontFamily(match[3]);
|
||||
var fontSize = +match[2] || 12;
|
||||
var isBold = /bold/.exec(match[1]);
|
||||
var isItalic = /italic/.exec(match[1]);
|
||||
cachedFontObjectsFromString[font] = {
|
||||
fontFamily: fontFamily,
|
||||
fontSize: fontSize,
|
||||
@@ -478,10 +459,9 @@ function extractFont(font) {
|
||||
if (typeof font === 'string') {
|
||||
return parseFontString(font);
|
||||
}
|
||||
const fontFamily = extractSingleFontFamily(font.fontFamily);
|
||||
const fontSize = +font.fontSize || 12;
|
||||
const fontWeight =
|
||||
font.fontWeight != null ? font.fontWeight.toString() : '400';
|
||||
var fontFamily = extractSingleFontFamily(font.fontFamily);
|
||||
var fontSize = +font.fontSize || 12;
|
||||
var fontWeight = font.fontWeight != null ? font.fontWeight.toString() : '400';
|
||||
return {
|
||||
// Normalize
|
||||
fontFamily: fontFamily,
|
||||
@@ -491,9 +471,9 @@ function extractFont(font) {
|
||||
};
|
||||
}
|
||||
|
||||
const newLine = /\n/g;
|
||||
var newLine = /\n/g;
|
||||
function extractFontAndLines(font, text) {
|
||||
return {font: extractFont(font), lines: text.split(newLine)};
|
||||
return { font: extractFont(font), lines: text.split(newLine) };
|
||||
}
|
||||
|
||||
function extractAlignment(alignment) {
|
||||
@@ -509,14 +489,12 @@ function extractAlignment(alignment) {
|
||||
|
||||
class Text extends React.Component {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const path = props.path;
|
||||
const textPath = path
|
||||
? (path instanceof Path ? path : new Path(path)).toJSON()
|
||||
: null;
|
||||
const textFrame = extractFontAndLines(
|
||||
var props = this.props;
|
||||
var path = props.path;
|
||||
var textPath = path ? (path instanceof Path ? path : new Path(path)).toJSON() : null;
|
||||
var textFrame = extractFontAndLines(
|
||||
props.font,
|
||||
childrenAsString(props.children),
|
||||
childrenAsString(props.children)
|
||||
);
|
||||
return (
|
||||
<NativeText
|
||||
@@ -528,6 +506,7 @@ class Text extends React.Component {
|
||||
strokeJoin={extractStrokeJoin(props.strokeJoin)}
|
||||
strokeWidth={extractNumber(props.strokeWidth, 1)}
|
||||
transform={extractTransform(props)}
|
||||
|
||||
alignment={extractAlignment(props.alignment)}
|
||||
frame={textFrame}
|
||||
path={textPath}
|
||||
@@ -539,17 +518,16 @@ class Text extends React.Component {
|
||||
// Declarative fill type objects - API design not finalized
|
||||
|
||||
function LinearGradient(stops, x1, y1, x2, y2) {
|
||||
const type = LINEAR_GRADIENT;
|
||||
var type = LINEAR_GRADIENT;
|
||||
|
||||
if (arguments.length < 5) {
|
||||
const angle = ((x1 == null ? 270 : x1) * Math.PI) / 180;
|
||||
var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
|
||||
|
||||
let x = Math.cos(angle);
|
||||
let y = -Math.sin(angle);
|
||||
const l = (Math.abs(x) + Math.abs(y)) / 2;
|
||||
var x = Math.cos(angle);
|
||||
var y = -Math.sin(angle);
|
||||
var l = (Math.abs(x) + Math.abs(y)) / 2;
|
||||
|
||||
x *= l;
|
||||
y *= l;
|
||||
x *= l; y *= l;
|
||||
|
||||
x1 = 0.5 - x;
|
||||
x2 = 0.5 + x;
|
||||
@@ -560,7 +538,7 @@ function LinearGradient(stops, x1, y1, x2, y2) {
|
||||
this._bb = false;
|
||||
}
|
||||
|
||||
const brushData = [type, +x1, +y1, +x2, +y2];
|
||||
var brushData = [type, +x1, +y1, +x2, +y2];
|
||||
insertColorStopsIntoArray(stops, brushData, 5);
|
||||
this._brush = brushData;
|
||||
}
|
||||
@@ -587,7 +565,7 @@ function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
|
||||
// To simulate this we render the gradient twice as large and add double
|
||||
// color stops. Ideally this API would become more restrictive so that this
|
||||
// extra work isn't needed.
|
||||
const brushData = [RADIAL_GRADIENT, +fx, +fy, +rx * 2, +ry * 2, +cx, +cy];
|
||||
var brushData = [RADIAL_GRADIENT, +fx, +fy, +rx * 2, +ry * 2, +cx, +cy];
|
||||
insertDoubleColorStopsIntoArray(stops, brushData, 7);
|
||||
this._brush = brushData;
|
||||
}
|
||||
@@ -596,7 +574,7 @@ function Pattern(url, width, height, left, top) {
|
||||
this._brush = [PATTERN, url, +left || 0, +top || 0, +width, +height];
|
||||
}
|
||||
|
||||
const ReactART = {
|
||||
var ReactART = {
|
||||
LinearGradient: LinearGradient,
|
||||
RadialGradient: RadialGradient,
|
||||
Pattern: Pattern,
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTNodeManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTGroupManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTNodeManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTNodeManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTRenderableManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTRenderableManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTShapeManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTSurfaceViewManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTRenderableManager.h"
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "ARTTextManager.h"
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @providesModule ActionSheetIOS
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
58B511D31A9E6C8500147676 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0940;
|
||||
LastUpgradeCheck = 0610;
|
||||
ORGANIZATIONNAME = Facebook;
|
||||
TargetAttributes = {
|
||||
58B511DA1A9E6C8500147676 = {
|
||||
@@ -106,31 +106,19 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -145,7 +133,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -165,30 +153,19 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
|
||||
@@ -197,7 +174,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#import "RCTActionSheetManager.h"
|
||||
@@ -186,4 +188,17 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options
|
||||
shareController.view.tintColor = [RCTConvert UIColor:options[@"tintColor"]];
|
||||
}
|
||||
|
||||
#pragma mark UIActionSheetDelegate Methods
|
||||
|
||||
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
RCTResponseSenderBlock callback = [_callbacks objectForKey:actionSheet];
|
||||
if (callback) {
|
||||
callback(@[@(buttonIndex)]);
|
||||
[_callbacks removeObjectForKey:actionSheet];
|
||||
} else {
|
||||
RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user