chore: update map
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"userInterfaceStyle": "dark",
|
||||
"newArchEnabled": false,
|
||||
"newArchEnabled": true,
|
||||
"splash": {
|
||||
"image": "./assets/splash-icon.png",
|
||||
"resizeMode": "contain",
|
||||
|
||||
+18
-62
@@ -441,41 +441,6 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-proposal-nullish-coalescing-operator": {
|
||||
"version": "7.18.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
|
||||
"integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
|
||||
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.18.6",
|
||||
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-proposal-optional-chaining": {
|
||||
"version": "7.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz",
|
||||
"integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==",
|
||||
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.20.2",
|
||||
"@babel/helper-skip-transparent-expression-wrappers": "^7.20.0",
|
||||
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-syntax-async-generators": {
|
||||
"version": "7.8.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
|
||||
@@ -1019,20 +984,6 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-object-assign": {
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.27.1.tgz",
|
||||
"integrity": "sha512-LP6tsnirA6iy13uBKiYgjJsfQrodmlSrpZModtlo1Vk8sOO68gfo7dfA9TGJyEgxTiO7czK4EGZm8FJEZtk4kQ==",
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.27.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-object-rest-spread": {
|
||||
"version": "7.28.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.6.tgz",
|
||||
@@ -6650,24 +6601,29 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-reanimated": {
|
||||
"version": "3.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.6.3.tgz",
|
||||
"integrity": "sha512-2KkkPozoIvDbJcHuf8qeyoLROXQxizSi+2CTCkuNVkVZOxxY4B0Omvgq61aOQhSZUh/649x1YHoAaTyGMGDJUw==",
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-4.1.6.tgz",
|
||||
"integrity": "sha512-F+ZJBYiok/6Jzp1re75F/9aLzkgoQCOh4yxrnwATa8392RvM3kx+fiXXFvwcgE59v48lMwd9q0nzF1oJLXpfxQ==",
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"convert-source-map": "^2.0.0",
|
||||
"invariant": "^2.2.4"
|
||||
"react-native-is-edge-to-edge": "^1.2.1",
|
||||
"semver": "7.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.0.0-0",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.0.0-0",
|
||||
"@babel/plugin-transform-shorthand-properties": "^7.0.0-0",
|
||||
"@babel/plugin-transform-template-literals": "^7.0.0-0",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
"react-native": "*",
|
||||
"react-native-worklets": ">=0.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-reanimated/node_modules/semver": {
|
||||
"version": "7.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-safe-area-context": {
|
||||
|
||||
+27
-20
@@ -1,33 +1,32 @@
|
||||
<img src="https://user-images.githubusercontent.com/16062886/117443145-ff868480-af37-11eb-8680-648bccf0d0ce.png" alt="React Native Reanimated by Software Mansion" width="100%">
|
||||
|
||||
### React Native's Animated library reimplemented
|
||||
### Create smooth animations with an excellent developer experience.
|
||||
|
||||
> Reanimated 3 is here! Check out our [documentation page](https://docs.swmansion.com/react-native-reanimated/) for more information
|
||||
|
||||
React Native Reanimated provides a more comprehensive,
|
||||
low level abstraction for the Animated library API to be built
|
||||
on top of and hence allow for much greater flexibility especially when it
|
||||
comes to gesture based interactions.
|
||||
> Reanimated 4 is here! Check out our [documentation page](https://docs.swmansion.com/react-native-reanimated/) for more information
|
||||
|
||||
### Nightly CI state
|
||||
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/build-nightly-npm-package.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/build-monorepo-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-static-framework-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-react-native-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-expo-dev-client-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-TS-react-native.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/build-v8-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/build-on-windows-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/detect-broken-urls-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/npm-reanimated-publish-nightly.yml)
|
||||
[![NPM Worklets publish [Nightly]](https://github.com/software-mansion/react-native-reanimated/actions/workflows/npm-worklets-publish-nightly.yml/badge.svg)](https://github.com/software-mansion/react-native-reanimated/actions/workflows/npm-worklets-publish-nightly.yml)
|
||||
[![Lint clang-tidy [Nightly]](https://github.com/software-mansion/react-native-reanimated/actions/workflows/lint-clang-tidy-nightly.yml/badge.svg)](https://github.com/software-mansion/react-native-reanimated/actions/workflows/lint-clang-tidy-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/reanimated-compatibility-check-nightly.yml)
|
||||
[![Use frameworks Reanimated build check [Nightly]](https://github.com/software-mansion/react-native-reanimated/actions/workflows/use-frameworks-reanimated-build-check-nightly.yml/badge.svg)](https://github.com/software-mansion/react-native-reanimated/actions/workflows/use-frameworks-reanimated-build-check-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/react-native-nightly-reanimated-build-check-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/expo-devclient-build-check-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/reanimated-typescript-compatibility-test-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/windows-hosted-app-reanimated-build-check-nightly.yml)
|
||||
[![Worklets Bundle Mode build check [Nightly]](https://github.com/software-mansion/react-native-reanimated/actions/workflows/worklets-bundle-mode-build-check-nightly.yml/badge.svg)](https://github.com/software-mansion/react-native-reanimated/actions/workflows/worklets-bundle-mode-build-check-nightly.yml)
|
||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/url-validation-nightly.yml)
|
||||
|
||||
## Installation
|
||||
|
||||
Check out the [installation](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#installation) section of our docs for the detailed installation instructions.
|
||||
|
||||
## Fabric
|
||||
## Compatibility
|
||||
|
||||
To learn how to use `react-native-reanimated` with Fabric architecture, head over to [Fabric README](README-Fabric.md). Instructions on how to run Fabric Example within this repo can be found in the [FabricExample README](FabricExample/README.md).
|
||||
React Native Reanimated 4.x supports only the [New React Native architecture](https://reactnative.dev/architecture/landing-page) and three latest React Native versions.
|
||||
|
||||
If your app still runs on the old architecture, please consider adopting the New Architecture or stay with latest 3.x release.
|
||||
|
||||
## Documentation
|
||||
|
||||
@@ -35,8 +34,8 @@ Check out our dedicated documentation page for info about this library, API refe
|
||||
|
||||
## Examples
|
||||
|
||||
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/main/Example/) directory.
|
||||
If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check Example/ directory README for installation instructions.
|
||||
The source code for the example (showcase) app is under the [`apps/common-app`](https://github.com/software-mansion/react-native-reanimated/blob/main/apps/common-app/) directory.
|
||||
If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check [Example README](apps/fabric-example/README.md) for installation instructions.
|
||||
|
||||
## License
|
||||
|
||||
@@ -49,3 +48,11 @@ This project has been built and is maintained thanks to the support from [Shopif
|
||||
[](https://shopify.com)
|
||||
[](https://expo.io)
|
||||
[](https://swmansion.com)
|
||||
|
||||
## Community Discord
|
||||
|
||||
[Join the Software Mansion Community Discord](https://discord.swmansion.com) to chat about Reanimated or other Software Mansion libraries.
|
||||
|
||||
## Reanimated is created by Software Mansion
|
||||
|
||||
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=reanimated&utm_medium=readme).
|
||||
|
||||
+60
-77
@@ -3,65 +3,22 @@ require_relative './scripts/reanimated_utils'
|
||||
|
||||
reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||
$config = find_config()
|
||||
assert_latest_react_native_with_new_architecture($config, reanimated_package_json)
|
||||
assert_minimal_react_native_version($config)
|
||||
|
||||
$new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
||||
is_release = ENV['PRODUCTION'] == '1'
|
||||
$new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] != '0'
|
||||
assert_new_architecture_enabled($new_arch_enabled)
|
||||
|
||||
folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + $config[:react_native_minor_version].to_s
|
||||
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
|
||||
boost_compiler_flags = '-Wno-documentation'
|
||||
fabric_flags = $new_arch_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
|
||||
example_flag = $config[:is_reanimated_example_app] ? '-DIS_REANIMATED_EXAMPLE_APP' : ''
|
||||
version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"]
|
||||
debug_flag = is_release ? '-DNDEBUG' : ''
|
||||
ios_min_version = $config[:react_native_minor_version] >= 73 ? '13.4' : '9.0'
|
||||
version_flags = "-DREACT_NATIVE_MINOR_VERSION=#{$config[:react_native_minor_version]} -DREANIMATED_VERSION=#{reanimated_package_json['version']}"
|
||||
ios_min_version = '13.4'
|
||||
|
||||
def self.install_modules_dependencies_legacy(s)
|
||||
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
||||
s.dependency "React-Core"
|
||||
if $new_arch_enabled
|
||||
s.dependency "React-RCTFabric"
|
||||
s.dependency "React-Codegen"
|
||||
end
|
||||
s.dependency "RCT-Folly"
|
||||
s.dependency "RCTRequired"
|
||||
s.dependency "RCTTypeSafety"
|
||||
s.dependency 'FBLazyVector'
|
||||
if $config[:react_native_minor_version] <= 71
|
||||
s.dependency 'FBReactNativeSpec'
|
||||
end
|
||||
s.dependency 'React-Core'
|
||||
s.dependency 'React-CoreModules'
|
||||
s.dependency 'React-Core/DevSupport'
|
||||
if !$config[:is_tvos_target]
|
||||
s.dependency 'React-RCTActionSheet'
|
||||
end
|
||||
s.dependency 'React-RCTNetwork'
|
||||
s.dependency 'React-RCTAnimation'
|
||||
s.dependency 'React-RCTLinking'
|
||||
s.dependency 'React-RCTBlob'
|
||||
s.dependency 'React-RCTSettings'
|
||||
s.dependency 'React-RCTText'
|
||||
s.dependency 'React-RCTImage'
|
||||
s.dependency 'React-Core/RCTWebSocket'
|
||||
s.dependency 'React-cxxreact'
|
||||
s.dependency 'React-jsi'
|
||||
s.dependency 'React-jsiexecutor'
|
||||
s.dependency 'React-jsinspector'
|
||||
s.dependency 'Yoga'
|
||||
s.dependency 'DoubleConversion'
|
||||
s.dependency 'glog'
|
||||
if using_hermes && !$config[:is_tvos_target] && $config[:react_native_minor_version] >= 70
|
||||
s.dependency 'React-hermes'
|
||||
s.dependency 'hermes-engine'
|
||||
end
|
||||
s.dependency 'React-callinvoker'
|
||||
if $config[:react_native_minor_version] >= 72 && !$new_arch_enabled
|
||||
s.dependency 'React-RCTAppDelegate'
|
||||
end
|
||||
end
|
||||
# Directory in which data for further processing for clangd will be stored.
|
||||
compilation_metadata_dir = "CompilationDatabase"
|
||||
# We want generate the metadata only within the monorepo of Reanimated.
|
||||
compilation_metadata_generation_flag = $config[:is_reanimated_example_app] ? "-gen-cdb-fragment-path #{compilation_metadata_dir}" : ''
|
||||
|
||||
feature_flags = "-DREANIMATED_FEATURE_FLAGS=\"#{get_static_feature_flags()}\""
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
@@ -74,42 +31,68 @@ Pod::Spec.new do |s|
|
||||
s.homepage = "https://github.com/software-mansion/react-native-reanimated"
|
||||
s.license = "MIT"
|
||||
s.author = { "author" => "author@domain.cn" }
|
||||
s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14" }
|
||||
s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
|
||||
s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }
|
||||
|
||||
s.source_files = [
|
||||
"apple/**/*.{mm,h,m}",
|
||||
"Common/cpp/**/*.{cpp,h}"
|
||||
]
|
||||
s.dependency "RNWorklets"
|
||||
|
||||
s.preserve_paths = [
|
||||
"Common/cpp/hidden_headers/**"
|
||||
]
|
||||
s.subspec "reanimated" do |ss|
|
||||
ss.source_files = "Common/cpp/reanimated/**/*.{cpp,h}"
|
||||
ss.header_dir = "reanimated"
|
||||
ss.header_mappings_dir = "Common/cpp/reanimated"
|
||||
|
||||
gcc_debug_definitions = "$(inherited)"
|
||||
if $config[:react_native_minor_version] >= 73 || !is_release
|
||||
gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1"
|
||||
ss.subspec "apple" do |sss|
|
||||
sss.source_files = "apple/reanimated/**/*.{mm,h,m}"
|
||||
sss.header_dir = "reanimated"
|
||||
sss.header_mappings_dir = "apple/reanimated"
|
||||
end
|
||||
end
|
||||
|
||||
s.pod_target_xcconfig = {
|
||||
"USE_HEADERMAP" => "YES",
|
||||
"DEFINES_MODULE" => "YES",
|
||||
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"$(PODS_ROOT)/Headers/Private/Yoga\"",
|
||||
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
|
||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[config=Debug]" => gcc_debug_definitions,
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[config=Release]" => "$(inherited) NDEBUG=1",
|
||||
"HEADER_SEARCH_PATHS" => [
|
||||
'"$(PODS_TARGET_SRCROOT)/ReactCommon"',
|
||||
'"$(PODS_TARGET_SRCROOT)"',
|
||||
'"$(PODS_ROOT)/RCT-Folly"',
|
||||
'"$(PODS_ROOT)/boost"',
|
||||
'"$(PODS_ROOT)/boost-for-react-native"',
|
||||
'"$(PODS_ROOT)/DoubleConversion"',
|
||||
'"$(PODS_ROOT)/Headers/Private/React-Core"',
|
||||
'"$(PODS_ROOT)/Headers/Private/Yoga"',
|
||||
'"$(PODS_ROOT)/Headers/Public/RNWorklets"',
|
||||
].join(' '),
|
||||
"FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
|
||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[config=*Debug*]" => '$(inherited)',
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[config=*Release*]" => '$(inherited)',
|
||||
}
|
||||
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
||||
s.compiler_flags = boost_compiler_flags
|
||||
s.xcconfig = {
|
||||
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/Headers/Public/React-hermes\" \"$(PODS_ROOT)/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/#{$config[:react_native_common_dir]}\"",
|
||||
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags + " " + example_flag + " " + version_flag + " " + debug_flag
|
||||
"HEADER_SEARCH_PATHS" => [
|
||||
'"$(PODS_ROOT)/boost"',
|
||||
'"$(PODS_ROOT)/boost-for-react-native"',
|
||||
'"$(PODS_ROOT)/glog"',
|
||||
'"$(PODS_ROOT)/RCT-Folly"',
|
||||
'"$(PODS_ROOT)/Headers/Public/React-hermes"',
|
||||
'"$(PODS_ROOT)/Headers/Public/hermes-engine"',
|
||||
'"$(PODS_ROOT)/Headers/Public/RNWorklets"',
|
||||
"\"$(PODS_ROOT)/#{$config[:react_native_common_dir]}\"",
|
||||
"\"$(PODS_ROOT)/#{$config[:dynamic_frameworks_reanimated_dir]}/apple\"",
|
||||
"\"$(PODS_ROOT)/#{$config[:dynamic_frameworks_reanimated_dir]}/Common/cpp\"",
|
||||
"\"$(PODS_ROOT)/#{$config[:dynamic_frameworks_reanimated_dir]}/Common/NativeView\"",
|
||||
"\"$(PODS_ROOT)/#{$config[:dynamic_frameworks_worklets_dir]}/apple\"",
|
||||
"\"$(PODS_ROOT)/#{$config[:dynamic_frameworks_worklets_dir]}/Common/cpp\"",
|
||||
].join(' '),
|
||||
"OTHER_CFLAGS" => "$(inherited) #{example_flag} #{version_flags} #{compilation_metadata_generation_flag} #{feature_flags}",
|
||||
}
|
||||
s.requires_arc = true
|
||||
s.dependency "ReactCommon/turbomodule/core"
|
||||
if defined?(install_modules_dependencies()) != nil
|
||||
install_modules_dependencies(s)
|
||||
else
|
||||
install_modules_dependencies_legacy(s)
|
||||
|
||||
install_modules_dependencies(s)
|
||||
|
||||
s.dependency 'React-jsi'
|
||||
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
||||
if using_hermes && !$config[:is_tvos_target]
|
||||
s.dependency 'React-hermes'
|
||||
end
|
||||
end
|
||||
|
||||
+76
-293
@@ -1,319 +1,102 @@
|
||||
project(Reanimated)
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73)
|
||||
set (CMAKE_CXX_STANDARD 20)
|
||||
else()
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
endif()
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
|
||||
add_compile_options(${folly_FLAGS})
|
||||
else()
|
||||
set(folly_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1")
|
||||
string(APPEND CMAKE_CXX_FLAGS " ${folly_FLAGS}")
|
||||
endif()
|
||||
# default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections
|
||||
# -funwind-tables -fstack-protector-strong -no-canonical-prefixes
|
||||
# -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"
|
||||
include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
|
||||
add_compile_options(${folly_FLAGS})
|
||||
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}")
|
||||
string(
|
||||
APPEND
|
||||
CMAKE_CXX_FLAGS
|
||||
" -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}\
|
||||
-DREANIMATED_VERSION=${REANIMATED_VERSION}\
|
||||
-DREANIMATED_FEATURE_FLAGS=\"${REANIMATED_FEATURE_FLAGS}\"")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer -fstack-protector-all")
|
||||
# flags to optimize the binary size
|
||||
string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden -ffunction-sections -fdata-sections")
|
||||
|
||||
string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
|
||||
|
||||
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
|
||||
if(${REANIMATED_PROFILING})
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DREANIMATED_PROFILING")
|
||||
endif()
|
||||
|
||||
if(${IS_REANIMATED_EXAMPLE_APP})
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP -Wpedantic")
|
||||
endif()
|
||||
|
||||
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
||||
set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
|
||||
set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
|
||||
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")
|
||||
|
||||
set (PACKAGE_NAME "reanimated")
|
||||
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
||||
set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
|
||||
set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")
|
||||
file(GLOB_RECURSE REANIMATED_COMMON_CPP_SOURCES CONFIGURE_DEPENDS
|
||||
"${COMMON_CPP_DIR}/reanimated/*.cpp")
|
||||
file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS
|
||||
"${ANDROID_CPP_DIR}/reanimated/*.cpp")
|
||||
|
||||
file(GLOB_RECURSE SOURCES_COMMON CONFIGURE_DEPENDS "${COMMON_SRC_DIR}/cpp/**.cpp")
|
||||
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${SRC_DIR}/main/cpp/**.cpp")
|
||||
find_package(fbjni REQUIRED CONFIG)
|
||||
find_package(ReactAndroid REQUIRED CONFIG)
|
||||
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
# Consume shared libraries and headers from prefabs
|
||||
find_package(fbjni REQUIRED CONFIG)
|
||||
find_package(ReactAndroid REQUIRED CONFIG)
|
||||
if(${JS_RUNTIME} STREQUAL "hermes")
|
||||
find_package(hermes-engine REQUIRED CONFIG)
|
||||
endif()
|
||||
add_library(reanimated SHARED ${REANIMATED_COMMON_CPP_SOURCES}
|
||||
${REANIMATED_ANDROID_CPP_SOURCES})
|
||||
|
||||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
|
||||
include(
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/cmake-utils/react-native-flags.cmake")
|
||||
target_compile_reactnative_options(reanimated PUBLIC)
|
||||
else()
|
||||
# Consume shared libraries from found .so files
|
||||
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
||||
message(FATAL_ERROR "not supported")
|
||||
else()
|
||||
set (RN_SO_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/react/jni")
|
||||
set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers")
|
||||
endif()
|
||||
file (GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
|
||||
string(APPEND CMAKE_CXX_FLAGS
|
||||
" -fexceptions -frtti -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
${PACKAGE_NAME}
|
||||
SHARED
|
||||
${SOURCES_COMMON}
|
||||
${SOURCES_ANDROID}
|
||||
${INCLUDE_JSI_CPP}
|
||||
${INCLUDE_JSIDYNAMIC_CPP}
|
||||
)
|
||||
|
||||
# includes
|
||||
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${COMMON_SRC_DIR}/cpp/AnimatedSensor"
|
||||
"${COMMON_SRC_DIR}/cpp/Fabric"
|
||||
"${COMMON_SRC_DIR}/cpp/hidden_headers"
|
||||
"${COMMON_SRC_DIR}/cpp/LayoutAnimations"
|
||||
"${COMMON_SRC_DIR}/cpp/NativeModules"
|
||||
"${COMMON_SRC_DIR}/cpp/ReanimatedRuntime"
|
||||
"${COMMON_SRC_DIR}/cpp/Registries"
|
||||
"${COMMON_SRC_DIR}/cpp/SharedItems"
|
||||
"${COMMON_SRC_DIR}/cpp/Tools"
|
||||
"${SRC_DIR}/main/cpp"
|
||||
reanimated
|
||||
PRIVATE "${COMMON_CPP_DIR}"
|
||||
"${ANDROID_CPP_DIR}"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
|
||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
||||
"${REACT_NATIVE_WORKLETS_DIR}/Common/cpp"
|
||||
"${REACT_NATIVE_WORKLETS_DIR}/android/src/main/cpp")
|
||||
|
||||
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
set(BUILD_TYPE "debug")
|
||||
else()
|
||||
set(BUILD_TYPE "release")
|
||||
endif()
|
||||
|
||||
add_library(worklets SHARED IMPORTED)
|
||||
|
||||
set_target_properties(
|
||||
worklets
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"${REACT_NATIVE_WORKLETS_DIR}/android/build/intermediates/cmake/${BUILD_TYPE}/obj/${ANDROID_ABI}/libworklets.so"
|
||||
)
|
||||
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
|
||||
)
|
||||
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
|
||||
# remove dead code sections
|
||||
set_target_properties(reanimated PROPERTIES LINK_FLAGS "-Wl,--gc-sections")
|
||||
|
||||
target_link_libraries(reanimated log ReactAndroid::jsi fbjni::fbjni android
|
||||
worklets)
|
||||
|
||||
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
||||
target_link_libraries(reanimated ReactAndroid::reactnative)
|
||||
else()
|
||||
file(GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR})
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${LIBFBJNI_INCLUDE_DIR}"
|
||||
"${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}"
|
||||
"${BUILD_DIR}/third-party-ndk/double-conversion"
|
||||
"${BUILD_DIR}/third-party-ndk/folly"
|
||||
"${BUILD_DIR}/third-party-ndk/glog/exported"
|
||||
"${REACT_NATIVE_DIR}/React"
|
||||
"${REACT_NATIVE_DIR}/React/Base"
|
||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni"
|
||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
|
||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/fabric/jni"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/jsi"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/hermes"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/turbomodule/core"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/turbomodule"
|
||||
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
|
||||
)
|
||||
target_link_libraries(reanimated ReactAndroid::react_nativemodule_core)
|
||||
endif()
|
||||
|
||||
# build shared lib
|
||||
|
||||
set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
log
|
||||
android
|
||||
)
|
||||
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
ReactAndroid::folly_runtime
|
||||
ReactAndroid::glog
|
||||
ReactAndroid::jsi
|
||||
ReactAndroid::reactnativejni
|
||||
fbjni::fbjni
|
||||
)
|
||||
else()
|
||||
find_library(
|
||||
JSI_LIB
|
||||
jsi
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
find_library(
|
||||
GLOG_LIB
|
||||
glog
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
find_library(
|
||||
FBJNI_LIB
|
||||
fbjni
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
if(${REACT_NATIVE_MINOR_VERSION} LESS 69)
|
||||
find_library(
|
||||
FOLLY_LIB
|
||||
folly_json
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else()
|
||||
find_library(
|
||||
FOLLY_LIB
|
||||
folly_runtime
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(
|
||||
REACTNATIVEJNI_LIB
|
||||
reactnativejni
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
${JSI_LIB}
|
||||
${GLOG_LIB}
|
||||
${FBJNI_LIB}
|
||||
${FOLLY_LIB}
|
||||
${REACTNATIVEJNI_LIB}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${JS_RUNTIME} STREQUAL "hermes")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
# From prefab from module `com.facebook.react:hermes-android`
|
||||
set(HERMES_LIB hermes-engine::libhermes)
|
||||
elseif(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 69)
|
||||
# Bundled Hermes from module `com.facebook.react:hermes-engine` or project `:ReactAndroid:hermes-engine`
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${JS_RUNTIME_DIR}/API"
|
||||
"${JS_RUNTIME_DIR}/public"
|
||||
)
|
||||
set(HERMES_LIB "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}/libhermes.so")
|
||||
else()
|
||||
# From `hermes-engine` npm package
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${JS_RUNTIME_DIR}/android/include"
|
||||
)
|
||||
set(HERMES_LIB "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}/libhermes.so")
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
${HERMES_LIB}
|
||||
)
|
||||
if (${HERMES_ENABLE_DEBUGGER})
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
set(HERMES_EXECUTOR_LIB ReactAndroid::hermes_executor)
|
||||
else()
|
||||
find_library(
|
||||
HERMES_EXECUTOR_LIB
|
||||
hermes-executor-debug
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif()
|
||||
if(${REACT_NATIVE_MINOR_VERSION} LESS_EQUAL 67)
|
||||
find_library(
|
||||
HERMES_INSPECTOR_LIB
|
||||
hermes-inspector
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
${HERMES_INSPECTOR_LIB}
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
${HERMES_EXECUTOR_LIB}
|
||||
)
|
||||
endif()
|
||||
elseif(${JS_RUNTIME} STREQUAL "v8")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
|
||||
target_include_directories(
|
||||
${PACKAGE_NAME}
|
||||
PRIVATE
|
||||
"${JS_RUNTIME_DIR}/src"
|
||||
)
|
||||
file (GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/*/jni/${ANDROID_ABI}")
|
||||
find_library(
|
||||
V8EXECUTOR_LIB
|
||||
v8executor
|
||||
PATHS ${V8_SO_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
${V8EXECUTOR_LIB}
|
||||
)
|
||||
elseif(${JS_RUNTIME} STREQUAL "jsc")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
|
||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
||||
set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
|
||||
else()
|
||||
find_library(
|
||||
JSEXECUTOR_LIB
|
||||
jscexecutor
|
||||
PATHS ${LIBRN_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(${PACKAGE_NAME} ${JSEXECUTOR_LIB})
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown JS runtime ${JS_RUNTIME}.")
|
||||
endif()
|
||||
|
||||
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
||||
target_link_libraries(
|
||||
${PACKAGE_NAME}
|
||||
ReactAndroid::fabricjni
|
||||
ReactAndroid::react_debug
|
||||
ReactAndroid::react_render_core
|
||||
ReactAndroid::react_render_mounting
|
||||
ReactAndroid::react_render_scheduler
|
||||
ReactAndroid::react_render_uimanager
|
||||
ReactAndroid::rrc_view
|
||||
)
|
||||
endif()
|
||||
|
||||
# Resolves "CMake Warning: Manually-specified variables were not used by the project"
|
||||
# when any of the following variables is not used in some build configuration.
|
||||
set (ignoreMe "${JS_RUNTIME_DIR}")
|
||||
set (ignoreMe "${BOOST_VERSION}")
|
||||
|
||||
+180
-723
File diff suppressed because it is too large
Load Diff
Generated
Vendored
BIN
Binary file not shown.
frontend-admin/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.properties
Generated
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
+1
@@ -1,2 +1,3 @@
|
||||
-keep class com.swmansion.reanimated.** { *; }
|
||||
-keep class com.facebook.react.turbomodule.** { *; }
|
||||
-keep class com.facebook.react.fabric.** { *; }
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ apply plugin: 'com.diffplug.spotless'
|
||||
|
||||
spotless {
|
||||
java {
|
||||
target 'src/main/java/**/*.java'
|
||||
target 'src/**/*.java'
|
||||
googleJavaFormat()
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+1
-4
@@ -1,5 +1,2 @@
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.swmansion.reanimated">
|
||||
|
||||
</manifest>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
|
||||
|
||||
Generated
Vendored
+94
-328
@@ -1,103 +1,49 @@
|
||||
package com.swmansion.reanimated;
|
||||
|
||||
import static java.lang.Float.NaN;
|
||||
|
||||
import android.view.View;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.GuardedRunnable;
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import android.os.SystemClock;
|
||||
import androidx.tracing.Trace;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.fabric.FabricUIManager;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.GuardedFrameCallback;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import com.facebook.react.uimanager.ReactShadowNode;
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.react.uimanager.UIImplementation;
|
||||
import com.facebook.react.uimanager.UIManagerHelper;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.UIManagerReanimatedHelper;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.react.uimanager.events.Event;
|
||||
import com.facebook.react.uimanager.events.EventDispatcherListener;
|
||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||
import com.swmansion.reanimated.layoutReanimation.AnimationsManager;
|
||||
import com.swmansion.reanimated.nativeProxy.NoopEventHandler;
|
||||
import com.swmansion.worklets.WorkletsModule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NodesManager implements EventDispatcherListener {
|
||||
|
||||
public void scrollTo(int viewTag, double x, double y, boolean animated) {
|
||||
View view;
|
||||
try {
|
||||
view = mUIManager.resolveView(viewTag);
|
||||
} catch (IllegalViewOperationException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
NativeMethodsHelper.scrollTo(view, x, y, animated);
|
||||
}
|
||||
|
||||
public void dispatchCommand(int viewTag, String commandId, ReadableArray commandArgs) {
|
||||
// mUIManager.dispatchCommand must be called from native modules queue thread
|
||||
// because of an assert in ShadowNodeRegistry.getNode
|
||||
mContext.runOnNativeModulesQueueThread(
|
||||
new GuardedRunnable(mContext.getExceptionHandler()) {
|
||||
@Override
|
||||
public void runGuarded() {
|
||||
mUIManager.dispatchCommand(viewTag, commandId, commandArgs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public float[] measure(int viewTag) {
|
||||
View view;
|
||||
try {
|
||||
view = mUIManager.resolveView(viewTag);
|
||||
} catch (IllegalViewOperationException e) {
|
||||
e.printStackTrace();
|
||||
return (new float[] {NaN, NaN, NaN, NaN, NaN, NaN});
|
||||
}
|
||||
return NativeMethodsHelper.measure(view);
|
||||
}
|
||||
private Long mFirstUptime = SystemClock.uptimeMillis();
|
||||
private boolean mSlowAnimationsEnabled = false;
|
||||
private int mAnimationsDragFactor;
|
||||
|
||||
public interface OnAnimationFrame {
|
||||
void onAnimationFrame(double timestampMs);
|
||||
}
|
||||
|
||||
private AnimationsManager mAnimationManager;
|
||||
private final UIImplementation mUIImplementation;
|
||||
private final DeviceEventManagerModule.RCTDeviceEventEmitter mEventEmitter;
|
||||
private final ReactChoreographer mReactChoreographer;
|
||||
private final GuardedFrameCallback mChoreographerCallback;
|
||||
protected final UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
||||
private final AtomicBoolean mCallbackPosted = new AtomicBoolean();
|
||||
private final ReactContext mContext;
|
||||
private final UIManagerModule mUIManager;
|
||||
private ReactApplicationContext mReactApplicationContext;
|
||||
private RCTEventEmitter mCustomEventHandler = new NoopEventHandler();
|
||||
private List<OnAnimationFrame> mFrameCallbacks = new ArrayList<>();
|
||||
private ConcurrentLinkedQueue<CopiedEvent> mEventQueue = new ConcurrentLinkedQueue<>();
|
||||
private double lastFrameTimeMs;
|
||||
public Set<String> uiProps = Collections.emptySet();
|
||||
public Set<String> nativeProps = Collections.emptySet();
|
||||
private ReaCompatibility compatibility;
|
||||
private FabricUIManager mFabricUIManager;
|
||||
|
||||
public NativeProxy getNativeProxy() {
|
||||
return mNativeProxy;
|
||||
@@ -105,47 +51,23 @@ public class NodesManager implements EventDispatcherListener {
|
||||
|
||||
private NativeProxy mNativeProxy;
|
||||
|
||||
public AnimationsManager getAnimationsManager() {
|
||||
return mAnimationManager;
|
||||
}
|
||||
|
||||
public void onCatalystInstanceDestroy() {
|
||||
if (mAnimationManager != null) {
|
||||
mAnimationManager.onCatalystInstanceDestroy();
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
if (mNativeProxy != null) {
|
||||
mNativeProxy.onCatalystInstanceDestroy();
|
||||
mNativeProxy.invalidate();
|
||||
mNativeProxy = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void initWithContext(ReactApplicationContext reactApplicationContext) {
|
||||
mReactApplicationContext = reactApplicationContext;
|
||||
mNativeProxy = new NativeProxy(reactApplicationContext);
|
||||
mAnimationManager.setAndroidUIScheduler(getNativeProxy().getAndroidUIScheduler());
|
||||
compatibility = new ReaCompatibility(reactApplicationContext);
|
||||
compatibility.registerFabricEventListener(this);
|
||||
}
|
||||
|
||||
private final class NativeUpdateOperation {
|
||||
public int mViewTag;
|
||||
public WritableMap mNativeProps;
|
||||
|
||||
public NativeUpdateOperation(int viewTag, WritableMap nativeProps) {
|
||||
mViewTag = viewTag;
|
||||
mNativeProps = nativeProps;
|
||||
if (mFabricUIManager != null) {
|
||||
mFabricUIManager.getEventDispatcher().removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
private Queue<NativeUpdateOperation> mOperationsInBatch = new LinkedList<>();
|
||||
private boolean mTryRunBatchUpdatesSynchronously = false;
|
||||
public NodesManager(ReactApplicationContext context, WorkletsModule workletsModule) {
|
||||
context.assertOnJSQueueThread();
|
||||
|
||||
public NodesManager(ReactContext context) {
|
||||
mContext = context;
|
||||
mUIManager = context.getNativeModule(UIManagerModule.class);
|
||||
mUIImplementation = mUIManager.getUIImplementation();
|
||||
mCustomEventNamesResolver = mUIManager.getDirectEventNamesResolver();
|
||||
UIManager uiManager = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC);
|
||||
assert uiManager != null;
|
||||
mCustomEventNamesResolver = uiManager::resolveCustomDirectEventName;
|
||||
mEventEmitter = context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
||||
|
||||
mReactChoreographer = ReactChoreographer.getInstance();
|
||||
@@ -157,17 +79,9 @@ public class NodesManager implements EventDispatcherListener {
|
||||
}
|
||||
};
|
||||
|
||||
// We register as event listener at the end, because we pass `this` and we haven't finished
|
||||
// contructing an object yet.
|
||||
// This lead to a crash described in
|
||||
// https://github.com/software-mansion/react-native-reanimated/issues/604 which was caused by
|
||||
// Nodes Manager being constructed on UI thread and registering for events.
|
||||
// Events are handled in the native modules thread in the `onEventDispatch()` method.
|
||||
// This method indirectly uses `mChoreographerCallback` which was created after event
|
||||
// registration, creating race condition
|
||||
mUIManager.getEventDispatcher().addListener(this);
|
||||
|
||||
mAnimationManager = new AnimationsManager(mContext, mUIManager);
|
||||
mNativeProxy = new NativeProxy(context, workletsModule, this);
|
||||
mFabricUIManager = (FabricUIManager) uiManager;
|
||||
mFabricUIManager.getEventDispatcher().addListener(this);
|
||||
}
|
||||
|
||||
public void onHostPause() {
|
||||
@@ -202,99 +116,58 @@ public class NodesManager implements EventDispatcherListener {
|
||||
}
|
||||
|
||||
public void performOperations() {
|
||||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
||||
if (mNativeProxy != null) {
|
||||
mNativeProxy.performOperations();
|
||||
}
|
||||
} else if (!mOperationsInBatch.isEmpty()) {
|
||||
final Queue<NativeUpdateOperation> copiedOperationsQueue = mOperationsInBatch;
|
||||
mOperationsInBatch = new LinkedList<>();
|
||||
final boolean trySynchronously = mTryRunBatchUpdatesSynchronously;
|
||||
mTryRunBatchUpdatesSynchronously = false;
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
mContext.runOnNativeModulesQueueThread(
|
||||
new GuardedRunnable(mContext.getExceptionHandler()) {
|
||||
@Override
|
||||
public void runGuarded() {
|
||||
boolean queueWasEmpty =
|
||||
UIManagerReanimatedHelper.isOperationQueueEmpty(mUIImplementation);
|
||||
boolean shouldDispatchUpdates = trySynchronously && queueWasEmpty;
|
||||
if (!shouldDispatchUpdates) {
|
||||
semaphore.release();
|
||||
}
|
||||
while (!copiedOperationsQueue.isEmpty()) {
|
||||
NativeUpdateOperation op = copiedOperationsQueue.remove();
|
||||
ReactShadowNode shadowNode = mUIImplementation.resolveShadowNode(op.mViewTag);
|
||||
if (shadowNode != null) {
|
||||
mUIManager.updateView(op.mViewTag, shadowNode.getViewClass(), op.mNativeProps);
|
||||
}
|
||||
}
|
||||
if (queueWasEmpty) {
|
||||
mUIImplementation.dispatchViewUpdates(-1); // no associated batchId
|
||||
}
|
||||
if (shouldDispatchUpdates) {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (trySynchronously) {
|
||||
try {
|
||||
semaphore.tryAcquire(16, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
// if the thread is interruped we just continue and let the layout update happen
|
||||
// asynchronously
|
||||
}
|
||||
}
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
if (mNativeProxy != null) {
|
||||
mNativeProxy.performOperations();
|
||||
}
|
||||
}
|
||||
|
||||
private void onAnimationFrame(long frameTimeNanos) {
|
||||
// Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "onAnimationFrame");
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
double currentFrameTimeMs = frameTimeNanos / 1000000.;
|
||||
|
||||
if (currentFrameTimeMs > lastFrameTimeMs) {
|
||||
// It is possible for ChoreographerCallback to be executed twice within the same frame
|
||||
// due to frame drops. If this occurs, the additional callback execution should be ignored.
|
||||
lastFrameTimeMs = currentFrameTimeMs;
|
||||
|
||||
while (!mEventQueue.isEmpty()) {
|
||||
CopiedEvent copiedEvent = mEventQueue.poll();
|
||||
handleEvent(
|
||||
copiedEvent.getTargetTag(), copiedEvent.getEventName(), copiedEvent.getPayload());
|
||||
try {
|
||||
if (BuildConfig.REANIMATED_PROFILING) {
|
||||
Trace.beginSection("onAnimationFrame");
|
||||
}
|
||||
|
||||
if (!mFrameCallbacks.isEmpty()) {
|
||||
List<OnAnimationFrame> frameCallbacks = mFrameCallbacks;
|
||||
mFrameCallbacks = new ArrayList<>(frameCallbacks.size());
|
||||
for (int i = 0, size = frameCallbacks.size(); i < size; i++) {
|
||||
frameCallbacks.get(i).onAnimationFrame(currentFrameTimeMs);
|
||||
double currentFrameTimeMs = frameTimeNanos / 1000000.;
|
||||
if (mSlowAnimationsEnabled) {
|
||||
currentFrameTimeMs =
|
||||
mFirstUptime + (currentFrameTimeMs - mFirstUptime) / mAnimationsDragFactor;
|
||||
}
|
||||
|
||||
if (currentFrameTimeMs > lastFrameTimeMs) {
|
||||
// It is possible for ChoreographerCallback to be executed twice within the same frame
|
||||
// due to frame drops. If this occurs, the additional callback execution should be ignored.
|
||||
lastFrameTimeMs = currentFrameTimeMs;
|
||||
|
||||
while (!mEventQueue.isEmpty()) {
|
||||
CopiedEvent copiedEvent = mEventQueue.poll();
|
||||
handleEvent(
|
||||
copiedEvent.getTargetTag(), copiedEvent.getEventName(), copiedEvent.getPayload());
|
||||
}
|
||||
|
||||
if (!mFrameCallbacks.isEmpty()) {
|
||||
List<OnAnimationFrame> frameCallbacks = mFrameCallbacks;
|
||||
mFrameCallbacks = new ArrayList<>(frameCallbacks.size());
|
||||
for (int i = 0, size = frameCallbacks.size(); i < size; i++) {
|
||||
frameCallbacks.get(i).onAnimationFrame(currentFrameTimeMs);
|
||||
}
|
||||
}
|
||||
|
||||
performOperations();
|
||||
}
|
||||
|
||||
performOperations();
|
||||
mCallbackPosted.set(false);
|
||||
if (!mFrameCallbacks.isEmpty() || !mEventQueue.isEmpty()) {
|
||||
// enqueue next frame
|
||||
startUpdatingOnAnimationFrame();
|
||||
}
|
||||
} finally {
|
||||
if (BuildConfig.REANIMATED_PROFILING) {
|
||||
Trace.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
mCallbackPosted.set(false);
|
||||
if (!mFrameCallbacks.isEmpty() || !mEventQueue.isEmpty()) {
|
||||
// enqueue next frame
|
||||
startUpdatingOnAnimationFrame();
|
||||
}
|
||||
|
||||
// Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
|
||||
public void enqueueUpdateViewOnNativeThread(
|
||||
int viewTag, WritableMap nativeProps, boolean trySynchronously) {
|
||||
if (trySynchronously) {
|
||||
mTryRunBatchUpdatesSynchronously = true;
|
||||
}
|
||||
mOperationsInBatch.add(new NativeUpdateOperation(viewTag, nativeProps));
|
||||
}
|
||||
|
||||
public void configureProps(Set<String> uiPropsSet, Set<String> nativePropsSet) {
|
||||
uiProps = uiPropsSet;
|
||||
nativeProps = nativePropsSet;
|
||||
}
|
||||
|
||||
public void postOnAnimation(OnAnimationFrame onAnimationFrame) {
|
||||
@@ -304,22 +177,32 @@ public class NodesManager implements EventDispatcherListener {
|
||||
|
||||
@Override
|
||||
public void onEventDispatch(Event event) {
|
||||
if (mNativeProxy == null) {
|
||||
return;
|
||||
}
|
||||
// Events can be dispatched from any thread so we have to make sure handleEvent is run from the
|
||||
// UI thread.
|
||||
if (UiThreadUtil.isOnUiThread()) {
|
||||
handleEvent(event);
|
||||
performOperations();
|
||||
} else {
|
||||
String eventName = mCustomEventNamesResolver.resolveCustomEventName(event.getEventName());
|
||||
int viewTag = event.getViewTag();
|
||||
boolean shouldSaveEvent = mNativeProxy.isAnyHandlerWaitingForEvent(eventName, viewTag);
|
||||
if (shouldSaveEvent) {
|
||||
mEventQueue.offer(new CopiedEvent(event));
|
||||
try {
|
||||
if (BuildConfig.REANIMATED_PROFILING) {
|
||||
Trace.beginSection("onEventDispatch");
|
||||
}
|
||||
|
||||
if (mNativeProxy == null) {
|
||||
return;
|
||||
}
|
||||
// Events can be dispatched from any thread so we have to make sure handleEvent is run from
|
||||
// the UI thread.
|
||||
if (UiThreadUtil.isOnUiThread()) {
|
||||
handleEvent(event);
|
||||
performOperations();
|
||||
} else {
|
||||
String eventName = mCustomEventNamesResolver.resolveCustomEventName(event.getEventName());
|
||||
int viewTag = event.getViewTag();
|
||||
boolean shouldSaveEvent = mNativeProxy.isAnyHandlerWaitingForEvent(eventName, viewTag);
|
||||
if (shouldSaveEvent) {
|
||||
mEventQueue.offer(new CopiedEvent(event));
|
||||
}
|
||||
startUpdatingOnAnimationFrame();
|
||||
}
|
||||
} finally {
|
||||
if (BuildConfig.REANIMATED_PROFILING) {
|
||||
Trace.endSection();
|
||||
}
|
||||
startUpdatingOnAnimationFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,128 +226,11 @@ public class NodesManager implements EventDispatcherListener {
|
||||
mEventEmitter.emit(name, body);
|
||||
}
|
||||
|
||||
public void updateProps(int viewTag, Map<String, Object> props) {
|
||||
// TODO: update PropsNode to use this method instead of its own way of updating props
|
||||
boolean hasUIProps = false;
|
||||
boolean hasNativeProps = false;
|
||||
boolean hasJSProps = false;
|
||||
JavaOnlyMap newUIProps = new JavaOnlyMap();
|
||||
WritableMap newJSProps = Arguments.createMap();
|
||||
WritableMap newNativeProps = Arguments.createMap();
|
||||
|
||||
for (Map.Entry<String, Object> entry : props.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (uiProps.contains(key)) {
|
||||
hasUIProps = true;
|
||||
addProp(newUIProps, key, value);
|
||||
} else if (nativeProps.contains(key)) {
|
||||
hasNativeProps = true;
|
||||
addProp(newNativeProps, key, value);
|
||||
} else {
|
||||
hasJSProps = true;
|
||||
addProp(newJSProps, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (viewTag != View.NO_ID) {
|
||||
if (hasUIProps) {
|
||||
mUIImplementation.synchronouslyUpdateViewOnUIThread(
|
||||
viewTag, new ReactStylesDiffMap(newUIProps));
|
||||
}
|
||||
if (hasNativeProps) {
|
||||
enqueueUpdateViewOnNativeThread(viewTag, newNativeProps, true);
|
||||
}
|
||||
if (hasJSProps) {
|
||||
WritableMap evt = Arguments.createMap();
|
||||
evt.putInt("viewTag", viewTag);
|
||||
evt.putMap("props", newJSProps);
|
||||
sendEvent("onReanimatedPropsChange", evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
|
||||
compatibility.synchronouslyUpdateUIProps(viewTag, uiProps);
|
||||
}
|
||||
|
||||
public String obtainProp(int viewTag, String propName) {
|
||||
View view = mUIManager.resolveView(viewTag);
|
||||
String result =
|
||||
"error: unknown propName " + propName + ", currently supported: opacity, zIndex";
|
||||
if (propName.equals("opacity")) {
|
||||
Float opacity = view.getAlpha();
|
||||
result = Float.toString(opacity);
|
||||
} else if (propName.equals("zIndex")) {
|
||||
Float zIndex = view.getElevation();
|
||||
result = Float.toString(zIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static WritableMap copyReadableMap(ReadableMap map) {
|
||||
WritableMap copy = Arguments.createMap();
|
||||
copy.merge(map);
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static WritableArray copyReadableArray(ReadableArray array) {
|
||||
WritableArray copy = Arguments.createArray();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
ReadableType type = array.getType(i);
|
||||
switch (type) {
|
||||
case Boolean:
|
||||
copy.pushBoolean(array.getBoolean(i));
|
||||
break;
|
||||
case String:
|
||||
copy.pushString(array.getString(i));
|
||||
break;
|
||||
case Null:
|
||||
copy.pushNull();
|
||||
break;
|
||||
case Number:
|
||||
copy.pushDouble(array.getDouble(i));
|
||||
break;
|
||||
case Map:
|
||||
copy.pushMap(copyReadableMap(array.getMap(i)));
|
||||
break;
|
||||
case Array:
|
||||
copy.pushArray(copyReadableArray(array.getArray(i)));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("[Reanimated] Unknown type of ReadableArray.");
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static void addProp(WritableMap propMap, String key, Object value) {
|
||||
if (value == null) {
|
||||
propMap.putNull(key);
|
||||
} else if (value instanceof Double) {
|
||||
propMap.putDouble(key, (Double) value);
|
||||
} else if (value instanceof Integer) {
|
||||
propMap.putInt(key, (Integer) value);
|
||||
} else if (value instanceof Number) {
|
||||
propMap.putDouble(key, ((Number) value).doubleValue());
|
||||
} else if (value instanceof Boolean) {
|
||||
propMap.putBoolean(key, (Boolean) value);
|
||||
} else if (value instanceof String) {
|
||||
propMap.putString(key, (String) value);
|
||||
} else if (value instanceof ReadableArray) {
|
||||
if (!(value instanceof WritableArray)) {
|
||||
propMap.putArray(key, copyReadableArray((ReadableArray) value));
|
||||
} else {
|
||||
propMap.putArray(key, (ReadableArray) value);
|
||||
}
|
||||
} else if (value instanceof ReadableMap) {
|
||||
if (!(value instanceof WritableMap)) {
|
||||
propMap.putMap(key, copyReadableMap((ReadableMap) value));
|
||||
} else {
|
||||
propMap.putMap(key, (ReadableMap) value);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("[Reanimated] Unknown type of animated value.");
|
||||
public void enableSlowAnimations(boolean slowAnimationsEnabled, int animationsDragFactor) {
|
||||
mSlowAnimationsEnabled = slowAnimationsEnabled;
|
||||
mAnimationsDragFactor = animationsDragFactor;
|
||||
if (slowAnimationsEnabled) {
|
||||
mFirstUptime = SystemClock.uptimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+24
-78
@@ -1,55 +1,38 @@
|
||||
package com.swmansion.reanimated;
|
||||
|
||||
import android.util.Log;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
||||
import com.facebook.react.uimanager.UIBlock;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.UIManagerModuleListener;
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Nullable;
|
||||
import com.swmansion.worklets.WorkletsModule;
|
||||
|
||||
@ReactModule(name = ReanimatedModule.NAME)
|
||||
public class ReanimatedModule extends ReactContextBaseJavaModule
|
||||
implements LifecycleEventListener, UIManagerModuleListener {
|
||||
|
||||
public static final String NAME = "ReanimatedModule";
|
||||
|
||||
private interface UIThreadOperation {
|
||||
void execute(NodesManager nodesManager);
|
||||
}
|
||||
|
||||
private ArrayList<UIThreadOperation> mOperations = new ArrayList<>();
|
||||
private @Nullable NodesManager mNodesManager;
|
||||
public class ReanimatedModule extends NativeReanimatedModuleSpec implements LifecycleEventListener {
|
||||
private final NodesManager mNodesManager;
|
||||
private final WorkletsModule mWorkletsModule;
|
||||
|
||||
public ReanimatedModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
reactContext.assertOnJSQueueThread();
|
||||
mWorkletsModule = reactContext.getNativeModule(WorkletsModule.class);
|
||||
mNodesManager = new NodesManager(reactContext, mWorkletsModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
ReactApplicationContext reactCtx = getReactApplicationContext();
|
||||
UIManagerModule uiManager = reactCtx.getNativeModule(UIManagerModule.class);
|
||||
reactCtx.addLifecycleEventListener(this);
|
||||
uiManager.addUIManagerListener(this);
|
||||
ReactApplicationContext reactContext = getReactApplicationContext();
|
||||
reactContext.assertOnJSQueueThread();
|
||||
reactContext.addLifecycleEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostPause() {
|
||||
if (mNodesManager != null) {
|
||||
mNodesManager.onHostPause();
|
||||
}
|
||||
mNodesManager.onHostPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
if (mNodesManager != null) {
|
||||
mNodesManager.onHostResume();
|
||||
}
|
||||
mNodesManager.onHostResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,70 +40,33 @@ public class ReanimatedModule extends ReactContextBaseJavaModule
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void willDispatchViewUpdates(final UIManagerModule uiManager) {
|
||||
if (mOperations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final ArrayList<UIThreadOperation> operations = mOperations;
|
||||
mOperations = new ArrayList<>();
|
||||
uiManager.addUIBlock(
|
||||
new UIBlock() {
|
||||
@Override
|
||||
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
||||
NodesManager nodesManager = getNodesManager();
|
||||
for (UIThreadOperation operation : operations) {
|
||||
operation.execute(nodesManager);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/*package*/
|
||||
public NodesManager getNodesManager() {
|
||||
if (mNodesManager == null) {
|
||||
mNodesManager = new NodesManager(getReactApplicationContext());
|
||||
}
|
||||
|
||||
// This method is called from react-native-gesture-handler.
|
||||
return mNodesManager;
|
||||
}
|
||||
|
||||
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||
public void installTurboModule() {
|
||||
// When debugging in chrome the JS context is not available.
|
||||
// https://github.com/facebook/react-native/blob/v0.67.0-rc.6/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.java#L25
|
||||
Utils.isChromeDebugger = getReactApplicationContext().getJavaScriptContextHolder().get() == 0;
|
||||
|
||||
if (!Utils.isChromeDebugger) {
|
||||
this.getNodesManager().initWithContext(getReactApplicationContext());
|
||||
} else {
|
||||
Log.w(
|
||||
"[REANIMATED]",
|
||||
"Unable to create Reanimated Native Module. You can ignore this message if you are using Chrome Debugger now.");
|
||||
}
|
||||
public boolean installTurboModule() {
|
||||
getReactApplicationContext().assertOnJSQueueThread();
|
||||
mNodesManager.getNativeProxy().installJSIBindings();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void addListener(String eventName) {
|
||||
public void addListener(String ignoredEventName) {
|
||||
// Keep: Required for RN built in Event Emitter Calls.
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void removeListeners(Integer count) {
|
||||
public void removeListeners(Integer ignoredCount) {
|
||||
// Keep: Required for RN built in Event Emitter Calls.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
super.onCatalystInstanceDestroy();
|
||||
|
||||
if (mNodesManager != null) {
|
||||
mNodesManager.onCatalystInstanceDestroy();
|
||||
}
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
mNodesManager.invalidate();
|
||||
ReactApplicationContext reactContext = getReactApplicationContext();
|
||||
reactContext.removeLifecycleEventListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+21
-47
@@ -1,84 +1,58 @@
|
||||
package com.swmansion.reanimated;
|
||||
|
||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
|
||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.react.BaseReactPackage;
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.TurboReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.module.annotations.ReactModuleList;
|
||||
import com.facebook.react.module.model.ReactModuleInfo;
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import com.facebook.react.uimanager.ReanimatedUIManager;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ReanimatedPackage extends TurboReactPackage implements ReactPackage {
|
||||
|
||||
@ReactModuleList(
|
||||
nativeModules = {
|
||||
ReanimatedModule.class,
|
||||
})
|
||||
public class ReanimatedPackage extends BaseReactPackage implements ReactPackage {
|
||||
@Override
|
||||
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
||||
if (name.equals(ReanimatedModule.NAME)) {
|
||||
return new ReanimatedModule(reactContext);
|
||||
}
|
||||
if (name.equals(ReanimatedUIManager.NAME)) {
|
||||
return createUIManager(reactContext);
|
||||
}
|
||||
return null;
|
||||
public NativeModule getModule(
|
||||
@NonNull String name, @NonNull ReactApplicationContext reactContext) {
|
||||
return switch (name) {
|
||||
case ReanimatedModule.NAME -> new ReanimatedModule(reactContext);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
||||
Class<? extends NativeModule>[] moduleList =
|
||||
new Class[] {
|
||||
ReanimatedModule.class, ReanimatedUIManager.class,
|
||||
ReanimatedModule.class,
|
||||
};
|
||||
|
||||
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
|
||||
for (Class<? extends NativeModule> moduleClass : moduleList) {
|
||||
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);
|
||||
ReactModule reactModule =
|
||||
Objects.requireNonNull(moduleClass.getAnnotation(ReactModule.class));
|
||||
|
||||
reactModuleInfoMap.put(
|
||||
reactModule.name(),
|
||||
new ReactModuleInfo(
|
||||
reactModule.name(),
|
||||
moduleClass.getName(),
|
||||
true,
|
||||
reactModule.canOverrideExistingModule(),
|
||||
reactModule.needsEagerInit(),
|
||||
reactModule.hasConstants(),
|
||||
reactModule.isCxxModule(),
|
||||
TurboModule.class.isAssignableFrom(moduleClass)));
|
||||
true));
|
||||
}
|
||||
|
||||
return new ReactModuleInfoProvider() {
|
||||
@Override
|
||||
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
||||
return reactModuleInfoMap;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private UIManagerModule createUIManager(final ReactApplicationContext reactContext) {
|
||||
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
|
||||
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
|
||||
final ReactInstanceManager reactInstanceManager = getReactInstanceManager(reactContext);
|
||||
List<ViewManager> viewManagers = reactInstanceManager.getOrCreateViewManagers(reactContext);
|
||||
int minTimeLeftInFrameForNonBatchedOperationMs = -1;
|
||||
try {
|
||||
return ReanimatedUIManagerFactory.create(
|
||||
reactContext, viewManagers, minTimeLeftInFrameForNonBatchedOperationMs);
|
||||
} finally {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
|
||||
}
|
||||
return () -> reactModuleInfoMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Generated
Vendored
+10
-2
@@ -8,8 +8,6 @@ import java.util.Map;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static boolean isChromeDebugger = false;
|
||||
|
||||
public static Map<String, Integer> processMapping(ReadableMap style) {
|
||||
ReadableMapKeySetIterator iter = style.keySetIterator();
|
||||
HashMap<String, Integer> mapping = new HashMap<>();
|
||||
@@ -46,4 +44,14 @@ public class Utils {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Runnable combineRunnables(final Runnable... runnables) {
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
for (Runnable r : runnables) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+2
-1
@@ -12,7 +12,8 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||
public class EventHandler implements RCTEventEmitter {
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
||||
|
||||
public UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
||||
|
||||
@DoNotStrip
|
||||
private EventHandler(HybridData hybridData) {
|
||||
|
||||
Generated
Vendored
+2
-1
@@ -17,6 +17,7 @@ public class ReanimatedSensor {
|
||||
Sensor sensor;
|
||||
ReanimatedSensorType sensorType;
|
||||
int interval;
|
||||
private static final int DEFAULT_INTERVAL = 8;
|
||||
|
||||
ReanimatedSensor(
|
||||
WeakReference<ReactApplicationContext> reactContext,
|
||||
@@ -30,7 +31,7 @@ public class ReanimatedSensor {
|
||||
(SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE);
|
||||
this.sensorType = sensorType;
|
||||
if (interval == -1) {
|
||||
this.interval = SensorManager.SENSOR_DELAY_UI;
|
||||
this.interval = DEFAULT_INTERVAL;
|
||||
} else {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
+6
-57
@@ -1,61 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
export { AnimatedText as Text } from './reanimated2/component/Text';
|
||||
export { AnimatedView as View } from './reanimated2/component/View';
|
||||
export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
|
||||
export { AnimatedImage as Image } from './reanimated2/component/Image';
|
||||
export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
|
||||
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||
export { AnimatedImage as Image } from './component/Image';
|
||||
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||
export { AnimatedText as Text } from './component/Text';
|
||||
export { AnimatedView as View } from './component/View';
|
||||
export { addWhitelistedNativeProps, addWhitelistedUIProps } from './ConfigHelper';
|
||||
/**
|
||||
* @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
|
||||
/**
|
||||
* @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
//# sourceMappingURL=Animated.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":["createAnimatedComponent","AnimatedText","Text","AnimatedView","View","AnimatedScrollView","ScrollView","AnimatedImage","Image","ReanimatedFlatList","FlatList","addWhitelistedNativeProps","addWhitelistedUIProps"],"sources":["Animated.ts"],"sourcesContent":["'use strict';\nimport type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';\nimport type { SharedValue as _SharedValue } from './reanimated2/commonTypes';\nimport type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';\nimport type {\n TransformStyleTypes as _TransformStyleTypes,\n Adaptable as _Adaptable,\n AdaptTransforms as _AdaptTransforms,\n AnimatedTransform as _AnimatedTransform,\n AnimateStyle as _AnimateStyle,\n StylesOrDefault as _StylesOrDefault,\n AnimateProps as _AnimateProps,\n} from './reanimated2/helperTypes';\nimport type { EasingFunction as _EasingFunction } from './reanimated2/Easing';\n\nimport type { AnimatedScrollViewProps as _AnimatedScrollViewProps } from './reanimated2/component/ScrollView';\nimport type { FlatListPropsWithLayout as _FlatListPropsWithLayout } from './reanimated2/component/FlatList';\n\nexport { createAnimatedComponent } from './createAnimatedComponent';\nexport { AnimatedText as Text } from './reanimated2/component/Text';\nexport { AnimatedView as View } from './reanimated2/component/View';\nexport { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';\nexport { AnimatedImage as Image } from './reanimated2/component/Image';\nexport { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';\nexport {\n addWhitelistedNativeProps,\n addWhitelistedUIProps,\n} from './ConfigHelper';\n/**\n * @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type Extrapolate = typeof _Extrapolate;\n/**\n * @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\n\nexport type SharedValue<T> = _SharedValue<T>;\n/**\n * @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type DerivedValue<T> = _DerivedValue<T>;\n/**\n * @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type Adaptable<T> = _Adaptable<T>;\n/**\n * @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type TransformStyleTypes = _TransformStyleTypes;\n/**\n * @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AdaptTransforms<T> = _AdaptTransforms<T>;\n/**\n * @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type AnimatedTransform = _AnimatedTransform;\n/**\n * @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimateStyle<S> = _AnimateStyle<S>;\n/**\n * @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type StylesOrDefault<S> = _StylesOrDefault<S>;\n/**\n * @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimateProps<P extends object> = _AnimateProps<P>;\n/**\n * @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type EasingFunction = _EasingFunction;\n/**\n * @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimatedScrollViewProps = _AnimatedScrollViewProps;\n/**\n * @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type FlatListPropsWithLayout<T> = _FlatListPropsWithLayout<T>;\n"],"mappings":"AAAA,YAAY;;AAkBZ,SAASA,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,YAAY,IAAIC,IAAI,QAAQ,8BAA8B;AACnE,SAASC,YAAY,IAAIC,IAAI,QAAQ,8BAA8B;AACnE,SAASC,kBAAkB,IAAIC,UAAU,QAAQ,oCAAoC;AACrF,SAASC,aAAa,IAAIC,KAAK,QAAQ,+BAA+B;AACtE,SAASC,kBAAkB,IAAIC,QAAQ,QAAQ,kCAAkC;AACjF,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,gBAAgB;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA"}
|
||||
{"version":3,"names":["ReanimatedFlatList","FlatList","AnimatedImage","Image","AnimatedScrollView","ScrollView","AnimatedText","Text","AnimatedView","View","addWhitelistedNativeProps","addWhitelistedUIProps","createAnimatedComponent"],"sourceRoot":"../../src","sources":["Animated.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,kBAAkB,IAAIC,QAAQ,QAAQ,sBAAsB;AACrE,SAASC,aAAa,IAAIC,KAAK,QAAQ,mBAAmB;AAC1D,SAASC,kBAAkB,IAAIC,UAAU,QAAQ,wBAAwB;AACzE,SAASC,YAAY,IAAIC,IAAI,QAAQ,kBAAkB;AACvD,SAASC,YAAY,IAAIC,IAAI,QAAQ,kBAAkB;AACvD,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,gBAAgB;AACvB,SAASC,uBAAuB,QAAQ,2BAA2B","ignoreList":[]}
|
||||
|
||||
+26
-52
@@ -1,61 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
import { PropsAllowlists } from './propsAllowlists';
|
||||
import { jsiConfigureProps } from './reanimated2/core';
|
||||
function assertNoOverlapInLists() {
|
||||
for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {
|
||||
if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {
|
||||
throw new Error(`[Reanimated] Property \`${key}\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`);
|
||||
}
|
||||
}
|
||||
import { executeOnUIRuntimeSync } from 'react-native-worklets';
|
||||
import { getLoggerConfig, SHOULD_BE_USE_WEB, updateLoggerConfig } from './common';
|
||||
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export function addWhitelistedNativeProps(_props) {
|
||||
// Do nothing. This is just for backward compatibility.
|
||||
}
|
||||
function configureProps() {
|
||||
assertNoOverlapInLists();
|
||||
jsiConfigureProps(Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST), Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST));
|
||||
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export function addWhitelistedUIProps(_props) {
|
||||
// Do nothing. This is just for backward compatibility.
|
||||
}
|
||||
export function addWhitelistedNativeProps(props) {
|
||||
const oldSize = Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length;
|
||||
PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST = {
|
||||
...PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST,
|
||||
...props
|
||||
};
|
||||
if (oldSize !== Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length) {
|
||||
configureProps();
|
||||
}
|
||||
}
|
||||
export function addWhitelistedUIProps(props) {
|
||||
const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;
|
||||
PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {
|
||||
...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,
|
||||
...props
|
||||
};
|
||||
if (oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length) {
|
||||
configureProps();
|
||||
}
|
||||
}
|
||||
const PROCESSED_VIEW_NAMES = new Set();
|
||||
|
||||
/**
|
||||
* updates UI props whitelist for given view host instance
|
||||
* this will work just once for every view name
|
||||
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||
* affect Reanimated code executed after call to this function so it should be
|
||||
* called before any Reanimated code is executed to take effect. Each call to
|
||||
* this function will override the previous configuration (it's recommended to
|
||||
* call it only once).
|
||||
*
|
||||
* @param config - The new logger configuration to apply.
|
||||
*/
|
||||
|
||||
export function adaptViewConfig(viewConfig) {
|
||||
const viewName = viewConfig.uiViewClassName;
|
||||
const props = viewConfig.validAttributes;
|
||||
|
||||
// update whitelist of UI props for this view name only once
|
||||
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
||||
const propsToAdd = {};
|
||||
Object.keys(props).forEach(key => {
|
||||
// we don't want to add native props as they affect layout
|
||||
// we also skip props which repeat here
|
||||
if (!(key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) && !(key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST)) {
|
||||
propsToAdd[key] = true;
|
||||
}
|
||||
});
|
||||
addWhitelistedUIProps(propsToAdd);
|
||||
PROCESSED_VIEW_NAMES.add(viewName);
|
||||
export function configureReanimatedLogger(config) {
|
||||
// Get the current config from the React runtime (to have a single source of truth)
|
||||
const currentConfig = getLoggerConfig();
|
||||
// Update the configuration object in the React runtime
|
||||
updateLoggerConfig(currentConfig, config);
|
||||
// Register the updated configuration in the UI runtime
|
||||
if (!SHOULD_BE_USE_WEB) {
|
||||
executeOnUIRuntimeSync(updateLoggerConfig)(currentConfig, config);
|
||||
}
|
||||
}
|
||||
configureProps();
|
||||
//# sourceMappingURL=ConfigHelper.js.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":["PropsAllowlists","jsiConfigureProps","assertNoOverlapInLists","key","NATIVE_THREAD_PROPS_WHITELIST","UI_THREAD_PROPS_WHITELIST","Error","configureProps","Object","keys","addWhitelistedNativeProps","props","oldSize","length","addWhitelistedUIProps","PROCESSED_VIEW_NAMES","Set","adaptViewConfig","viewConfig","viewName","uiViewClassName","validAttributes","has","propsToAdd","forEach","add"],"sources":["ConfigHelper.ts"],"sourcesContent":["'use strict';\nimport { PropsAllowlists } from './propsAllowlists';\nimport { jsiConfigureProps } from './reanimated2/core';\nfunction assertNoOverlapInLists() {\n for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {\n if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {\n throw new Error(\n `[Reanimated] Property \\`${key}\\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`\n );\n }\n }\n}\n\nfunction configureProps(): void {\n assertNoOverlapInLists();\n jsiConfigureProps(\n Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST),\n Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST)\n );\n}\n\nexport function addWhitelistedNativeProps(\n props: Record<string, boolean>\n): void {\n const oldSize = Object.keys(\n PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST\n ).length;\n PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST = {\n ...PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST,\n ...props,\n };\n if (\n oldSize !==\n Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length\n ) {\n configureProps();\n }\n}\n\nexport function addWhitelistedUIProps(props: Record<string, boolean>): void {\n const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;\n PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {\n ...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,\n ...props,\n };\n if (\n oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length\n ) {\n configureProps();\n }\n}\n\nconst PROCESSED_VIEW_NAMES = new Set();\n\nexport interface ViewConfig {\n uiViewClassName: string;\n validAttributes: Record<string, unknown>;\n}\n/**\n * updates UI props whitelist for given view host instance\n * this will work just once for every view name\n */\n\nexport function adaptViewConfig(viewConfig: ViewConfig): void {\n const viewName = viewConfig.uiViewClassName;\n const props = viewConfig.validAttributes;\n\n // update whitelist of UI props for this view name only once\n if (!PROCESSED_VIEW_NAMES.has(viewName)) {\n const propsToAdd: Record<string, boolean> = {};\n Object.keys(props).forEach((key) => {\n // we don't want to add native props as they affect layout\n // we also skip props which repeat here\n if (\n !(key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) &&\n !(key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST)\n ) {\n propsToAdd[key] = true;\n }\n });\n addWhitelistedUIProps(propsToAdd);\n\n PROCESSED_VIEW_NAMES.add(viewName);\n }\n}\n\nconfigureProps();\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,sBAAsBA,CAAA,EAAG;EAChC,KAAK,MAAMC,GAAG,IAAIH,eAAe,CAACI,6BAA6B,EAAE;IAC/D,IAAID,GAAG,IAAIH,eAAe,CAACK,yBAAyB,EAAE;MACpD,MAAM,IAAIC,KAAK,CACZ,2BAA0BH,GAAI,wFAAuF,CACvH;IACH;EACF;AACF;AAEA,SAASI,cAAcA,CAAA,EAAS;EAC9BL,sBAAsB,EAAE;EACxBD,iBAAiB,CACfO,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,EACtDG,MAAM,CAACC,IAAI,CAACT,eAAe,CAACI,6BAA6B,CAAC,CAC3D;AACH;AAEA,OAAO,SAASM,yBAAyBA,CACvCC,KAA8B,EACxB;EACN,MAAMC,OAAO,GAAGJ,MAAM,CAACC,IAAI,CACzBT,eAAe,CAACI,6BAA6B,CAC9C,CAACS,MAAM;EACRb,eAAe,CAACI,6BAA6B,GAAG;IAC9C,GAAGJ,eAAe,CAACI,6BAA6B;IAChD,GAAGO;EACL,CAAC;EACD,IACEC,OAAO,KACPJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACI,6BAA6B,CAAC,CAACS,MAAM,EACjE;IACAN,cAAc,EAAE;EAClB;AACF;AAEA,OAAO,SAASO,qBAAqBA,CAACH,KAA8B,EAAQ;EAC1E,MAAMC,OAAO,GAAGJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,CAACQ,MAAM;EAC7Eb,eAAe,CAACK,yBAAyB,GAAG;IAC1C,GAAGL,eAAe,CAACK,yBAAyB;IAC5C,GAAGM;EACL,CAAC;EACD,IACEC,OAAO,KAAKJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,CAACQ,MAAM,EACzE;IACAN,cAAc,EAAE;EAClB;AACF;AAEA,MAAMQ,oBAAoB,GAAG,IAAIC,GAAG,EAAE;AAMtC;AACA;AACA;AACA;;AAEA,OAAO,SAASC,eAAeA,CAACC,UAAsB,EAAQ;EAC5D,MAAMC,QAAQ,GAAGD,UAAU,CAACE,eAAe;EAC3C,MAAMT,KAAK,GAAGO,UAAU,CAACG,eAAe;;EAExC;EACA,IAAI,CAACN,oBAAoB,CAACO,GAAG,CAACH,QAAQ,CAAC,EAAE;IACvC,MAAMI,UAAmC,GAAG,CAAC,CAAC;IAC9Cf,MAAM,CAACC,IAAI,CAACE,KAAK,CAAC,CAACa,OAAO,CAAErB,GAAG,IAAK;MAClC;MACA;MACA,IACE,EAAEA,GAAG,IAAIH,eAAe,CAACI,6BAA6B,CAAC,IACvD,EAAED,GAAG,IAAIH,eAAe,CAACK,yBAAyB,CAAC,EACnD;QACAkB,UAAU,CAACpB,GAAG,CAAC,GAAG,IAAI;MACxB;IACF,CAAC,CAAC;IACFW,qBAAqB,CAACS,UAAU,CAAC;IAEjCR,oBAAoB,CAACU,GAAG,CAACN,QAAQ,CAAC;EACpC;AACF;AAEAZ,cAAc,EAAE"}
|
||||
{"version":3,"names":["executeOnUIRuntimeSync","getLoggerConfig","SHOULD_BE_USE_WEB","updateLoggerConfig","addWhitelistedNativeProps","_props","addWhitelistedUIProps","configureReanimatedLogger","config","currentConfig"],"sourceRoot":"../../src","sources":["ConfigHelper.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,sBAAsB,QAAQ,uBAAuB;AAG9D,SACEC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,QACb,UAAU;;AAEjB;AACA,OAAO,SAASC,yBAAyBA,CACvCC,MAA+B,EACzB;EACN;AAAA;;AAGF;AACA,OAAO,SAASC,qBAAqBA,CAACD,MAA+B,EAAQ;EAC3E;AAAA;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,yBAAyBA,CAACC,MAAoB,EAAE;EAC9D;EACA,MAAMC,aAAa,GAAGR,eAAe,CAAC,CAAC;EACvC;EACAE,kBAAkB,CAACM,aAAa,EAAED,MAAM,CAAC;EACzC;EACA,IAAI,CAACN,iBAAiB,EAAE;IACtBF,sBAAsB,CAACG,kBAAkB,CAAC,CAACM,aAAa,EAAED,MAAM,CAAC;EACnE;AACF","ignoreList":[]}
|
||||
|
||||
Generated
Vendored
+20
-7
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import { logger } from './common';
|
||||
const mockTargetValues = {
|
||||
targetOriginX: 0,
|
||||
targetOriginY: 0,
|
||||
@@ -18,18 +19,30 @@ const mockTargetValues = {
|
||||
currentGlobalOriginY: 0,
|
||||
currentBorderRadius: 0
|
||||
};
|
||||
function getCommonProperties(layoutStyle, componentStyle) {
|
||||
let componentStyleFlat = Array.isArray(componentStyle) ? componentStyle.flat() : [componentStyle];
|
||||
componentStyleFlat = componentStyleFlat.filter(Boolean);
|
||||
componentStyleFlat = componentStyleFlat.map(style => 'initial' in style ? style.initial.value // Include properties of animated style
|
||||
: style);
|
||||
const componentStylesKeys = componentStyleFlat.flatMap(style => Object.keys(style));
|
||||
const commonKeys = Object.keys(layoutStyle).filter(key => componentStylesKeys.includes(key));
|
||||
return commonKeys;
|
||||
}
|
||||
function maybeReportOverwrittenProperties(layoutAnimationStyle, style, displayName) {
|
||||
const commonProperties = getCommonProperties(layoutAnimationStyle, style);
|
||||
if (commonProperties.length > 0) {
|
||||
logger.warn(`${commonProperties.length === 1 ? 'Property' : 'Properties'} "${commonProperties.join(', ')}" of ${displayName} may be overwritten by a layout animation. Please wrap your component with an animated view and apply the layout animation on the wrapper.`);
|
||||
}
|
||||
}
|
||||
export function maybeBuild(layoutAnimationOrBuilder, style, displayName) {
|
||||
const isAnimationBuilder = value => 'build' in layoutAnimationOrBuilder && typeof layoutAnimationOrBuilder.build === 'function';
|
||||
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
||||
const animationFactory = layoutAnimationOrBuilder.build();
|
||||
const layoutAnimation = animationFactory(mockTargetValues);
|
||||
const animatedStyle = layoutAnimation.animations;
|
||||
const getCommonProperties = (obj1, obj2) => Object.keys(obj1).filter(key => Object.prototype.hasOwnProperty.call(obj2, key));
|
||||
const commonProperties = getCommonProperties(animatedStyle, style || {});
|
||||
if (commonProperties.length > 0) {
|
||||
console.warn(`[Reanimated] ${commonProperties.length === 1 ? 'Property' : 'Properties: '} "${commonProperties}" of ${displayName} may be overwritten with layout animation. Please create a wrapper with the layout animation you want to apply.`);
|
||||
if (__DEV__ && style) {
|
||||
const layoutAnimation = animationFactory(mockTargetValues);
|
||||
maybeReportOverwrittenProperties(layoutAnimation.animations, style, displayName);
|
||||
}
|
||||
return layoutAnimationOrBuilder.build();
|
||||
return animationFactory;
|
||||
} else {
|
||||
return layoutAnimationOrBuilder;
|
||||
}
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":["mockTargetValues","targetOriginX","targetOriginY","targetWidth","targetHeight","targetGlobalOriginX","targetGlobalOriginY","targetBorderRadius","windowWidth","windowHeight","currentOriginX","currentOriginY","currentWidth","currentHeight","currentGlobalOriginX","currentGlobalOriginY","currentBorderRadius","maybeBuild","layoutAnimationOrBuilder","style","displayName","isAnimationBuilder","value","build","animationFactory","layoutAnimation","animatedStyle","animations","getCommonProperties","obj1","obj2","Object","keys","filter","key","prototype","hasOwnProperty","call","commonProperties","length","console","warn"],"sources":["animationBuilder.tsx"],"sourcesContent":["'use strict';\nimport type {\n ILayoutAnimationBuilder,\n LayoutAnimationFunction,\n LayoutAnimationsValues,\n} from './reanimated2/layoutReanimation';\nimport type { StyleProps } from './reanimated2/commonTypes';\n\nconst mockTargetValues: LayoutAnimationsValues = {\n targetOriginX: 0,\n targetOriginY: 0,\n targetWidth: 0,\n targetHeight: 0,\n targetGlobalOriginX: 0,\n targetGlobalOriginY: 0,\n targetBorderRadius: 0,\n windowWidth: 0,\n windowHeight: 0,\n currentOriginX: 0,\n currentOriginY: 0,\n currentWidth: 0,\n currentHeight: 0,\n currentGlobalOriginX: 0,\n currentGlobalOriginY: 0,\n currentBorderRadius: 0,\n};\n\nexport function maybeBuild(\n layoutAnimationOrBuilder:\n | ILayoutAnimationBuilder\n | LayoutAnimationFunction\n | Keyframe,\n style: StyleProps | undefined,\n displayName: string\n): LayoutAnimationFunction | Keyframe {\n const isAnimationBuilder = (\n value: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe\n ): value is ILayoutAnimationBuilder =>\n 'build' in layoutAnimationOrBuilder &&\n typeof layoutAnimationOrBuilder.build === 'function';\n\n if (isAnimationBuilder(layoutAnimationOrBuilder)) {\n const animationFactory = layoutAnimationOrBuilder.build();\n const layoutAnimation = animationFactory(mockTargetValues);\n const animatedStyle = layoutAnimation.animations;\n\n const getCommonProperties = (obj1: object, obj2: object) =>\n Object.keys(obj1).filter((key) =>\n Object.prototype.hasOwnProperty.call(obj2, key)\n );\n\n const commonProperties = getCommonProperties(animatedStyle, style || {});\n if (commonProperties.length > 0) {\n console.warn(\n `[Reanimated] ${\n commonProperties.length === 1 ? 'Property' : 'Properties: '\n } \"${commonProperties}\" of ${displayName} may be overwritten with layout animation. Please create a wrapper with the layout animation you want to apply.`\n );\n }\n\n return layoutAnimationOrBuilder.build();\n } else {\n return layoutAnimationOrBuilder;\n }\n}\n"],"mappings":"AAAA,YAAY;;AAQZ,MAAMA,gBAAwC,GAAG;EAC/CC,aAAa,EAAE,CAAC;EAChBC,aAAa,EAAE,CAAC;EAChBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,mBAAmB,EAAE,CAAC;EACtBC,mBAAmB,EAAE,CAAC;EACtBC,kBAAkB,EAAE,CAAC;EACrBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,cAAc,EAAE,CAAC;EACjBC,cAAc,EAAE,CAAC;EACjBC,YAAY,EAAE,CAAC;EACfC,aAAa,EAAE,CAAC;EAChBC,oBAAoB,EAAE,CAAC;EACvBC,oBAAoB,EAAE,CAAC;EACvBC,mBAAmB,EAAE;AACvB,CAAC;AAED,OAAO,SAASC,UAAUA,CACxBC,wBAGY,EACZC,KAA6B,EAC7BC,WAAmB,EACiB;EACpC,MAAMC,kBAAkB,GACtBC,KAAmE,IAEnE,OAAO,IAAIJ,wBAAwB,IACnC,OAAOA,wBAAwB,CAACK,KAAK,KAAK,UAAU;EAEtD,IAAIF,kBAAkB,CAACH,wBAAwB,CAAC,EAAE;IAChD,MAAMM,gBAAgB,GAAGN,wBAAwB,CAACK,KAAK,EAAE;IACzD,MAAME,eAAe,GAAGD,gBAAgB,CAACxB,gBAAgB,CAAC;IAC1D,MAAM0B,aAAa,GAAGD,eAAe,CAACE,UAAU;IAEhD,MAAMC,mBAAmB,GAAGA,CAACC,IAAY,EAAEC,IAAY,KACrDC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,MAAM,CAAEC,GAAG,IAC3BH,MAAM,CAACI,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,IAAI,EAAEI,GAAG,CAAC,CAChD;IAEH,MAAMI,gBAAgB,GAAGV,mBAAmB,CAACF,aAAa,EAAEP,KAAK,IAAI,CAAC,CAAC,CAAC;IACxE,IAAImB,gBAAgB,CAACC,MAAM,GAAG,CAAC,EAAE;MAC/BC,OAAO,CAACC,IAAI,CACT,gBACCH,gBAAgB,CAACC,MAAM,KAAK,CAAC,GAAG,UAAU,GAAG,cAC9C,KAAID,gBAAiB,QAAOlB,WAAY,iHAAgH,CAC1J;IACH;IAEA,OAAOF,wBAAwB,CAACK,KAAK,EAAE;EACzC,CAAC,MAAM;IACL,OAAOL,wBAAwB;EACjC;AACF"}
|
||||
{"version":3,"names":["logger","mockTargetValues","targetOriginX","targetOriginY","targetWidth","targetHeight","targetGlobalOriginX","targetGlobalOriginY","targetBorderRadius","windowWidth","windowHeight","currentOriginX","currentOriginY","currentWidth","currentHeight","currentGlobalOriginX","currentGlobalOriginY","currentBorderRadius","getCommonProperties","layoutStyle","componentStyle","componentStyleFlat","Array","isArray","flat","filter","Boolean","map","style","initial","value","componentStylesKeys","flatMap","Object","keys","commonKeys","key","includes","maybeReportOverwrittenProperties","layoutAnimationStyle","displayName","commonProperties","length","warn","join","maybeBuild","layoutAnimationOrBuilder","isAnimationBuilder","build","animationFactory","__DEV__","layoutAnimation","animations"],"sourceRoot":"../../src","sources":["animationBuilder.tsx"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,UAAU;AASjC,MAAMC,gBAAuC,GAAG;EAC9CC,aAAa,EAAE,CAAC;EAChBC,aAAa,EAAE,CAAC;EAChBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,mBAAmB,EAAE,CAAC;EACtBC,mBAAmB,EAAE,CAAC;EACtBC,kBAAkB,EAAE,CAAC;EACrBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,cAAc,EAAE,CAAC;EACjBC,cAAc,EAAE,CAAC;EACjBC,YAAY,EAAE,CAAC;EACfC,aAAa,EAAE,CAAC;EAChBC,oBAAoB,EAAE,CAAC;EACvBC,oBAAoB,EAAE,CAAC;EACvBC,mBAAmB,EAAE;AACvB,CAAC;AAED,SAASC,mBAAmBA,CAC1BC,WAAuB,EACvBC,cAAuC,EACvC;EACA,IAAIC,kBAAkB,GAAGC,KAAK,CAACC,OAAO,CAACH,cAAc,CAAC,GAClDA,cAAc,CAACI,IAAI,CAAC,CAAC,GACrB,CAACJ,cAAc,CAAC;EAEpBC,kBAAkB,GAAGA,kBAAkB,CAACI,MAAM,CAACC,OAAO,CAAC;EAEvDL,kBAAkB,GAAGA,kBAAkB,CAACM,GAAG,CAAEC,KAAK,IAChD,SAAS,IAAIA,KAAK,GACdA,KAAK,CAACC,OAAO,CAACC,KAAK,CAAC;EAAA,EACpBF,KACN,CAAC;EAED,MAAMG,mBAAmB,GAAGV,kBAAkB,CAACW,OAAO,CAAEJ,KAAK,IAC3DK,MAAM,CAACC,IAAI,CAACN,KAAK,CACnB,CAAC;EAED,MAAMO,UAAU,GAAGF,MAAM,CAACC,IAAI,CAACf,WAAW,CAAC,CAACM,MAAM,CAAEW,GAAG,IACrDL,mBAAmB,CAACM,QAAQ,CAACD,GAAG,CAClC,CAAC;EAED,OAAOD,UAAU;AACnB;AAEA,SAASG,gCAAgCA,CACvCC,oBAAgC,EAChCX,KAA8B,EAC9BY,WAAmB,EACnB;EACA,MAAMC,gBAAgB,GAAGvB,mBAAmB,CAACqB,oBAAoB,EAAEX,KAAK,CAAC;EAEzE,IAAIa,gBAAgB,CAACC,MAAM,GAAG,CAAC,EAAE;IAC/B1C,MAAM,CAAC2C,IAAI,CACT,GACEF,gBAAgB,CAACC,MAAM,KAAK,CAAC,GAAG,UAAU,GAAG,YAAY,KACtDD,gBAAgB,CAACG,IAAI,CACxB,IACF,CAAC,QAAQJ,WAAW,4IACtB,CAAC;EACH;AACF;AAEA,OAAO,SAASK,UAAUA,CACxBC,wBAGY,EACZlB,KAA0C,EAC1CY,WAAmB,EACiB;EACpC,MAAMO,kBAAkB,GACtBjB,KAAmE,IAEnE,OAAO,IAAIgB,wBAAwB,IACnC,OAAOA,wBAAwB,CAACE,KAAK,KAAK,UAAU;EAEtD,IAAID,kBAAkB,CAACD,wBAAwB,CAAC,EAAE;IAChD,MAAMG,gBAAgB,GAAGH,wBAAwB,CAACE,KAAK,CAAC,CAAC;IAEzD,IAAIE,OAAO,IAAItB,KAAK,EAAE;MACpB,MAAMuB,eAAe,GAAGF,gBAAgB,CAAChD,gBAAgB,CAAC;MAC1DqC,gCAAgC,CAC9Ba,eAAe,CAACC,UAAU,EAC1BxB,KAAK,EACLY,WACF,CAAC;IACH;IAEA,OAAOS,gBAAgB;EACzB,CAAC,MAAM;IACL,OAAOH,wBAAwB;EACjC;AACF","ignoreList":[]}
|
||||
|
||||
Generated
Vendored
+30
-50
@@ -1,16 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
import { isSharedValue } from '../isSharedValue';
|
||||
import { startMapper, stopMapper } from '../mappers';
|
||||
import { updateProps } from '../updateProps';
|
||||
import { makeViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
import { flattenArray } from './utils';
|
||||
import { makeViewDescriptorsSet } from '../reanimated2/ViewDescriptorsSet';
|
||||
import { adaptViewConfig } from '../ConfigHelper';
|
||||
import updateProps from '../reanimated2/UpdateProps';
|
||||
import { stopMapper, startMapper } from '../reanimated2/mappers';
|
||||
import { isSharedValue } from '../reanimated2/isSharedValue';
|
||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
||||
function isInlineStyleTransform(transform) {
|
||||
if (!Array.isArray(transform)) {
|
||||
return false;
|
||||
@@ -22,28 +16,29 @@ function inlinePropsHasChanged(styles1, styles2) {
|
||||
return true;
|
||||
}
|
||||
for (const key of Object.keys(styles1)) {
|
||||
if (styles1[key] !== styles2[key]) return true;
|
||||
if (styles1[key] !== styles2[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getInlinePropsUpdate(inlineProps) {
|
||||
function getInlinePropsUpdate(styleValue) {
|
||||
'worklet';
|
||||
|
||||
const update = {};
|
||||
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
||||
if (isSharedValue(styleValue)) {
|
||||
update[key] = styleValue.value;
|
||||
} else if (Array.isArray(styleValue)) {
|
||||
update[key] = styleValue.map(item => {
|
||||
return getInlinePropsUpdate(item);
|
||||
});
|
||||
} else if (typeof styleValue === 'object') {
|
||||
update[key] = getInlinePropsUpdate(styleValue);
|
||||
} else {
|
||||
update[key] = styleValue;
|
||||
}
|
||||
if (isSharedValue(styleValue)) {
|
||||
return styleValue.value;
|
||||
}
|
||||
return update;
|
||||
if (Array.isArray(styleValue)) {
|
||||
return styleValue.map(getInlinePropsUpdate);
|
||||
}
|
||||
if (styleValue && typeof styleValue === 'object') {
|
||||
const update = {};
|
||||
for (const [key, value] of Object.entries(styleValue)) {
|
||||
update[key] = getInlinePropsUpdate(value);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return styleValue;
|
||||
}
|
||||
function extractSharedValuesMapFromProps(props) {
|
||||
const inlineProps = {};
|
||||
@@ -55,11 +50,11 @@ function extractSharedValuesMapFromProps(props) {
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
for (const [key, styleValue] of Object.entries(style)) {
|
||||
for (const [styleKey, styleValue] of Object.entries(style)) {
|
||||
if (isSharedValue(styleValue)) {
|
||||
inlineProps[key] = styleValue;
|
||||
} else if (key === 'transform' && isInlineStyleTransform(styleValue)) {
|
||||
inlineProps[key] = styleValue;
|
||||
inlineProps[styleKey] = styleValue;
|
||||
} else if (styleKey === 'transform' && isInlineStyleTransform(styleValue)) {
|
||||
inlineProps[styleKey] = styleValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -91,11 +86,9 @@ export function getInlineStyle(style, isFirstRender) {
|
||||
return newStyle;
|
||||
}
|
||||
export class InlinePropManager {
|
||||
constructor() {
|
||||
_defineProperty(this, "_inlinePropsViewDescriptors", null);
|
||||
_defineProperty(this, "_inlinePropsMapperId", null);
|
||||
_defineProperty(this, "_inlineProps", {});
|
||||
}
|
||||
_inlinePropsViewDescriptors = null;
|
||||
_inlinePropsMapperId = null;
|
||||
_inlineProps = {};
|
||||
attachInlineProps(animatedComponent, viewInfo) {
|
||||
const newInlineProps = extractSharedValuesMapFromProps(animatedComponent.props);
|
||||
const hasChanged = inlinePropsHasChanged(newInlineProps, this._inlineProps);
|
||||
@@ -104,32 +97,19 @@ export class InlinePropManager {
|
||||
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
||||
const {
|
||||
viewTag,
|
||||
viewName,
|
||||
shadowNodeWrapper,
|
||||
viewConfig
|
||||
shadowNodeWrapper
|
||||
} = viewInfo;
|
||||
if (Object.keys(newInlineProps).length && viewConfig) {
|
||||
adaptViewConfig(viewConfig);
|
||||
}
|
||||
this._inlinePropsViewDescriptors.add({
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
tag: viewTag,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
name: viewName,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
shadowNodeWrapper: shadowNodeWrapper
|
||||
});
|
||||
}
|
||||
const shareableViewDescriptors = this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
||||
const maybeViewRef = SHOULD_BE_USE_WEB ? {
|
||||
items: new Set([animatedComponent])
|
||||
} // see makeViewsRefSet
|
||||
: undefined;
|
||||
const updaterFunction = () => {
|
||||
'worklet';
|
||||
|
||||
const update = getInlinePropsUpdate(newInlineProps);
|
||||
updateProps(shareableViewDescriptors, update, maybeViewRef);
|
||||
updateProps(shareableViewDescriptors, update);
|
||||
};
|
||||
this._inlineProps = newInlineProps;
|
||||
if (this._inlinePropsMapperId) {
|
||||
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+32
-68
@@ -1,86 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
import { NativeEventEmitter, NativeModules, findNodeHandle } from 'react-native';
|
||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
||||
import { runOnJS, runOnUIImmediately } from '../reanimated2/threads';
|
||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
||||
class JSPropsUpdaterPaper {
|
||||
constructor() {
|
||||
_defineProperty(this, "_reanimatedEventEmitter", void 0);
|
||||
this._reanimatedEventEmitter = new NativeEventEmitter(NativeModules.ReanimatedModule);
|
||||
import { runOnUI } from 'react-native-worklets';
|
||||
import { SHOULD_BE_USE_WEB } from '../common';
|
||||
class JSPropsUpdaterNative {
|
||||
static _tagToComponentMapping = new Map();
|
||||
registerComponent(animatedComponent, jsProps) {
|
||||
const viewTag = animatedComponent.getComponentViewTag();
|
||||
JSPropsUpdaterNative._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
runOnUI(() => {
|
||||
global._tagToJSPropNamesMapping[viewTag] = Object.fromEntries(jsProps.map(propName => [propName, true]));
|
||||
})();
|
||||
}
|
||||
addOnJSPropsChangeListener(animatedComponent) {
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterPaper._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 1) {
|
||||
const listener = data => {
|
||||
const component = JSPropsUpdaterPaper._tagToComponentMapping.get(data.viewTag);
|
||||
component === null || component === void 0 ? void 0 : component._updateFromNative(data.props);
|
||||
};
|
||||
this._reanimatedEventEmitter.addListener('onReanimatedPropsChange', listener);
|
||||
}
|
||||
unregisterComponent(animatedComponent) {
|
||||
const viewTag = animatedComponent.getComponentViewTag();
|
||||
JSPropsUpdaterNative._tagToComponentMapping.delete(viewTag);
|
||||
runOnUI(() => {
|
||||
delete global._tagToJSPropNamesMapping[viewTag];
|
||||
})();
|
||||
}
|
||||
removeOnJSPropsChangeListener(animatedComponent) {
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterPaper._tagToComponentMapping.delete(viewTag);
|
||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 0) {
|
||||
this._reanimatedEventEmitter.removeAllListeners('onReanimatedPropsChange');
|
||||
}
|
||||
updateProps(operations) {
|
||||
operations.forEach(({
|
||||
tag,
|
||||
updates
|
||||
}) => {
|
||||
const component = JSPropsUpdaterNative._tagToComponentMapping.get(tag);
|
||||
component?.setNativeProps(updates);
|
||||
});
|
||||
}
|
||||
}
|
||||
_defineProperty(JSPropsUpdaterPaper, "_tagToComponentMapping", new Map());
|
||||
class JSPropsUpdaterFabric {
|
||||
constructor() {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
const updater = (viewTag, props) => {
|
||||
const component = JSPropsUpdaterFabric._tagToComponentMapping.get(viewTag);
|
||||
component === null || component === void 0 ? void 0 : component._updateFromNative(props);
|
||||
};
|
||||
runOnUIImmediately(() => {
|
||||
'worklet';
|
||||
|
||||
global.updateJSProps = (viewTag, props) => {
|
||||
runOnJS(updater)(viewTag, props);
|
||||
};
|
||||
})();
|
||||
JSPropsUpdaterFabric.isInitialized = true;
|
||||
}
|
||||
}
|
||||
addOnJSPropsChangeListener(animatedComponent) {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
return;
|
||||
}
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterFabric._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
}
|
||||
removeOnJSPropsChangeListener(animatedComponent) {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
return;
|
||||
}
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterFabric._tagToComponentMapping.delete(viewTag);
|
||||
}
|
||||
}
|
||||
_defineProperty(JSPropsUpdaterFabric, "_tagToComponentMapping", new Map());
|
||||
_defineProperty(JSPropsUpdaterFabric, "isInitialized", false);
|
||||
class JSPropsUpdaterWeb {
|
||||
addOnJSPropsChangeListener(_animatedComponent) {
|
||||
registerComponent(_animatedComponent) {
|
||||
// noop
|
||||
}
|
||||
removeOnJSPropsChangeListener(_animatedComponent) {
|
||||
unregisterComponent(_animatedComponent) {
|
||||
// noop
|
||||
}
|
||||
updateProps(_operations) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
let JSPropsUpdater;
|
||||
if (SHOULD_BE_USE_WEB) {
|
||||
JSPropsUpdater = JSPropsUpdaterWeb;
|
||||
} else if (global._IS_FABRIC) {
|
||||
JSPropsUpdater = JSPropsUpdaterFabric;
|
||||
} else {
|
||||
JSPropsUpdater = JSPropsUpdaterPaper;
|
||||
JSPropsUpdater = JSPropsUpdaterNative;
|
||||
}
|
||||
export default JSPropsUpdater;
|
||||
const jsPropsUpdater = new JSPropsUpdater();
|
||||
export default jsPropsUpdater;
|
||||
//# sourceMappingURL=JSPropsUpdater.js.map
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+29
-35
@@ -1,23 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
import { isSharedValue } from '../reanimated2';
|
||||
import { isChromeDebugger } from '../reanimated2/PlatformChecker';
|
||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
||||
import { initialUpdaterRun } from '../reanimated2/animation';
|
||||
import { hasInlineStyles, getInlineStyle } from './InlinePropManager';
|
||||
import { initialUpdaterRun } from '../animation';
|
||||
import { isSharedValue } from '../isSharedValue';
|
||||
import { WorkletEventHandler } from '../WorkletEventHandler';
|
||||
import { getInlineStyle, hasInlineStyles } from './InlinePropManager';
|
||||
import { flattenArray, has } from './utils';
|
||||
import { StyleSheet } from 'react-native';
|
||||
function dummyListener() {
|
||||
// empty listener we use to assign to listener properties for which animated
|
||||
// event is used.
|
||||
}
|
||||
export class PropsFilter {
|
||||
constructor() {
|
||||
_defineProperty(this, "_initialStyle", {});
|
||||
}
|
||||
_initialPropsMap = new Map();
|
||||
filterNonAnimatedProps(component) {
|
||||
const inputProps = component.props;
|
||||
const props = {};
|
||||
@@ -27,37 +20,38 @@ export class PropsFilter {
|
||||
const styleProp = inputProps.style;
|
||||
const styles = flattenArray(styleProp ?? []);
|
||||
const processedStyle = styles.map(style => {
|
||||
if (style && style.viewDescriptors) {
|
||||
// this is how we recognize styles returned by useAnimatedStyle
|
||||
style.viewsRef.add(component);
|
||||
if (style?.viewDescriptors) {
|
||||
const handle = style;
|
||||
if (component._isFirstRender) {
|
||||
this._initialStyle = {
|
||||
...style.initial.value,
|
||||
...this._initialStyle,
|
||||
...initialUpdaterRun(style.initial.updater)
|
||||
};
|
||||
this._initialPropsMap.set(handle, {
|
||||
...handle.initial.value,
|
||||
...initialUpdaterRun(handle.initial.updater)
|
||||
});
|
||||
}
|
||||
return this._initialStyle;
|
||||
return this._initialPropsMap.get(handle) ?? {};
|
||||
} else if (hasInlineStyles(style)) {
|
||||
return getInlineStyle(style, component._isFirstRender);
|
||||
} else {
|
||||
return style;
|
||||
}
|
||||
});
|
||||
props[key] = StyleSheet.flatten(processedStyle);
|
||||
// keep styles as they were passed by the user
|
||||
// it will help other libs to interpret styles correctly
|
||||
props[key] = processedStyle;
|
||||
} else if (key === 'animatedProps') {
|
||||
const animatedProp = inputProps.animatedProps;
|
||||
if (animatedProp.initial !== undefined) {
|
||||
Object.keys(animatedProp.initial.value).forEach(key => {
|
||||
var _animatedProp$initial, _animatedProp$viewsRe;
|
||||
props[key] = (_animatedProp$initial = animatedProp.initial) === null || _animatedProp$initial === void 0 ? void 0 : _animatedProp$initial.value[key];
|
||||
(_animatedProp$viewsRe = animatedProp.viewsRef) === null || _animatedProp$viewsRe === void 0 ? void 0 : _animatedProp$viewsRe.add(component);
|
||||
});
|
||||
}
|
||||
} else if (has('current', value) && value.current instanceof WorkletEventHandler) {
|
||||
if (value.current.eventNames.length > 0) {
|
||||
value.current.eventNames.forEach(eventName => {
|
||||
props[eventName] = has('listeners', value.current) ? value.current.listeners[eventName] : dummyListener;
|
||||
const animatedPropsProp = inputProps.animatedProps;
|
||||
const animatedPropsArray = flattenArray(animatedPropsProp ?? []);
|
||||
animatedPropsArray.forEach(animatedProps => {
|
||||
if (animatedProps?.viewDescriptors && animatedProps.initial) {
|
||||
Object.keys(animatedProps.initial.value).forEach(initialValueKey => {
|
||||
props[initialValueKey] = animatedProps.initial?.value[initialValueKey];
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (has('workletEventHandler', value) && value.workletEventHandler instanceof WorkletEventHandler) {
|
||||
if (value.workletEventHandler.eventNames.length > 0) {
|
||||
value.workletEventHandler.eventNames.forEach(eventName => {
|
||||
props[eventName] = has('listeners', value.workletEventHandler) ? value.workletEventHandler.listeners[eventName] : dummyListener;
|
||||
});
|
||||
} else {
|
||||
props[key] = dummyListener;
|
||||
@@ -66,7 +60,7 @@ export class PropsFilter {
|
||||
if (component._isFirstRender) {
|
||||
props[key] = value.value;
|
||||
}
|
||||
} else if (key !== 'onGestureHandlerStateChange' || !isChromeDebugger()) {
|
||||
} else {
|
||||
props[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["'use strict';\nimport type { Ref, Component } from 'react';\nimport type {\n StyleProps,\n BaseAnimationBuilder,\n ILayoutAnimationBuilder,\n EntryExitAnimationFunction,\n SharedTransition,\n SharedValue,\n} from '../reanimated2';\nimport type {\n ViewDescriptorsSet,\n ViewRefSet,\n} from '../reanimated2/ViewDescriptorsSet';\nimport type { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';\nimport type { ShadowNodeWrapper } from '../reanimated2/commonTypes';\nimport type { ViewConfig } from '../ConfigHelper';\n\nexport interface AnimatedProps extends Record<string, unknown> {\n viewDescriptors?: ViewDescriptorsSet;\n viewsRef?: ViewRefSet<unknown>;\n initial?: SharedValue<StyleProps>;\n}\n\nexport interface ViewInfo {\n viewTag: number | HTMLElement | null;\n viewName: string | null;\n shadowNodeWrapper: ShadowNodeWrapper | null;\n viewConfig: ViewConfig;\n}\n\nexport interface IInlinePropManager {\n attachInlineProps(\n animatedComponent: React.Component<unknown, unknown>,\n viewInfo: ViewInfo\n ): void;\n detachInlineProps(): void;\n}\n\nexport interface IPropsFilter {\n filterNonAnimatedProps: (\n component: React.Component<unknown, unknown> & IAnimatedComponentInternal\n ) => Record<string, unknown>;\n}\n\nexport interface IJSPropsUpdater {\n addOnJSPropsChangeListener(\n animatedComponent: React.Component<unknown, unknown> &\n IAnimatedComponentInternal\n ): void;\n removeOnJSPropsChangeListener(\n animatedComponent: React.Component<unknown, unknown> &\n IAnimatedComponentInternal\n ): void;\n}\n\nexport type LayoutAnimationStaticContext = {\n presetName: string;\n};\n\nexport type AnimatedComponentProps<P extends Record<string, unknown>> = P & {\n forwardedRef?: Ref<Component>;\n style?: NestedArray<StyleProps>;\n animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;\n animatedStyle?: StyleProps;\n layout?: (\n | BaseAnimationBuilder\n | ILayoutAnimationBuilder\n | typeof BaseAnimationBuilder\n ) &\n LayoutAnimationStaticContext;\n entering?: (\n | BaseAnimationBuilder\n | typeof BaseAnimationBuilder\n | EntryExitAnimationFunction\n | Keyframe\n ) &\n LayoutAnimationStaticContext;\n exiting?: (\n | BaseAnimationBuilder\n | typeof BaseAnimationBuilder\n | EntryExitAnimationFunction\n | Keyframe\n ) &\n LayoutAnimationStaticContext;\n sharedTransitionTag?: string;\n sharedTransitionStyle?: SharedTransition;\n};\n\nexport interface AnimatedComponentRef extends Component {\n setNativeProps?: (props: Record<string, unknown>) => void;\n getScrollableNode?: () => AnimatedComponentRef;\n getAnimatableRef?: () => AnimatedComponentRef;\n}\n\nexport interface IAnimatedComponentInternal {\n _styles: StyleProps[] | null;\n _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;\n _viewTag: number;\n _isFirstRender: boolean;\n animatedStyle: { value: StyleProps };\n _component: AnimatedComponentRef | HTMLElement | null;\n _sharedElementTransition: SharedTransition | null;\n _jsPropsUpdater: IJSPropsUpdater;\n _InlinePropManager: IInlinePropManager;\n _PropsFilter: IPropsFilter;\n _viewInfo?: ViewInfo;\n context: React.ContextType<typeof SkipEnteringContext>;\n}\n\nexport type NestedArray<T> = T | NestedArray<T>[];\n\nexport interface InitialComponentProps extends Record<string, unknown> {\n ref?: Ref<Component>;\n collapsable?: boolean;\n}\n"],"mappings":"AAAA,YAAY;;AAAC"}
|
||||
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["createAnimatedComponent/commonTypes.ts"],"mappings":"AAAA,YAAY;;AAAC","ignoreList":[]}
|
||||
|
||||
Generated
Vendored
+32
-391
@@ -1,41 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
import React from 'react';
|
||||
import { findNodeHandle, Platform } from 'react-native';
|
||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
||||
import '../reanimated2/layoutReanimation/animationsManager';
|
||||
import invariant from 'invariant';
|
||||
import { adaptViewConfig } from '../ConfigHelper';
|
||||
import { RNRenderer } from '../reanimated2/platform-specific/RNRenderer';
|
||||
import { configureLayoutAnimations, enableLayoutAnimations } from '../reanimated2/core';
|
||||
import { SharedTransition, LayoutAnimationType } from '../reanimated2/layoutReanimation';
|
||||
import { getShadowNodeWrapperFromRef } from '../reanimated2/fabricUtils';
|
||||
import { removeFromPropsRegistry } from '../reanimated2/PropsRegistry';
|
||||
import { getReduceMotionFromConfig } from '../reanimated2/animation/util';
|
||||
import { maybeBuild } from '../animationBuilder';
|
||||
import { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
||||
import JSPropsUpdater from './JSPropsUpdater';
|
||||
import { has, flattenArray } from './utils';
|
||||
import setAndForwardRef from './setAndForwardRef';
|
||||
import { isFabric, isJest, isWeb, shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
||||
import { InlinePropManager } from './InlinePropManager';
|
||||
import { PropsFilter } from './PropsFilter';
|
||||
import { startWebLayoutAnimation, tryActivateLayoutTransition, configureWebLayoutAnimations, getReducedMotionFromConfig } from '../reanimated2/layoutReanimation/web';
|
||||
const IS_WEB = isWeb();
|
||||
const IS_FABRIC = isFabric();
|
||||
function onlyAnimatedStyles(styles) {
|
||||
return styles.filter(style => style === null || style === void 0 ? void 0 : style.viewDescriptors);
|
||||
}
|
||||
function isSameAnimatedStyle(style1, style2) {
|
||||
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
||||
// Instead, we can compare its viewsRefs.
|
||||
return (style1 === null || style1 === void 0 ? void 0 : style1.viewsRef) === (style2 === null || style2 === void 0 ? void 0 : style2.viewsRef);
|
||||
}
|
||||
const isSameAnimatedProps = isSameAnimatedStyle;
|
||||
import AnimatedComponentImpl from './AnimatedComponent';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
/**
|
||||
* Lets you create an Animated version of any React Native component.
|
||||
@@ -45,366 +13,39 @@ const isSameAnimatedProps = isSameAnimatedStyle;
|
||||
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
||||
*/
|
||||
|
||||
// Don't change the order of overloads, since such a change breaks current behavior
|
||||
|
||||
/**
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
*/ // @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling
|
||||
* `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
*/
|
||||
// @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
export function createAnimatedComponent(Component, options) {
|
||||
invariant(typeof Component !== 'function' || Component.prototype && Component.prototype.isReactComponent, `Looks like you're passing a function component \`${Component.name}\` to \`createAnimatedComponent\` function which supports only class components. Please wrap your function component with \`React.forwardRef()\` or use a class component instead.`);
|
||||
class AnimatedComponent extends React.Component {
|
||||
class AnimatedComponent extends AnimatedComponentImpl {
|
||||
static displayName = `AnimatedComponent(${Component.displayName || Component.name || 'Component'})`;
|
||||
constructor(props) {
|
||||
super(props);
|
||||
_defineProperty(this, "_styles", null);
|
||||
_defineProperty(this, "_animatedProps", void 0);
|
||||
_defineProperty(this, "_viewTag", -1);
|
||||
_defineProperty(this, "_isFirstRender", true);
|
||||
_defineProperty(this, "animatedStyle", {
|
||||
value: {}
|
||||
});
|
||||
_defineProperty(this, "_component", null);
|
||||
_defineProperty(this, "_sharedElementTransition", null);
|
||||
_defineProperty(this, "_jsPropsUpdater", new JSPropsUpdater());
|
||||
_defineProperty(this, "_InlinePropManager", new InlinePropManager());
|
||||
_defineProperty(this, "_PropsFilter", new PropsFilter());
|
||||
_defineProperty(this, "_viewInfo", void 0);
|
||||
_defineProperty(this, "context", void 0);
|
||||
_defineProperty(this, "_setComponentRef", setAndForwardRef({
|
||||
getForwardedRef: () => this.props.forwardedRef,
|
||||
setLocalRef: ref => {
|
||||
// TODO update config
|
||||
|
||||
const tag = IS_WEB ? ref : findNodeHandle(ref);
|
||||
const {
|
||||
layout,
|
||||
entering,
|
||||
exiting,
|
||||
sharedTransitionTag
|
||||
} = this.props;
|
||||
if ((layout || entering || exiting || sharedTransitionTag) && tag != null) {
|
||||
var _this$context;
|
||||
if (!shouldBeUseWeb()) {
|
||||
enableLayoutAnimations(true, false);
|
||||
}
|
||||
if (layout) {
|
||||
configureLayoutAnimations(tag, LayoutAnimationType.LAYOUT, maybeBuild(layout, undefined /* We don't have to warn user if style has common properties with animation for LAYOUT */, AnimatedComponent.displayName));
|
||||
}
|
||||
const skipEntering = (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.current;
|
||||
if (entering && !skipEntering) {
|
||||
var _this$props;
|
||||
configureLayoutAnimations(tag, LayoutAnimationType.ENTERING, maybeBuild(entering, (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.style, AnimatedComponent.displayName));
|
||||
}
|
||||
if (exiting) {
|
||||
const reduceMotionInExiting = 'getReduceMotion' in exiting && typeof exiting.getReduceMotion === 'function' ? getReduceMotionFromConfig(exiting.getReduceMotion()) : getReduceMotionFromConfig();
|
||||
if (!reduceMotionInExiting) {
|
||||
var _this$props2;
|
||||
configureLayoutAnimations(tag, LayoutAnimationType.EXITING, maybeBuild(exiting, (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : _this$props2.style, AnimatedComponent.displayName));
|
||||
}
|
||||
}
|
||||
if (sharedTransitionTag && !IS_WEB) {
|
||||
const sharedElementTransition = this.props.sharedTransitionStyle ?? new SharedTransition();
|
||||
const reduceMotionInTransition = getReduceMotionFromConfig(sharedElementTransition.getReduceMotion());
|
||||
if (!reduceMotionInTransition) {
|
||||
sharedElementTransition.registerTransition(tag, sharedTransitionTag);
|
||||
this._sharedElementTransition = sharedElementTransition;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ref !== this._component) {
|
||||
this._component = ref;
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (isJest()) {
|
||||
this.animatedStyle = {
|
||||
value: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
componentDidMount() {
|
||||
this._attachNativeEvents();
|
||||
this._jsPropsUpdater.addOnJSPropsChangeListener(this);
|
||||
this._attachAnimatedStyles();
|
||||
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
|
||||
if (IS_WEB) {
|
||||
configureWebLayoutAnimations();
|
||||
if (!this.props.entering) {
|
||||
this._isFirstRender = false;
|
||||
return;
|
||||
}
|
||||
if (getReducedMotionFromConfig(this.props.entering)) {
|
||||
this._isFirstRender = false;
|
||||
return;
|
||||
}
|
||||
startWebLayoutAnimation(this.props, this._component, LayoutAnimationType.ENTERING);
|
||||
}
|
||||
this._isFirstRender = false;
|
||||
}
|
||||
componentWillUnmount() {
|
||||
var _this$_sharedElementT;
|
||||
this._detachNativeEvents();
|
||||
this._jsPropsUpdater.removeOnJSPropsChangeListener(this);
|
||||
this._detachStyles();
|
||||
this._InlinePropManager.detachInlineProps();
|
||||
(_this$_sharedElementT = this._sharedElementTransition) === null || _this$_sharedElementT === void 0 ? void 0 : _this$_sharedElementT.unregisterTransition(this._viewTag);
|
||||
if (IS_WEB && this.props.exiting && !getReducedMotionFromConfig(this.props.exiting)) {
|
||||
startWebLayoutAnimation(this.props, this._component, LayoutAnimationType.EXITING);
|
||||
}
|
||||
}
|
||||
_getEventViewRef() {
|
||||
var _this$_component, _getScrollableNode, _ref;
|
||||
// Make sure to get the scrollable node for components that implement
|
||||
// `ScrollResponder.Mixin`.
|
||||
return (_this$_component = this._component) !== null && _this$_component !== void 0 && _this$_component.getScrollableNode ? (_getScrollableNode = (_ref = this._component).getScrollableNode) === null || _getScrollableNode === void 0 ? void 0 : _getScrollableNode.call(_ref) : this._component;
|
||||
}
|
||||
_attachNativeEvents() {
|
||||
const node = this._getEventViewRef();
|
||||
let viewTag = null; // We set it only if needed
|
||||
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (has('current', prop) && prop.current instanceof WorkletEventHandler) {
|
||||
if (viewTag === null) {
|
||||
viewTag = findNodeHandle(options !== null && options !== void 0 && options.setNativeProps ? this : node);
|
||||
}
|
||||
prop.current.registerForEvents(viewTag, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
_detachNativeEvents() {
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (has('current', prop) && prop.current instanceof WorkletEventHandler) {
|
||||
prop.current.unregisterFromEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
_detachStyles() {
|
||||
if (IS_WEB && this._styles !== null) {
|
||||
for (const style of this._styles) {
|
||||
if (style !== null && style !== void 0 && style.viewsRef) {
|
||||
style.viewsRef.remove(this);
|
||||
}
|
||||
}
|
||||
} else if (this._viewTag !== -1 && this._styles !== null) {
|
||||
var _this$props$animatedP;
|
||||
for (const style of this._styles) {
|
||||
style.viewDescriptors.remove(this._viewTag);
|
||||
}
|
||||
if ((_this$props$animatedP = this.props.animatedProps) !== null && _this$props$animatedP !== void 0 && _this$props$animatedP.viewDescriptors) {
|
||||
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
|
||||
}
|
||||
if (IS_FABRIC) {
|
||||
removeFromPropsRegistry(this._viewTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
_reattachNativeEvents(prevProps) {
|
||||
for (const key in prevProps) {
|
||||
const prop = this.props[key];
|
||||
if (has('current', prop) && prop.current instanceof WorkletEventHandler && prop.current.reattachNeeded) {
|
||||
prop.current.unregisterFromEvents();
|
||||
}
|
||||
}
|
||||
let viewTag = null;
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (has('current', prop) && prop.current instanceof WorkletEventHandler && prop.current.reattachNeeded) {
|
||||
if (viewTag === null) {
|
||||
const node = this._getEventViewRef();
|
||||
viewTag = findNodeHandle(options !== null && options !== void 0 && options.setNativeProps ? this : node);
|
||||
}
|
||||
prop.current.registerForEvents(viewTag, key);
|
||||
prop.current.reattachNeeded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_updateFromNative(props) {
|
||||
if (options !== null && options !== void 0 && options.setNativeProps) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
options.setNativeProps(this._component, props);
|
||||
} else {
|
||||
var _this$_component2, _this$_component2$set;
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
(_this$_component2 = this._component) === null || _this$_component2 === void 0 ? void 0 : (_this$_component2$set = _this$_component2.setNativeProps) === null || _this$_component2$set === void 0 ? void 0 : _this$_component2$set.call(_this$_component2, props);
|
||||
}
|
||||
}
|
||||
_getViewInfo() {
|
||||
var _this$_component3, _getAnimatableRef, _ref2;
|
||||
if (this._viewInfo !== undefined) {
|
||||
return this._viewInfo;
|
||||
}
|
||||
let viewTag;
|
||||
let viewName;
|
||||
let shadowNodeWrapper = null;
|
||||
let viewConfig;
|
||||
// Component can specify ref which should be animated when animated version of the component is created.
|
||||
// Otherwise, we animate the component itself.
|
||||
const component = (_this$_component3 = this._component) !== null && _this$_component3 !== void 0 && _this$_component3.getAnimatableRef ? (_getAnimatableRef = (_ref2 = this._component).getAnimatableRef) === null || _getAnimatableRef === void 0 ? void 0 : _getAnimatableRef.call(_ref2) : this;
|
||||
if (IS_WEB) {
|
||||
// At this point I assume that `_setComponentRef` was already called and `_component` is set.
|
||||
// `this._component` on web represents HTMLElement of our component, that's why we use casting
|
||||
viewTag = this._component;
|
||||
viewName = null;
|
||||
shadowNodeWrapper = null;
|
||||
viewConfig = null;
|
||||
} else {
|
||||
var _hostInstance$viewCon;
|
||||
// hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
|
||||
const hostInstance = RNRenderer.findHostInstance_DEPRECATED(component);
|
||||
if (!hostInstance) {
|
||||
throw new Error('[Reanimated] Cannot find host instance for this component. Maybe it renders nothing?');
|
||||
}
|
||||
// we can access view tag in the same way it's accessed here https://github.com/facebook/react/blob/e3f4eb7272d4ca0ee49f27577156b57eeb07cf73/packages/react-native-renderer/src/ReactFabric.js#L146
|
||||
viewTag = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance._nativeTag;
|
||||
/**
|
||||
* RN uses viewConfig for components for storing different properties of the component(example: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js#L24).
|
||||
* The name we're looking for is in the field named uiViewClassName.
|
||||
*/
|
||||
viewName = hostInstance === null || hostInstance === void 0 ? void 0 : (_hostInstance$viewCon = hostInstance.viewConfig) === null || _hostInstance$viewCon === void 0 ? void 0 : _hostInstance$viewCon.uiViewClassName;
|
||||
viewConfig = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.viewConfig;
|
||||
if (IS_FABRIC) {
|
||||
shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
|
||||
}
|
||||
}
|
||||
this._viewInfo = {
|
||||
viewTag,
|
||||
viewName,
|
||||
shadowNodeWrapper,
|
||||
viewConfig
|
||||
};
|
||||
return this._viewInfo;
|
||||
}
|
||||
_attachAnimatedStyles() {
|
||||
var _this$props$animatedP2, _this$props$animatedP3;
|
||||
const styles = this.props.style ? onlyAnimatedStyles(flattenArray(this.props.style)) : [];
|
||||
const prevStyles = this._styles;
|
||||
this._styles = styles;
|
||||
const prevAnimatedProps = this._animatedProps;
|
||||
this._animatedProps = this.props.animatedProps;
|
||||
const {
|
||||
viewTag,
|
||||
viewName,
|
||||
shadowNodeWrapper,
|
||||
viewConfig
|
||||
} = this._getViewInfo();
|
||||
|
||||
// update UI props whitelist for this view
|
||||
const hasReanimated2Props = ((_this$props$animatedP2 = this.props.animatedProps) === null || _this$props$animatedP2 === void 0 ? void 0 : _this$props$animatedP2.viewDescriptors) || styles.length;
|
||||
if (hasReanimated2Props && viewConfig) {
|
||||
adaptViewConfig(viewConfig);
|
||||
}
|
||||
this._viewTag = viewTag;
|
||||
|
||||
// remove old styles
|
||||
if (prevStyles) {
|
||||
// in most of the cases, views have only a single animated style and it remains unchanged
|
||||
const hasOneSameStyle = styles.length === 1 && prevStyles.length === 1 && isSameAnimatedStyle(styles[0], prevStyles[0]);
|
||||
if (!hasOneSameStyle) {
|
||||
// otherwise, remove each style that is not present in new styles
|
||||
for (const prevStyle of prevStyles) {
|
||||
const isPresent = styles.some(style => isSameAnimatedStyle(style, prevStyle));
|
||||
if (!isPresent) {
|
||||
prevStyle.viewDescriptors.remove(viewTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
styles.forEach(style => {
|
||||
style.viewDescriptors.add({
|
||||
tag: viewTag,
|
||||
name: viewName,
|
||||
shadowNodeWrapper
|
||||
});
|
||||
if (isJest()) {
|
||||
/**
|
||||
* We need to connect Jest's TestObject instance whose contains just props object
|
||||
* with the updateProps() function where we update the properties of the component.
|
||||
* We can't update props object directly because TestObject contains a copy of props - look at render function:
|
||||
* const props = this._filterNonAnimatedProps(this.props);
|
||||
*/
|
||||
this.animatedStyle.value = {
|
||||
...this.animatedStyle.value,
|
||||
...style.initial.value
|
||||
};
|
||||
style.animatedStyle.current = this.animatedStyle;
|
||||
}
|
||||
});
|
||||
|
||||
// detach old animatedProps
|
||||
if (prevAnimatedProps && !isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)) {
|
||||
prevAnimatedProps.viewDescriptors.remove(viewTag);
|
||||
}
|
||||
|
||||
// attach animatedProps property
|
||||
if ((_this$props$animatedP3 = this.props.animatedProps) !== null && _this$props$animatedP3 !== void 0 && _this$props$animatedP3.viewDescriptors) {
|
||||
this.props.animatedProps.viewDescriptors.add({
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
tag: viewTag,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
name: viewName,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
shadowNodeWrapper: shadowNodeWrapper
|
||||
});
|
||||
}
|
||||
}
|
||||
componentDidUpdate(prevProps, _prevState,
|
||||
// This type comes straight from React
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
snapshot) {
|
||||
this._reattachNativeEvents(prevProps);
|
||||
this._attachAnimatedStyles();
|
||||
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
|
||||
|
||||
// Snapshot won't be undefined because it comes from getSnapshotBeforeUpdate method
|
||||
if (IS_WEB && snapshot !== null && this.props.layout && !getReducedMotionFromConfig(this.props.layout)) {
|
||||
tryActivateLayoutTransition(this.props, this._component, snapshot);
|
||||
}
|
||||
}
|
||||
// This is a component lifecycle method from React, therefore we are not calling it directly.
|
||||
// It is called before the component gets rerendered. This way we can access components' position before it changed
|
||||
// and later on, in componentDidUpdate, calculate translation for layout transition.
|
||||
getSnapshotBeforeUpdate() {
|
||||
if (this._component.getBoundingClientRect !== undefined) {
|
||||
return this._component.getBoundingClientRect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
render() {
|
||||
const props = this._PropsFilter.filterNonAnimatedProps(this);
|
||||
if (isJest()) {
|
||||
props.animatedStyle = this.animatedStyle;
|
||||
}
|
||||
|
||||
// Layout animations on web are set inside `componentDidMount` method, which is called after first render.
|
||||
// Because of that we can encounter a situation in which component is visible for a short amount of time, and later on animation triggers.
|
||||
// I've tested that on various browsers and devices and it did not happen to me. To be sure that it won't happen to someone else,
|
||||
// I've decided to hide component at first render. Its visibility is reset in `componentDidMount`.
|
||||
if (this._isFirstRender && IS_WEB && props.entering && !getReducedMotionFromConfig(props.entering)) {
|
||||
props.style = {
|
||||
...(props.style ?? {}),
|
||||
visibility: 'hidden' // Hide component until `componentDidMount` triggers
|
||||
};
|
||||
}
|
||||
|
||||
const platformProps = Platform.select({
|
||||
web: {},
|
||||
default: {
|
||||
collapsable: false
|
||||
}
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
||||
// Casting is used here, because ref can be null - in that case it cannot be assigned to HTMLElement.
|
||||
// After spending some time trying to figure out what to do with this problem, we decided to leave it this way
|
||||
ref: this._setComponentRef
|
||||
}, platformProps));
|
||||
// User can override component-defined jsProps via options
|
||||
const jsProps = options?.jsProps ?? Component.jsProps;
|
||||
const modifiedOptions = jsProps?.length ? {
|
||||
...options,
|
||||
jsProps
|
||||
} : options;
|
||||
super(Component, props, AnimatedComponent.displayName, modifiedOptions);
|
||||
}
|
||||
}
|
||||
_defineProperty(AnimatedComponent, "displayName", void 0);
|
||||
_defineProperty(AnimatedComponent, "contextType", SkipEnteringContext);
|
||||
AnimatedComponent.displayName = `AnimatedComponent(${Component.displayName || Component.name || 'Component'})`;
|
||||
return /*#__PURE__*/React.forwardRef((props, ref) => {
|
||||
return /*#__PURE__*/React.createElement(AnimatedComponent, _extends({}, props, ref === null ? null : {
|
||||
forwardedRef: ref
|
||||
}));
|
||||
});
|
||||
const animatedComponent = props => {
|
||||
return /*#__PURE__*/_jsx(AnimatedComponent, {
|
||||
...props,
|
||||
// Needed to prevent react from signing AnimatedComponent to the ref
|
||||
// (we want to handle the ref assignment in the AnimatedComponent)
|
||||
ref: null,
|
||||
...(props.ref === null ? null : {
|
||||
forwardedRef: props.ref
|
||||
})
|
||||
});
|
||||
};
|
||||
animatedComponent.displayName = Component.displayName || Component.name || 'Component';
|
||||
return animatedComponent;
|
||||
}
|
||||
//# sourceMappingURL=createAnimatedComponent.js.map
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":["createAnimatedComponent"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport { createAnimatedComponent } from './createAnimatedComponent';\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,uBAAuB,QAAQ,2BAA2B"}
|
||||
{"version":3,"names":["createAnimatedComponent"],"sourceRoot":"../../../src","sources":["createAnimatedComponent/index.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,uBAAuB,QAAQ,2BAA2B","ignoreList":[]}
|
||||
|
||||
Generated
Vendored
+28
@@ -27,4 +27,32 @@ export const has = (key, x) => {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export function filterStyles(styles) {
|
||||
if (!styles) {
|
||||
return {
|
||||
animatedStyles: [],
|
||||
cssStyle: null
|
||||
};
|
||||
}
|
||||
return styles.reduce(({
|
||||
animatedStyles,
|
||||
cssStyle
|
||||
}, style) => {
|
||||
if (style?.viewDescriptors) {
|
||||
animatedStyles.push(style);
|
||||
} else {
|
||||
cssStyle = {
|
||||
...cssStyle,
|
||||
...style
|
||||
};
|
||||
}
|
||||
return {
|
||||
animatedStyles,
|
||||
cssStyle
|
||||
};
|
||||
}, {
|
||||
animatedStyles: [],
|
||||
cssStyle: null
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=utils.js.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"names":["flattenArray","array","Array","isArray","resultArr","_flattenArray","arr","forEach","item","push","has","key","x","undefined"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type { NestedArray } from './commonTypes';\n\nexport function flattenArray<T>(array: NestedArray<T>): T[] {\n if (!Array.isArray(array)) {\n return [array];\n }\n const resultArr: T[] = [];\n\n const _flattenArray = (arr: NestedArray<T>[]): void => {\n arr.forEach((item) => {\n if (Array.isArray(item)) {\n _flattenArray(item);\n } else {\n resultArr.push(item);\n }\n });\n };\n _flattenArray(array);\n return resultArr;\n}\n\nexport const has = <K extends string>(\n key: K,\n x: unknown\n): x is typeof x & { [key in K]: unknown } => {\n if (typeof x === 'function' || typeof x === 'object') {\n if (x === null || x === undefined) {\n return false;\n } else {\n return key in x;\n }\n }\n return false;\n};\n"],"mappings":"AAAA,YAAY;;AAGZ,OAAO,SAASA,YAAYA,CAAIC,KAAqB,EAAO;EAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;IACzB,OAAO,CAACA,KAAK,CAAC;EAChB;EACA,MAAMG,SAAc,GAAG,EAAE;EAEzB,MAAMC,aAAa,GAAIC,GAAqB,IAAW;IACrDA,GAAG,CAACC,OAAO,CAAEC,IAAI,IAAK;MACpB,IAAIN,KAAK,CAACC,OAAO,CAACK,IAAI,CAAC,EAAE;QACvBH,aAAa,CAACG,IAAI,CAAC;MACrB,CAAC,MAAM;QACLJ,SAAS,CAACK,IAAI,CAACD,IAAI,CAAC;MACtB;IACF,CAAC,CAAC;EACJ,CAAC;EACDH,aAAa,CAACJ,KAAK,CAAC;EACpB,OAAOG,SAAS;AAClB;AAEA,OAAO,MAAMM,GAAG,GAAGA,CACjBC,GAAM,EACNC,CAAU,KACkC;EAC5C,IAAI,OAAOA,CAAC,KAAK,UAAU,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;IACpD,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;MACjC,OAAO,KAAK;IACd,CAAC,MAAM;MACL,OAAOF,GAAG,IAAIC,CAAC;IACjB;EACF;EACA,OAAO,KAAK;AACd,CAAC"}
|
||||
{"version":3,"names":["flattenArray","array","Array","isArray","resultArr","_flattenArray","arr","forEach","item","push","has","key","x","undefined","filterStyles","styles","animatedStyles","cssStyle","reduce","style","viewDescriptors"],"sourceRoot":"../../../src","sources":["createAnimatedComponent/utils.ts"],"mappings":"AAAA,YAAY;;AAKZ,OAAO,SAASA,YAAYA,CAAIC,KAAqB,EAAO;EAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;IACzB,OAAO,CAACA,KAAK,CAAC;EAChB;EACA,MAAMG,SAAc,GAAG,EAAE;EAEzB,MAAMC,aAAa,GAAIC,GAAqB,IAAW;IACrDA,GAAG,CAACC,OAAO,CAAEC,IAAI,IAAK;MACpB,IAAIN,KAAK,CAACC,OAAO,CAACK,IAAI,CAAC,EAAE;QACvBH,aAAa,CAACG,IAAI,CAAC;MACrB,CAAC,MAAM;QACLJ,SAAS,CAACK,IAAI,CAACD,IAAI,CAAC;MACtB;IACF,CAAC,CAAC;EACJ,CAAC;EACDH,aAAa,CAACJ,KAAK,CAAC;EACpB,OAAOG,SAAS;AAClB;AAEA,OAAO,MAAMM,GAAG,GAAGA,CACjBC,GAAM,EACNC,CAAU,KACuB;EACjC,IAAI,OAAOA,CAAC,KAAK,UAAU,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;IACpD,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;MACjC,OAAO,KAAK;IACd,CAAC,MAAM;MACL,OAAOF,GAAG,IAAIC,CAAC;IACjB;EACF;EACA,OAAO,KAAK;AACd,CAAC;AAOD,OAAO,SAASE,YAAYA,CAACC,MAAgC,EAAkB;EAC7E,IAAI,CAACA,MAAM,EAAE;IACX,OAAO;MAAEC,cAAc,EAAE,EAAE;MAAEC,QAAQ,EAAE;IAAK,CAAC;EAC/C;EAEA,OAAOF,MAAM,CAACG,MAAM,CAClB,CAAC;IAAEF,cAAc;IAAEC;EAAS,CAAC,EAAEE,KAAK,KAAK;IACvC,IAAIA,KAAK,EAAEC,eAAe,EAAE;MAC1BJ,cAAc,CAACP,IAAI,CAACU,KAAK,CAAC;IAC5B,CAAC,MAAM;MACLF,QAAQ,GAAG;QAAE,GAAGA,QAAQ;QAAE,GAAGE;MAAM,CAAa;IAClD;IACA,OAAO;MAAEH,cAAc;MAAEC;IAAS,CAAC;EACrC,CAAC,EACD;IAAED,cAAc,EAAE,EAAE;IAAEC,QAAQ,EAAE;EAAK,CACvC,CAAC;AACH","ignoreList":[]}
|
||||
|
||||
+59
-1
@@ -1,6 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
import './publicGlobals';
|
||||
import { initializeReanimatedModule } from './initializers';
|
||||
import { ReanimatedModule } from './ReanimatedModule';
|
||||
|
||||
// TODO: Specify the initialization pipeline since now there's no
|
||||
// universal source of truth for it.
|
||||
initializeReanimatedModule(ReanimatedModule);
|
||||
|
||||
// eslint-disable-next-line import/first
|
||||
import * as Animated from './Animated';
|
||||
export * from './reanimated2';
|
||||
export default Animated;
|
||||
export { createAnimatedComponent } from './Animated';
|
||||
export { cancelAnimation, defineAnimation, GentleSpringConfig, GentleSpringConfigWithDuration, Reanimated3DefaultSpringConfig, Reanimated3DefaultSpringConfigWithDuration, SnappySpringConfig, SnappySpringConfigWithDuration, WigglySpringConfig, WigglySpringConfigWithDuration, withClamp, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming } from './animation';
|
||||
export { convertToRGBA, isColor } from './Colors';
|
||||
export { processColor, ReanimatedLogLevel } from './common';
|
||||
export { InterfaceOrientation, IOSReferenceFrame, KeyboardState, ReduceMotion, SensorType } from './commonTypes';
|
||||
export { LayoutAnimationConfig } from './component/LayoutAnimationConfig';
|
||||
export { PerformanceMonitor } from './component/PerformanceMonitor';
|
||||
export { ReducedMotionConfig } from './component/ReducedMotionConfig';
|
||||
export { configureReanimatedLogger } from './ConfigHelper';
|
||||
export { enableLayoutAnimations, getViewProp, isConfigured, isReanimated3, makeMutable } from './core';
|
||||
export * from './css';
|
||||
export { Easing } from './Easing';
|
||||
export { getStaticFeatureFlag, setDynamicFeatureFlag } from './featureFlags';
|
||||
export { useAnimatedKeyboard, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedSensor, useAnimatedStyle, useComposedEventHandler, useDerivedValue, useEvent, useFrameCallback, useHandler, useReducedMotion, useScrollOffset, /** @deprecated Please use {@link useScrollOffset} instead. */
|
||||
useScrollOffset as useScrollViewOffset, useSharedValue } from './hook';
|
||||
export { ColorSpace, /** @deprecated Please use {@link Extrapolation} instead. */
|
||||
Extrapolate, interpolateColor, useInterpolateConfig } from './interpolateColor';
|
||||
export { clamp, Extrapolation, interpolate } from './interpolation';
|
||||
export { isSharedValue } from './isSharedValue';
|
||||
export { advanceAnimationByFrame, advanceAnimationByTime, getAnimatedStyle, setUpTests, withReanimatedTimer } from './jestUtils';
|
||||
export { BaseAnimationBuilder,
|
||||
// Bounce
|
||||
BounceIn, BounceInDown, BounceInLeft, BounceInRight, BounceInUp, BounceOut, BounceOutDown, BounceOutLeft, BounceOutRight, BounceOutUp, ComplexAnimationBuilder, CurvedTransition, EntryExitTransition,
|
||||
// Fade
|
||||
FadeIn, FadeInDown, FadeInLeft, FadeInRight, FadeInUp, FadeOut, FadeOutDown, FadeOutLeft, FadeOutRight, FadeOutUp, FadingTransition, FlipInEasyX, FlipInEasyY, FlipInXDown,
|
||||
// Flip
|
||||
FlipInXUp, FlipInYLeft, FlipInYRight, FlipOutEasyX, FlipOutEasyY, FlipOutXDown, FlipOutXUp, FlipOutYLeft, FlipOutYRight, JumpingTransition, Keyframe,
|
||||
// Transitions
|
||||
Layout, LightSpeedInLeft,
|
||||
// Lightspeed
|
||||
LightSpeedInRight, LightSpeedOutLeft, LightSpeedOutRight, LinearTransition,
|
||||
// Pinwheel
|
||||
PinwheelIn, PinwheelOut,
|
||||
// Roll
|
||||
RollInLeft, RollInRight, RollOutLeft, RollOutRight,
|
||||
// Rotate
|
||||
RotateInDownLeft, RotateInDownRight, RotateInUpLeft, RotateInUpRight, RotateOutDownLeft, RotateOutDownRight, RotateOutUpLeft, RotateOutUpRight, SequencedTransition, SlideInDown, SlideInLeft,
|
||||
// Slide
|
||||
SlideInRight, SlideInUp, SlideOutDown, SlideOutLeft, SlideOutRight, SlideOutUp,
|
||||
// Stretch
|
||||
StretchInX, StretchInY, StretchOutX, StretchOutY,
|
||||
// Zoom
|
||||
ZoomIn, ZoomInDown, ZoomInEasyDown, ZoomInEasyUp, ZoomInLeft, ZoomInRight, ZoomInRotate, ZoomInUp, ZoomOut, ZoomOutDown, ZoomOutEasyDown, ZoomOutEasyUp, ZoomOutLeft, ZoomOutRight, ZoomOutRotate, ZoomOutUp } from './layoutReanimation';
|
||||
export { startMapper, stopMapper } from './mappers';
|
||||
export { jsVersion as reanimatedVersion } from './platform-specific/jsVersion';
|
||||
export { dispatchCommand, getRelativeCoords, measure, scrollTo, setGestureState, setNativeProps } from './platformFunctions';
|
||||
export { getUseOfValueInStyleWarning } from './pluginUtils';
|
||||
export { createAnimatedPropAdapter } from './PropAdapters';
|
||||
export { finishScreenTransition, ScreenTransition, startScreenTransition } from './screenTransition';
|
||||
export { createWorkletRuntime, executeOnUIRuntimeSync, isWorkletFunction, makeShareableCloneRecursive, runOnJS, runOnRuntime, runOnUI } from './workletFunctions';
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+7
-65
@@ -1,66 +1,8 @@
|
||||
import type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';
|
||||
import type { SharedValue as _SharedValue } from './reanimated2/commonTypes';
|
||||
import type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';
|
||||
import type { TransformStyleTypes as _TransformStyleTypes, Adaptable as _Adaptable, AdaptTransforms as _AdaptTransforms, AnimatedTransform as _AnimatedTransform, AnimateStyle as _AnimateStyle, StylesOrDefault as _StylesOrDefault, AnimateProps as _AnimateProps } from './reanimated2/helperTypes';
|
||||
import type { EasingFunction as _EasingFunction } from './reanimated2/Easing';
|
||||
import type { AnimatedScrollViewProps as _AnimatedScrollViewProps } from './reanimated2/component/ScrollView';
|
||||
import type { FlatListPropsWithLayout as _FlatListPropsWithLayout } from './reanimated2/component/FlatList';
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
export { AnimatedText as Text } from './reanimated2/component/Text';
|
||||
export { AnimatedView as View } from './reanimated2/component/View';
|
||||
export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
|
||||
export { AnimatedImage as Image } from './reanimated2/component/Image';
|
||||
export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
|
||||
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||
export { AnimatedImage as Image } from './component/Image';
|
||||
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||
export { AnimatedText as Text } from './component/Text';
|
||||
export { AnimatedView as View } from './component/View';
|
||||
export { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
|
||||
/**
|
||||
* @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type Extrapolate = typeof _Extrapolate;
|
||||
/**
|
||||
* @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type SharedValue<T> = _SharedValue<T>;
|
||||
/**
|
||||
* @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type DerivedValue<T> = _DerivedValue<T>;
|
||||
/**
|
||||
* @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type Adaptable<T> = _Adaptable<T>;
|
||||
/**
|
||||
* @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type TransformStyleTypes = _TransformStyleTypes;
|
||||
/**
|
||||
* @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AdaptTransforms<T> = _AdaptTransforms<T>;
|
||||
/**
|
||||
* @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type AnimatedTransform = _AnimatedTransform;
|
||||
/**
|
||||
* @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimateStyle<S> = _AnimateStyle<S>;
|
||||
/**
|
||||
* @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type StylesOrDefault<S> = _StylesOrDefault<S>;
|
||||
/**
|
||||
* @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimateProps<P extends object> = _AnimateProps<P>;
|
||||
/**
|
||||
* @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type EasingFunction = _EasingFunction;
|
||||
/**
|
||||
* @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimatedScrollViewProps = _AnimatedScrollViewProps;
|
||||
/**
|
||||
* @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type FlatListPropsWithLayout<T> = _FlatListPropsWithLayout<T>;
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
//# sourceMappingURL=Animated.d.ts.map
|
||||
Generated
Vendored
+14
-9
@@ -1,11 +1,16 @@
|
||||
export declare function addWhitelistedNativeProps(props: Record<string, boolean>): void;
|
||||
export declare function addWhitelistedUIProps(props: Record<string, boolean>): void;
|
||||
export interface ViewConfig {
|
||||
uiViewClassName: string;
|
||||
validAttributes: Record<string, unknown>;
|
||||
}
|
||||
import type { LoggerConfig } from './common';
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export declare function addWhitelistedNativeProps(_props: Record<string, boolean>): void;
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export declare function addWhitelistedUIProps(_props: Record<string, boolean>): void;
|
||||
/**
|
||||
* updates UI props whitelist for given view host instance
|
||||
* this will work just once for every view name
|
||||
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||
* affect Reanimated code executed after call to this function so it should be
|
||||
* called before any Reanimated code is executed to take effect. Each call to
|
||||
* this function will override the previous configuration (it's recommended to
|
||||
* call it only once).
|
||||
*
|
||||
* @param config - The new logger configuration to apply.
|
||||
*/
|
||||
export declare function adaptViewConfig(viewConfig: ViewConfig): void;
|
||||
export declare function configureReanimatedLogger(config: LoggerConfig): void;
|
||||
//# sourceMappingURL=ConfigHelper.d.ts.map
|
||||
Generated
Vendored
+4
-3
@@ -1,3 +1,4 @@
|
||||
import type { ILayoutAnimationBuilder, LayoutAnimationFunction } from './reanimated2/layoutReanimation';
|
||||
import type { StyleProps } from './reanimated2/commonTypes';
|
||||
export declare function maybeBuild(layoutAnimationOrBuilder: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe, style: StyleProps | undefined, displayName: string): LayoutAnimationFunction | Keyframe;
|
||||
import type { ILayoutAnimationBuilder, LayoutAnimationFunction, StyleProps } from './commonTypes';
|
||||
import type { NestedArray } from './createAnimatedComponent/commonTypes';
|
||||
export declare function maybeBuild(layoutAnimationOrBuilder: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe, style: NestedArray<StyleProps> | undefined, displayName: string): LayoutAnimationFunction | Keyframe;
|
||||
//# sourceMappingURL=animationBuilder.d.ts.map
|
||||
Generated
Vendored
+6
-6
@@ -1,13 +1,13 @@
|
||||
/// <reference types="react" />
|
||||
import type { StyleProps } from '../reanimated2';
|
||||
import type { IAnimatedComponentInternal, IInlinePropManager, ViewInfo } from './commonTypes';
|
||||
import type { ViewDescriptorsSet } from '../reanimated2/ViewDescriptorsSet';
|
||||
import type { StyleProps } from '../commonTypes';
|
||||
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
import type { AnimatedComponentType, IInlinePropManager, ViewInfo } from './commonTypes';
|
||||
export declare function hasInlineStyles(style: StyleProps): boolean;
|
||||
export declare function getInlineStyle(style: Record<string, unknown>, isFirstRender: boolean): Record<string, unknown>;
|
||||
export declare function getInlineStyle(style: Record<string, unknown>, isFirstRender: boolean): StyleProps | Record<string, unknown>;
|
||||
export declare class InlinePropManager implements IInlinePropManager {
|
||||
_inlinePropsViewDescriptors: ViewDescriptorsSet | null;
|
||||
_inlinePropsMapperId: number | null;
|
||||
_inlineProps: StyleProps;
|
||||
attachInlineProps(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal, viewInfo: ViewInfo): void;
|
||||
attachInlineProps(animatedComponent: AnimatedComponentType, viewInfo: ViewInfo): void;
|
||||
detachInlineProps(): void;
|
||||
}
|
||||
//# sourceMappingURL=InlinePropManager.d.ts.map
|
||||
Generated
Vendored
+11
-19
@@ -1,23 +1,15 @@
|
||||
/// <reference types="react" />
|
||||
import type { AnimatedComponentProps, IAnimatedComponentInternal, IJSPropsUpdater, InitialComponentProps } from './commonTypes';
|
||||
declare class JSPropsUpdaterPaper implements IJSPropsUpdater {
|
||||
import type { AnimatedComponentProps, AnimatedComponentType, IAnimatedComponentInternal, IJSPropsUpdater, InitialComponentProps, JSPropsOperation } from './commonTypes';
|
||||
declare class JSPropsUpdaterNative implements IJSPropsUpdater {
|
||||
private static _tagToComponentMapping;
|
||||
private _reanimatedEventEmitter;
|
||||
constructor();
|
||||
addOnJSPropsChangeListener(animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
removeOnJSPropsChangeListener(animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
}
|
||||
declare class JSPropsUpdaterFabric implements IJSPropsUpdater {
|
||||
private static _tagToComponentMapping;
|
||||
private static isInitialized;
|
||||
constructor();
|
||||
addOnJSPropsChangeListener(animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
removeOnJSPropsChangeListener(animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
registerComponent(animatedComponent: AnimatedComponentType, jsProps: string[]): void;
|
||||
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||
updateProps(operations: JSPropsOperation[]): void;
|
||||
}
|
||||
declare class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||
addOnJSPropsChangeListener(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
removeOnJSPropsChangeListener(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
registerComponent(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
unregisterComponent(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||
updateProps(_operations: JSPropsOperation[]): void;
|
||||
}
|
||||
type JSPropsUpdaterOptions = typeof JSPropsUpdaterWeb | typeof JSPropsUpdaterFabric | typeof JSPropsUpdaterPaper;
|
||||
declare let JSPropsUpdater: JSPropsUpdaterOptions;
|
||||
export default JSPropsUpdater;
|
||||
declare const jsPropsUpdater: JSPropsUpdaterNative | JSPropsUpdaterWeb;
|
||||
export default jsPropsUpdater;
|
||||
//# sourceMappingURL=JSPropsUpdater.d.ts.map
|
||||
Generated
Vendored
+4
-4
@@ -1,6 +1,6 @@
|
||||
/// <reference types="react" />
|
||||
import type { IAnimatedComponentInternal, IPropsFilter } from './commonTypes';
|
||||
import type { AnimatedComponentType, IPropsFilter } from './commonTypes';
|
||||
export declare class PropsFilter implements IPropsFilter {
|
||||
private _initialStyle;
|
||||
filterNonAnimatedProps(component: React.Component<unknown, unknown> & IAnimatedComponentInternal): Record<string, unknown>;
|
||||
private _initialPropsMap;
|
||||
filterNonAnimatedProps(component: AnimatedComponentType): Record<string, unknown>;
|
||||
}
|
||||
//# sourceMappingURL=PropsFilter.d.ts.map
|
||||
Generated
Vendored
+56
-26
@@ -1,68 +1,98 @@
|
||||
import type { Ref, Component } from 'react';
|
||||
import type { StyleProps, BaseAnimationBuilder, ILayoutAnimationBuilder, EntryExitAnimationFunction, SharedTransition, SharedValue } from '../reanimated2';
|
||||
import type { ViewDescriptorsSet, ViewRefSet } from '../reanimated2/ViewDescriptorsSet';
|
||||
import type { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
||||
import type { ShadowNodeWrapper } from '../reanimated2/commonTypes';
|
||||
import type { ViewConfig } from '../ConfigHelper';
|
||||
import type { Component, Ref, RefObject } from 'react';
|
||||
import type { AnimatedStyle, EntryExitAnimationFunction, ILayoutAnimationBuilder, ShadowNodeWrapper, SharedValue, StyleProps, StyleUpdaterContainer } from '../commonTypes';
|
||||
import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
|
||||
import type { BaseAnimationBuilder } from '../layoutReanimation';
|
||||
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
export interface AnimatedProps extends Record<string, unknown> {
|
||||
viewDescriptors?: ViewDescriptorsSet;
|
||||
viewsRef?: ViewRefSet<unknown>;
|
||||
initial?: SharedValue<StyleProps>;
|
||||
styleUpdaterContainer?: StyleUpdaterContainer;
|
||||
}
|
||||
export interface ViewInfo {
|
||||
viewTag: number | HTMLElement | null;
|
||||
viewName: string | null;
|
||||
viewTag: number | AnimatedComponentRef | HTMLElement | null;
|
||||
shadowNodeWrapper: ShadowNodeWrapper | null;
|
||||
viewConfig: ViewConfig;
|
||||
viewName?: string;
|
||||
DOMElement?: HTMLElement | null;
|
||||
}
|
||||
export interface IInlinePropManager {
|
||||
attachInlineProps(animatedComponent: React.Component<unknown, unknown>, viewInfo: ViewInfo): void;
|
||||
detachInlineProps(): void;
|
||||
}
|
||||
export type AnimatedComponentType = React.Component<unknown, unknown> & IAnimatedComponentInternal;
|
||||
export type PropUpdates = StyleProps | AnimatedStyle<any>;
|
||||
export interface IPropsFilter {
|
||||
filterNonAnimatedProps: (component: React.Component<unknown, unknown> & IAnimatedComponentInternal) => Record<string, unknown>;
|
||||
filterNonAnimatedProps: (component: AnimatedComponentType) => Record<string, unknown>;
|
||||
}
|
||||
export type JSPropsOperation = {
|
||||
tag: number;
|
||||
updates: StyleProps;
|
||||
};
|
||||
export interface IJSPropsUpdater {
|
||||
addOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
|
||||
removeOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
|
||||
registerComponent(animatedComponent: AnimatedComponentType, jsProps: string[]): void;
|
||||
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||
updateProps(operations: JSPropsOperation[]): void;
|
||||
}
|
||||
export interface INativeEventsManager {
|
||||
attachEvents(): void;
|
||||
detachEvents(): void;
|
||||
updateEvents(prevProps: AnimatedComponentProps<InitialComponentProps>): void;
|
||||
}
|
||||
export type LayoutAnimationStaticContext = {
|
||||
presetName: string;
|
||||
};
|
||||
export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
||||
forwardedRef?: Ref<Component>;
|
||||
export type AnimatedComponentProps<P extends Record<string, unknown> = Record<string, unknown>> = P & {
|
||||
ref?: Ref<Component>;
|
||||
style?: NestedArray<StyleProps>;
|
||||
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||
jestAnimatedValues?: RefObject<AnimatedProps>;
|
||||
animatedStyle?: StyleProps;
|
||||
layout?: (BaseAnimationBuilder | ILayoutAnimationBuilder | typeof BaseAnimationBuilder) & LayoutAnimationStaticContext;
|
||||
entering?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
|
||||
exiting?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
|
||||
sharedTransitionTag?: string;
|
||||
sharedTransitionStyle?: SharedTransition;
|
||||
};
|
||||
export type LayoutAnimationOrBuilder = (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe | ILayoutAnimationBuilder) & LayoutAnimationStaticContext;
|
||||
export interface AnimatedComponentRef extends Component {
|
||||
setNativeProps?: (props: Record<string, unknown>) => void;
|
||||
getScrollableNode?: () => AnimatedComponentRef;
|
||||
getAnimatableRef?: () => AnimatedComponentRef;
|
||||
elementRef?: React.RefObject<HTMLElement>;
|
||||
}
|
||||
export interface IAnimatedComponentInternal {
|
||||
_styles: StyleProps[] | null;
|
||||
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||
_viewTag: number;
|
||||
export interface IAnimatedComponentInternalBase {
|
||||
ChildComponent: AnyComponent;
|
||||
_componentRef: AnimatedComponentRef | HTMLElement | null;
|
||||
_hasAnimatedRef: boolean;
|
||||
_viewInfo?: ViewInfo;
|
||||
/**
|
||||
* Used for Layout Animations and Animated Styles. It is not related to event
|
||||
* handling.
|
||||
*/
|
||||
getComponentViewTag: () => number;
|
||||
}
|
||||
export interface IAnimatedComponentInternal extends IAnimatedComponentInternalBase {
|
||||
_animatedStyles: StyleProps[];
|
||||
_prevAnimatedStyles: StyleProps[];
|
||||
_animatedProps: Partial<AnimatedComponentProps<AnimatedProps>>[];
|
||||
_prevAnimatedProps: Partial<AnimatedComponentProps<AnimatedProps>>[];
|
||||
_isFirstRender: boolean;
|
||||
animatedStyle: {
|
||||
jestInlineStyle: NestedArray<StyleProps> | undefined;
|
||||
jestAnimatedStyle: {
|
||||
value: StyleProps;
|
||||
};
|
||||
_component: AnimatedComponentRef | HTMLElement | null;
|
||||
_sharedElementTransition: SharedTransition | null;
|
||||
_jsPropsUpdater: IJSPropsUpdater;
|
||||
jestAnimatedProps: {
|
||||
value: AnimatedProps;
|
||||
};
|
||||
_InlinePropManager: IInlinePropManager;
|
||||
_PropsFilter: IPropsFilter;
|
||||
_viewInfo?: ViewInfo;
|
||||
/** Doesn't exist on web. */
|
||||
_NativeEventsManager?: INativeEventsManager;
|
||||
context: React.ContextType<typeof SkipEnteringContext>;
|
||||
setNativeProps: (props: StyleProps) => void;
|
||||
}
|
||||
export type NestedArray<T> = T | NestedArray<T>[];
|
||||
export type AnyComponent = React.ComponentType<any>;
|
||||
export interface InitialComponentProps extends Record<string, unknown> {
|
||||
ref?: Ref<Component>;
|
||||
collapsable?: boolean;
|
||||
}
|
||||
export type ManagedAnimatedComponent = React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal;
|
||||
//# sourceMappingURL=commonTypes.d.ts.map
|
||||
Generated
Vendored
+12
-10
@@ -1,10 +1,9 @@
|
||||
import type { ComponentClass, FunctionComponent } from 'react';
|
||||
import '../reanimated2/layoutReanimation/animationsManager';
|
||||
import type { AnimateProps } from '../reanimated2';
|
||||
import type { AnimatedComponentRef } from './commonTypes';
|
||||
import type { ComponentClass, ComponentType, FunctionComponent } from 'react';
|
||||
import type { FlatList, FlatListProps } from 'react-native';
|
||||
type Options<P> = {
|
||||
setNativeProps: (ref: AnimatedComponentRef, props: P) => void;
|
||||
import type { AnimatedProps } from '../helperTypes';
|
||||
import type { Options } from './AnimatedComponent';
|
||||
type AnimatableComponent<C extends ComponentType<any>> = C & {
|
||||
jsProps?: string[];
|
||||
};
|
||||
/**
|
||||
* Lets you create an Animated version of any React Native component.
|
||||
@@ -13,10 +12,13 @@ type Options<P> = {
|
||||
* @returns A component that Reanimated is capable of animating.
|
||||
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
||||
*/
|
||||
export declare function createAnimatedComponent<P extends object>(component: AnimatableComponent<FunctionComponent<P>>, options?: Options<P>): FunctionComponent<AnimatedProps<P>>;
|
||||
export declare function createAnimatedComponent<P extends object>(component: AnimatableComponent<ComponentClass<P>>, options?: Options<P>): ComponentClass<AnimatedProps<P>>;
|
||||
export declare function createAnimatedComponent<P extends object>(component: AnimatableComponent<ComponentType<P>>, options?: Options<P>): FunctionComponent<AnimatedProps<P>> | ComponentClass<AnimatedProps<P>>;
|
||||
/**
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling
|
||||
* `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
*/
|
||||
export declare function createAnimatedComponent(component: typeof FlatList<unknown>, options?: Options<any>): ComponentClass<AnimateProps<FlatListProps<unknown>>>;
|
||||
export declare function createAnimatedComponent<P extends object>(component: FunctionComponent<P>, options?: Options<P>): FunctionComponent<AnimateProps<P>>;
|
||||
export declare function createAnimatedComponent<P extends object>(component: ComponentClass<P>, options?: Options<P>): ComponentClass<AnimateProps<P>>;
|
||||
export declare function createAnimatedComponent(component: AnimatableComponent<typeof FlatList<unknown>>, options?: Options<typeof FlatList<unknown>>): ComponentClass<AnimatedProps<FlatListProps<unknown>>>;
|
||||
export {};
|
||||
//# sourceMappingURL=createAnimatedComponent.d.ts.map
|
||||
Generated
Vendored
+1
@@ -1 +1,2 @@
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
Generated
Vendored
+9
@@ -1,3 +1,12 @@
|
||||
import type { StyleProps } from '../commonTypes';
|
||||
import type { CSSStyle } from '../css';
|
||||
import type { NestedArray } from './commonTypes';
|
||||
export declare function flattenArray<T>(array: NestedArray<T>): T[];
|
||||
export declare const has: <K extends string>(key: K, x: unknown) => x is { [key in K]: unknown; };
|
||||
type FilteredStyles = {
|
||||
cssStyle: CSSStyle | null;
|
||||
animatedStyles: StyleProps[];
|
||||
};
|
||||
export declare function filterStyles(styles: StyleProps[] | undefined): FilteredStyles;
|
||||
export {};
|
||||
//# sourceMappingURL=utils.d.ts.map
|
||||
+48
-1
@@ -1,3 +1,50 @@
|
||||
import './publicGlobals';
|
||||
import * as Animated from './Animated';
|
||||
export * from './reanimated2';
|
||||
export default Animated;
|
||||
export { createAnimatedComponent } from './Animated';
|
||||
export type { DecayAnimation, DelayAnimation, RepeatAnimation, SequenceAnimation, SpringAnimation, StyleLayoutAnimation, TimingAnimation, WithDecayConfig, WithSpringConfig, WithTimingConfig, } from './animation';
|
||||
export { cancelAnimation, defineAnimation, GentleSpringConfig, GentleSpringConfigWithDuration, Reanimated3DefaultSpringConfig, Reanimated3DefaultSpringConfigWithDuration, SnappySpringConfig, SnappySpringConfigWithDuration, WigglySpringConfig, WigglySpringConfigWithDuration, withClamp, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming, } from './animation';
|
||||
export type { ParsedColorArray } from './Colors';
|
||||
export { convertToRGBA, isColor } from './Colors';
|
||||
export { processColor, ReanimatedLogLevel } from './common';
|
||||
export type { AnimatableValue, AnimatableValueObject, AnimatedKeyboardInfo, AnimatedKeyboardOptions, AnimatedSensor, AnimatedStyle, AnimatedTransform, Animation, AnimationCallback, AnimationObject, BaseLayoutAnimationConfig, EasingFunction, EntryAnimationsValues, EntryExitAnimationFunction, ExitAnimationsValues, IEntryExitAnimationBuilder, ILayoutAnimationBuilder, KeyframeProps, LayoutAnimation, LayoutAnimationFunction, LayoutAnimationStartFunction, LayoutAnimationValues as LayoutAnimationsValues, LayoutAnimationType, MeasuredDimensions, SensorConfig, SharedValue, StyleProps, TransformArrayItem, Value3D, ValueRotation, } from './commonTypes';
|
||||
export { InterfaceOrientation, IOSReferenceFrame, KeyboardState, ReduceMotion, SensorType, } from './commonTypes';
|
||||
export type { FlatListPropsWithLayout } from './component/FlatList';
|
||||
export { LayoutAnimationConfig } from './component/LayoutAnimationConfig';
|
||||
export type { PerformanceMonitorProps } from './component/PerformanceMonitor';
|
||||
export { PerformanceMonitor } from './component/PerformanceMonitor';
|
||||
export { ReducedMotionConfig } from './component/ReducedMotionConfig';
|
||||
export type { AnimatedScrollViewProps } from './component/ScrollView';
|
||||
export { configureReanimatedLogger } from './ConfigHelper';
|
||||
export { enableLayoutAnimations, getViewProp, isConfigured, isReanimated3, makeMutable, } from './core';
|
||||
export * from './css';
|
||||
export type { EasingFunctionFactory } from './Easing';
|
||||
export { Easing } from './Easing';
|
||||
export { getStaticFeatureFlag, setDynamicFeatureFlag } from './featureFlags';
|
||||
export type { FrameInfo } from './frameCallback';
|
||||
export type { AnimatedProps, EntryOrExitLayoutType } from './helperTypes';
|
||||
export type { AnimatedRef, DerivedValue, EventHandler, EventHandlerProcessed, FrameCallback, ReanimatedEvent, ScrollEvent, ScrollHandler, ScrollHandlerProcessed, ScrollHandlers, UseHandlerContext, } from './hook';
|
||||
export { useAnimatedKeyboard, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedSensor, useAnimatedStyle, useComposedEventHandler, useDerivedValue, useEvent, useFrameCallback, useHandler, useReducedMotion, useScrollOffset,
|
||||
/** @deprecated Please use {@link useScrollOffset} instead. */
|
||||
useScrollOffset as useScrollViewOffset, useSharedValue, } from './hook';
|
||||
export type { InterpolateConfig, InterpolateHSV, InterpolateRGB, InterpolationOptions, } from './interpolateColor';
|
||||
export { ColorSpace,
|
||||
/** @deprecated Please use {@link Extrapolation} instead. */
|
||||
Extrapolate, interpolateColor, useInterpolateConfig, } from './interpolateColor';
|
||||
export type { ExtrapolationConfig, ExtrapolationType } from './interpolation';
|
||||
export { clamp, Extrapolation, interpolate } from './interpolation';
|
||||
export { isSharedValue } from './isSharedValue';
|
||||
export { advanceAnimationByFrame, advanceAnimationByTime, getAnimatedStyle, setUpTests, withReanimatedTimer, } from './jestUtils';
|
||||
export type { ReanimatedKeyframe } from './layoutReanimation';
|
||||
export { BaseAnimationBuilder, BounceIn, BounceInDown, BounceInLeft, BounceInRight, BounceInUp, BounceOut, BounceOutDown, BounceOutLeft, BounceOutRight, BounceOutUp, ComplexAnimationBuilder, CurvedTransition, EntryExitTransition, FadeIn, FadeInDown, FadeInLeft, FadeInRight, FadeInUp, FadeOut, FadeOutDown, FadeOutLeft, FadeOutRight, FadeOutUp, FadingTransition, FlipInEasyX, FlipInEasyY, FlipInXDown, FlipInXUp, FlipInYLeft, FlipInYRight, FlipOutEasyX, FlipOutEasyY, FlipOutXDown, FlipOutXUp, FlipOutYLeft, FlipOutYRight, JumpingTransition, Keyframe, Layout, LightSpeedInLeft, LightSpeedInRight, LightSpeedOutLeft, LightSpeedOutRight, LinearTransition, PinwheelIn, PinwheelOut, RollInLeft, RollInRight, RollOutLeft, RollOutRight, RotateInDownLeft, RotateInDownRight, RotateInUpLeft, RotateInUpRight, RotateOutDownLeft, RotateOutDownRight, RotateOutUpLeft, RotateOutUpRight, SequencedTransition, SlideInDown, SlideInLeft, SlideInRight, SlideInUp, SlideOutDown, SlideOutLeft, SlideOutRight, SlideOutUp, StretchInX, StretchInY, StretchOutX, StretchOutY, ZoomIn, ZoomInDown, ZoomInEasyDown, ZoomInEasyUp, ZoomInLeft, ZoomInRight, ZoomInRotate, ZoomInUp, ZoomOut, ZoomOutDown, ZoomOutEasyDown, ZoomOutEasyUp, ZoomOutLeft, ZoomOutRight, ZoomOutRotate, ZoomOutUp, } from './layoutReanimation';
|
||||
export { startMapper, stopMapper } from './mappers';
|
||||
export { jsVersion as reanimatedVersion } from './platform-specific/jsVersion';
|
||||
export type { ComponentCoords } from './platformFunctions';
|
||||
export { dispatchCommand, getRelativeCoords, measure, scrollTo, setGestureState, setNativeProps, } from './platformFunctions';
|
||||
export { getUseOfValueInStyleWarning } from './pluginUtils';
|
||||
export { createAnimatedPropAdapter } from './PropAdapters';
|
||||
export type { AnimatedScreenTransition, GoBackGesture, ScreenTransitionConfig, } from './screenTransition';
|
||||
export { finishScreenTransition, ScreenTransition, startScreenTransition, } from './screenTransition';
|
||||
export type { WorkletRuntime } from './workletFunctions';
|
||||
export { createWorkletRuntime, executeOnUIRuntimeSync, isWorkletFunction, makeShareableCloneRecursive, runOnJS, runOnRuntime, runOnUI, } from './workletFunctions';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+4
-49
@@ -1,56 +1,11 @@
|
||||
/**
|
||||
* Mock implementation for test runners.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
|
||||
* ```
|
||||
*/
|
||||
|
||||
const { View, Text, Image, Animated, processColor } = require('react-native');
|
||||
const ReanimatedV2 = require('./src/reanimated2/mock');
|
||||
|
||||
function NOOP() {
|
||||
// noop
|
||||
}
|
||||
|
||||
const Reanimated = {
|
||||
SpringUtils: {
|
||||
makeDefaultConfig: NOOP,
|
||||
makeConfigFromBouncinessAndSpeed: NOOP,
|
||||
makeConfigFromOrigamiTensionAndFriction: NOOP,
|
||||
},
|
||||
|
||||
View,
|
||||
Text,
|
||||
Image,
|
||||
ScrollView: Animated.ScrollView,
|
||||
FlatList: Animated.FlatList,
|
||||
|
||||
Extrapolate: {
|
||||
EXTEND: 'extend',
|
||||
CLAMP: 'clamp',
|
||||
IDENTITY: 'identity',
|
||||
},
|
||||
|
||||
processColor,
|
||||
|
||||
interpolate: NOOP,
|
||||
interpolateColor: NOOP,
|
||||
clamp: NOOP,
|
||||
createAnimatedComponent: (Component) => Component,
|
||||
addWhitelistedUIProps: NOOP,
|
||||
addWhitelistedNativeProps: NOOP,
|
||||
};
|
||||
const Reanimated = require('./src/mock');
|
||||
// @ts-expect-error
|
||||
const Animated = Reanimated.default;
|
||||
|
||||
module.exports = {
|
||||
__esModule: true,
|
||||
|
||||
...Reanimated,
|
||||
...ReanimatedV2,
|
||||
|
||||
default: {
|
||||
...Reanimated,
|
||||
...Animated,
|
||||
},
|
||||
};
|
||||
|
||||
+106
-111
@@ -1,54 +1,46 @@
|
||||
{
|
||||
"name": "react-native-reanimated",
|
||||
"version": "3.6.3",
|
||||
"version": "4.1.6",
|
||||
"description": "More powerful alternative to Animated library for React Native.",
|
||||
"keywords": [
|
||||
"react-native",
|
||||
"react",
|
||||
"native",
|
||||
"reanimated"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
|
||||
"test:unit": "jest",
|
||||
"test:update-snapshot": "jest --updateSnapshot",
|
||||
"lint": "yarn lint:js && yarn lint:plugin && yarn lint:cpp && yarn lint:java && yarn lint:ios",
|
||||
"lint:js": "eslint --ext '.js,.ts,.tsx' src __tests__ __typetests__ && yarn prettier --check src __tests__ __typetests__",
|
||||
"lint:plugin": "cd plugin && yarn lint && cd ..",
|
||||
"lint:docs": "cd docs && yarn lint && cd ..",
|
||||
"lint:java": "./android/gradlew -p android spotlessCheck -q",
|
||||
"lint:cpp": "./scripts/cpplint.sh",
|
||||
"lint:ios": "./scripts/validate-ios.sh && yarn format:ios --dry-run",
|
||||
"format": "yarn format:js && yarn format:plugin && yarn format:java && yarn format:ios && yarn format:android && yarn format:common",
|
||||
"test": "jest",
|
||||
"lint": "yarn lint:js && yarn lint:common && yarn lint:android && yarn lint:apple",
|
||||
"lint:js": "eslint src __tests__ __typetests__ && yarn prettier --check src __tests__ __typetests__",
|
||||
"lint:android": "../../scripts/validate-android.sh && ./android/gradlew -p android spotlessCheck -q && ../../scripts/cpplint.sh android/src && yarn format:android:cpp --dry-run -Werror && yarn lint:cmake",
|
||||
"lint:common": "../../scripts/validate-common.sh && ../../scripts/cpplint.sh Common && yarn format:common --dry-run -Werror",
|
||||
"lint:clang-tidy": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs ../../scripts/clang-tidy-lint.sh",
|
||||
"lint:apple": "../../scripts/validate-apple.sh && yarn format:apple --dry-run -Werror",
|
||||
"lint:cmake": "find ./android -type d \\( -name build -o -name .cxx \\) -prune -o -type f -name 'CMakeLists.txt' -print | xargs ../../scripts/lint-cmake.sh",
|
||||
"format": "yarn format:js && yarn format:apple && yarn format:android && yarn format:common",
|
||||
"format:js": "prettier --write --list-different src __tests__ __typetests__",
|
||||
"format:plugin": "cd plugin && yarn format && cd ..",
|
||||
"format:java": "node ./scripts/format-java.js",
|
||||
"format:ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i --Werror",
|
||||
"format:android": "find android/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
|
||||
"format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
|
||||
"format:docs": "cd docs && yarn format && cd ..",
|
||||
"find-unused-code:js": "yarn ts-prune --ignore \"index|.web.\" --error ",
|
||||
"format:apple": "find apple -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
||||
"format:android": "yarn format:android:java && yarn format:android:cpp && yarn format:android:cmake",
|
||||
"format:android:java": "node ../../scripts/format-java.js",
|
||||
"format:android:cpp": "find android/src -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
||||
"format:android:cmake": "find ./android -type d \\( -name build -o -name .cxx \\) -prune -o -type f -name 'CMakeLists.txt' -print | xargs ../../scripts/format-cmake.sh",
|
||||
"format:common": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
||||
"find-unused-code:js": "knip",
|
||||
"type:check": "yarn type:check:src && yarn type:check:app && yarn type:check:tests:common",
|
||||
"type:check:src": "yarn tsc --noEmit",
|
||||
"type:check:plugin": "cd plugin && yarn type:check:src && cd ..",
|
||||
"type:check:app": "./scripts/test-ts.sh app/src/App.tsx",
|
||||
"type:check:tests:common": "./scripts/test-ts.sh __typetests__/common.tsx",
|
||||
"type:check:tests:0.72+": "./scripts/test-ts.sh __typetests__/0.72+.tsx",
|
||||
"type:check:tests:legacy": "./scripts/test-ts.sh __typetests__/legacy.tsx",
|
||||
"type:check:all": "yarn type:check:src && yarn type:check:plugin && ./scripts/test-ts.sh app/src/App.tsx __typetests__/common.tsx __typetests__/0.72+.tsx __typetests__/legacy.tsx",
|
||||
"prepare": "yarn plugin && bob build && husky install && yarn app",
|
||||
"circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular src lib",
|
||||
"use_strict_check": "node ./scripts/validate-use-strict.js",
|
||||
"setup": "yarn && cd Example && yarn && cd ios && pod install --verbose && cd ../..",
|
||||
"clean": "rm -rf node_modules && cd Example && rm -rf node_modules && cd ios && pod deintegrate && cd ../..",
|
||||
"reset": "yarn clean && yarn setup",
|
||||
"clean:deep": "cd android && rm -rf .cxx .gradle build && cd ../Example/android && rm -rf .gradle build app/build && cd ../.. && yarn clean",
|
||||
"reset:deep": "yarn clean:deep && yarn setup",
|
||||
"plugin": "cd plugin && yarn && cd ..",
|
||||
"app": "cd app && yarn && cd ..",
|
||||
"run-example:ios": "cd Example && yarn && cd ios && pod install && open ReanimatedExample.xcworkspace && cd .. && yarn start --reset-cache",
|
||||
"run-example:ios:cold-start": "cd Example && yarn && cd ios && git clean -xdf && pod install && open ReanimatedExample.xcworkspace && cd .. && yarn start --reset-cache",
|
||||
"run-fabric-example:ios": "cd FabricExample && yarn && cd ios && pod install && open FabricExample.xcworkspace && cd .. && yarn start --reset-cache",
|
||||
"run-fabric-example:ios:cold-start": "cd FabricExample && yarn && cd ios && git clean -xdf && pod install && open FabricExample.xcworkspace && cd .. && yarn start --reset-cache"
|
||||
"type:check:app": "yarn workspace common-app type:check",
|
||||
"type:check:tests:common": "../../scripts/test-ts.sh __typetests__/common",
|
||||
"build": "yarn workspace react-native-worklets build && bob build",
|
||||
"circular-dependency-check": "yarn madge --extensions js,jsx --circular lib",
|
||||
"use-strict-check": "node ../../scripts/validate-use-strict.js",
|
||||
"prepack": "cp ../../README.md ./README.md",
|
||||
"postpack": "rm ./README.md"
|
||||
},
|
||||
"main": "lib/module/index",
|
||||
"module": "lib/module/index",
|
||||
"react-native": "src/index",
|
||||
"source": "src/index",
|
||||
"types": "lib/typescript/index",
|
||||
"types": "lib/typescript/index.d.ts",
|
||||
"files": [
|
||||
"Common/",
|
||||
"src/",
|
||||
@@ -60,9 +52,14 @@
|
||||
"apple/",
|
||||
"RNReanimated.podspec",
|
||||
"scripts/reanimated_utils.rb",
|
||||
"scripts/validate-worklets-build.js",
|
||||
"scripts/validate-worklets-version.js",
|
||||
"scripts/worklets-version.json",
|
||||
"scripts/validate-react-native-version.js",
|
||||
"compatibility.json",
|
||||
"mock.js",
|
||||
"plugin/index.js",
|
||||
"plugin/build/plugin.js",
|
||||
"metro-config",
|
||||
"!**/__tests__",
|
||||
"!**/__fixtures__",
|
||||
"!**/__mocks__",
|
||||
@@ -77,7 +74,8 @@
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/software-mansion/react-native-reanimated.git"
|
||||
"url": "git+https://github.com/software-mansion/react-native-reanimated.git",
|
||||
"directory": "packages/react-native-reanimated"
|
||||
},
|
||||
"author": {
|
||||
"email": "krzys.magiera@gmail.com",
|
||||
@@ -88,106 +86,103 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/software-mansion/react-native-reanimated/issues"
|
||||
},
|
||||
"homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
|
||||
"homepage": "https://docs.swmansion.com/react-native-reanimated",
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"convert-source-map": "^2.0.0",
|
||||
"invariant": "^2.2.4"
|
||||
"react-native-is-edge-to-edge": "^1.2.1",
|
||||
"semver": "7.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.0.0-0",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.0.0-0",
|
||||
"@babel/plugin-transform-shorthand-properties": "^7.0.0-0",
|
||||
"@babel/plugin-transform-template-literals": "^7.0.0-0",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
"react-native": "*",
|
||||
"react-native-worklets": ">=0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.20.0",
|
||||
"@babel/core": "^7.20.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
|
||||
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.0.0",
|
||||
"@babel/plugin-transform-shorthand-properties": "^7.0.0",
|
||||
"@babel/plugin-transform-template-literals": "^7.0.0",
|
||||
"@babel/preset-env": "^7.20.0",
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/preset-env": "^7.25.3",
|
||||
"@babel/types": "^7.20.0",
|
||||
"@react-native/eslint-config": "^0.72.2",
|
||||
"@react-native/babel-preset": "0.81.0",
|
||||
"@react-native/eslint-config": "0.81.0",
|
||||
"@react-native/metro-config": "0.81.0",
|
||||
"@react-native/typescript-config": "0.81.0",
|
||||
"@shopify/flash-list": "2.0.2",
|
||||
"@testing-library/jest-native": "^4.0.4",
|
||||
"@testing-library/react-hooks": "^8.0.0",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@testing-library/react-hooks": "^8.0.1",
|
||||
"@testing-library/react-native": "^13.0.1",
|
||||
"@types/babel__core": "^7.20.0",
|
||||
"@types/babel__generator": "^7.6.4",
|
||||
"@types/babel__traverse": "^7.14.2",
|
||||
"@types/convert-source-map": "^2.0.0",
|
||||
"@types/invariant": "^2.2.35",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-test-renderer": "17.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
||||
"@typescript-eslint/parser": "^5.11.0",
|
||||
"axios": "^1.4.0",
|
||||
"@types/react": "^19.1.0",
|
||||
"@types/react-test-renderer": "^19.1.0",
|
||||
"@types/semver": "^7",
|
||||
"@typescript-eslint/parser": "^6.19.0",
|
||||
"@typescript-eslint/rule-tester": "^6.21.0",
|
||||
"axios": "^1.8.2",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^27.5.1",
|
||||
"babel-plugin-module-resolver": "^5.0.0",
|
||||
"clang-format": "^1.6.0",
|
||||
"clang-format-node": "^1.3.1",
|
||||
"code-tag": "^1.1.0",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-import-resolver-babel-module": "^5.3.1",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"cspell": "^8.8.0",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint-config-standard": "^17.1.0",
|
||||
"eslint-import-resolver-babel-module": "^5.3.2",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.13.0",
|
||||
"eslint-plugin-n": "^17.19.0",
|
||||
"eslint-plugin-no-inline-styles": "^1.0.5",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-promise": "^7.2.1",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-reanimated": "workspace:*",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"eslint-plugin-tsdoc": "^0.2.17",
|
||||
"husky": "^7.0.4",
|
||||
"eslint-plugin-tsdoc": "^0.4.0",
|
||||
"jest": "^29.0.0",
|
||||
"lint-staged": "^11.2.0",
|
||||
"knip": "^5.61.3",
|
||||
"madge": "^5.0.1",
|
||||
"prettier": "^2.5.1",
|
||||
"react": "17.0.2",
|
||||
"react-native": "0.72.6",
|
||||
"react-native-builder-bob": "^0.18.3",
|
||||
"react-native-gesture-handler": "^2.13.2",
|
||||
"react-native-web": "~0.18.12",
|
||||
"react-test-renderer": "17.0.2",
|
||||
"prettier": "^3.3.3",
|
||||
"react": "19.1.0",
|
||||
"react-native": "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-96e336150b.patch",
|
||||
"react-native-builder-bob": "0.40.13",
|
||||
"react-native-gesture-handler": "2.28.0",
|
||||
"react-native-svg": "15.12.1",
|
||||
"react-native-worklets": "workspace:*",
|
||||
"react-test-renderer": "19.1.0",
|
||||
"shelljs": "^0.8.5",
|
||||
"ts-prune": "^0.10.3",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.(js|ts|tsx)": [
|
||||
"eslint",
|
||||
"eslint --quiet --ext '.js,.ts,.tsx' src/",
|
||||
"prettier --write"
|
||||
],
|
||||
"plugin/**/*.ts": "yarn lint:plugin",
|
||||
"**/*.{h,cpp}": "yarn lint:cpp",
|
||||
"android/src/**/*.java": "yarn format:java",
|
||||
"android/src/**/*.{h,cpp}": "yarn format:android",
|
||||
"apple/**/*.{h,m,mm,cpp}": "yarn format:ios",
|
||||
"Common/**/*.{h,cpp}": "yarn format:common"
|
||||
"typescript": "5.8.3"
|
||||
},
|
||||
"react-native-builder-bob": {
|
||||
"source": "src",
|
||||
"output": "lib",
|
||||
"targets": [
|
||||
"module",
|
||||
[
|
||||
"module",
|
||||
{
|
||||
"esm": false,
|
||||
"jsxRuntime": "automatic"
|
||||
}
|
||||
],
|
||||
"typescript"
|
||||
]
|
||||
},
|
||||
"codegenConfig": {
|
||||
"name": "rnreanimated",
|
||||
"type": "modules",
|
||||
"jsSrcsDir": "./src/specs",
|
||||
"android": {
|
||||
"javaPackageName": "com.swmansion.reanimated"
|
||||
}
|
||||
},
|
||||
"sideEffects": [
|
||||
"./lib/reanimated2/core",
|
||||
"./lib/index"
|
||||
"./src/layoutReanimation/animationsManager.ts",
|
||||
"./lib/module/layoutReanimation/animationsManager.js",
|
||||
"./src/core.ts",
|
||||
"./lib/module/core.js",
|
||||
"./src/initializers.ts",
|
||||
"./lib/module/initializers.js",
|
||||
"./src/index.ts",
|
||||
"./lib/module/index.js"
|
||||
]
|
||||
}
|
||||
|
||||
+4
-1
@@ -1 +1,4 @@
|
||||
module.exports = require('./build/plugin.js');
|
||||
// @ts-ignore plugin type isn't exposed
|
||||
const plugin = require('react-native-worklets/plugin');
|
||||
|
||||
module.exports = plugin;
|
||||
|
||||
+51
-15
@@ -13,8 +13,9 @@ def find_config()
|
||||
:react_native_minor_version => nil,
|
||||
:is_tvos_target => nil,
|
||||
:react_native_node_modules_dir => nil,
|
||||
:reanimated_node_modules_dir => nil,
|
||||
:react_native_common_dir => nil,
|
||||
:dynamic_frameworks_reanimated_dir => nil,
|
||||
:dynamic_frameworks_worklets_dir => nil,
|
||||
}
|
||||
|
||||
react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
|
||||
@@ -30,7 +31,13 @@ def find_config()
|
||||
raise '[Reanimated] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
|
||||
end
|
||||
|
||||
result[:is_reanimated_example_app] = ENV["REANIMATED_EXAMPLE_APP_NAME"] != nil
|
||||
validate_worklets_script = File.expand_path(File.join(__dir__, 'validate-worklets-build.js'))
|
||||
unless system("node \"#{validate_worklets_script}\"")
|
||||
abort("[Reanimated] Failed to validate worklets version")
|
||||
end
|
||||
|
||||
|
||||
result[:is_reanimated_example_app] = ENV["IS_REANIMATED_EXAMPLE_APP"] != nil
|
||||
result[:is_tvos_target] = react_native_json['name'] == 'react-native-tvos'
|
||||
result[:react_native_version] = react_native_json['version']
|
||||
result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
|
||||
@@ -38,30 +45,59 @@ def find_config()
|
||||
result[:react_native_minor_version] = 1000
|
||||
end
|
||||
result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
|
||||
result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
|
||||
|
||||
pods_root = Pod::Config.instance.project_pods_root
|
||||
react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
|
||||
react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:react_native_common_dir] = react_native_common_dir_relative
|
||||
|
||||
react_native_reanimated_dir_absolute = File.join(__dir__, '..')
|
||||
react_native_reanimated_dir_relative = Pathname.new(react_native_reanimated_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:dynamic_frameworks_reanimated_dir] = react_native_reanimated_dir_relative
|
||||
|
||||
react_native_worklets_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-worklets/package.json')"`), '..')
|
||||
react_native_worklets_dir_absolute = File.join(react_native_worklets_node_modules_dir, 'react-native-worklets')
|
||||
react_native_worklets_dir_relative = Pathname.new(react_native_worklets_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:dynamic_frameworks_worklets_dir] = react_native_worklets_dir_relative
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
|
||||
reanimated_version = reanimated_package_json['version']
|
||||
reanimated_major_version = reanimated_version.split('.')[0].to_i
|
||||
react_native_minor_version = config[:react_native_minor_version]
|
||||
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
||||
if fabric_enabled && reanimated_major_version == 3 && react_native_minor_version < 72
|
||||
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
||||
raise "[Reanimated] Outdated version of React Native for New Architecture. Reanimated " + reanimated_version + " supports the New Architecture on React Native 0.72.0+. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#outdated-version-of-react-native-for-new-architecture for more information."
|
||||
def assert_minimal_react_native_version(config)
|
||||
validate_react_native_version_script = File.expand_path(File.join(__dir__, 'validate-react-native-version.js'))
|
||||
unless system("node \"#{validate_react_native_version_script}\" #{config[:react_native_version]}")
|
||||
raise "[Reanimated] React Native version is not compatible with Reanimated"
|
||||
end
|
||||
end
|
||||
|
||||
def assert_minimal_react_native_version(config)
|
||||
if config[:react_native_minor_version] < 66
|
||||
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
||||
raise "[Reanimated] Unsupported React Native version. Please use 0.66 or newer."
|
||||
def assert_new_architecture_enabled(new_arch_enabled)
|
||||
if !new_arch_enabled
|
||||
raise "[Reanimated] Reanimated requires the New Architecture to be enabled. If you have `RCT_NEW_ARCH_ENABLED=0` set in your environment you should remove it."
|
||||
end
|
||||
end
|
||||
|
||||
def get_static_feature_flags()
|
||||
feature_flags = {}
|
||||
|
||||
static_feature_flags_path = File.path('./src/featureFlags/staticFlags.json')
|
||||
if !File.exist?(static_feature_flags_path)
|
||||
raise "[Reanimated] Feature flags file not found at #{static_feature_flags_path}."
|
||||
end
|
||||
static_feature_flags_json = JSON.parse(File.read(static_feature_flags_path))
|
||||
static_feature_flags_json.each do |key, value|
|
||||
feature_flags[key] = value.to_s
|
||||
end
|
||||
|
||||
package_json_path = File.join(Pod::Config.instance.installation_root.to_s, '..', 'package.json')
|
||||
if File.exist?(package_json_path)
|
||||
package_json = JSON.parse(File.read(package_json_path))
|
||||
if package_json['reanimated'] && package_json['reanimated']['staticFeatureFlags']
|
||||
feature_flags_json = package_json['reanimated']['staticFeatureFlags']
|
||||
feature_flags_json.each do |key, value|
|
||||
feature_flags[key] = value.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return feature_flags.map { |key, value| "[#{key}:#{value}]" }.join('')
|
||||
end
|
||||
|
||||
+6
-76
@@ -1,81 +1,11 @@
|
||||
'use strict';
|
||||
import type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';
|
||||
import type { SharedValue as _SharedValue } from './reanimated2/commonTypes';
|
||||
import type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';
|
||||
import type {
|
||||
TransformStyleTypes as _TransformStyleTypes,
|
||||
Adaptable as _Adaptable,
|
||||
AdaptTransforms as _AdaptTransforms,
|
||||
AnimatedTransform as _AnimatedTransform,
|
||||
AnimateStyle as _AnimateStyle,
|
||||
StylesOrDefault as _StylesOrDefault,
|
||||
AnimateProps as _AnimateProps,
|
||||
} from './reanimated2/helperTypes';
|
||||
import type { EasingFunction as _EasingFunction } from './reanimated2/Easing';
|
||||
|
||||
import type { AnimatedScrollViewProps as _AnimatedScrollViewProps } from './reanimated2/component/ScrollView';
|
||||
import type { FlatListPropsWithLayout as _FlatListPropsWithLayout } from './reanimated2/component/FlatList';
|
||||
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
export { AnimatedText as Text } from './reanimated2/component/Text';
|
||||
export { AnimatedView as View } from './reanimated2/component/View';
|
||||
export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
|
||||
export { AnimatedImage as Image } from './reanimated2/component/Image';
|
||||
export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
|
||||
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||
export { AnimatedImage as Image } from './component/Image';
|
||||
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||
export { AnimatedText as Text } from './component/Text';
|
||||
export { AnimatedView as View } from './component/View';
|
||||
export {
|
||||
addWhitelistedNativeProps,
|
||||
addWhitelistedUIProps,
|
||||
} from './ConfigHelper';
|
||||
/**
|
||||
* @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type Extrapolate = typeof _Extrapolate;
|
||||
/**
|
||||
* @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
|
||||
export type SharedValue<T> = _SharedValue<T>;
|
||||
/**
|
||||
* @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type DerivedValue<T> = _DerivedValue<T>;
|
||||
/**
|
||||
* @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type Adaptable<T> = _Adaptable<T>;
|
||||
/**
|
||||
* @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type TransformStyleTypes = _TransformStyleTypes;
|
||||
/**
|
||||
* @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AdaptTransforms<T> = _AdaptTransforms<T>;
|
||||
/**
|
||||
* @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
*/
|
||||
export type AnimatedTransform = _AnimatedTransform;
|
||||
/**
|
||||
* @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimateStyle<S> = _AnimateStyle<S>;
|
||||
/**
|
||||
* @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type StylesOrDefault<S> = _StylesOrDefault<S>;
|
||||
/**
|
||||
* @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimateProps<P extends object> = _AnimateProps<P>;
|
||||
/**
|
||||
* @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type EasingFunction = _EasingFunction;
|
||||
/**
|
||||
* @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type AnimatedScrollViewProps = _AnimatedScrollViewProps;
|
||||
/**
|
||||
* @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.
|
||||
* */
|
||||
export type FlatListPropsWithLayout<T> = _FlatListPropsWithLayout<T>;
|
||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||
|
||||
+28
-74
@@ -1,87 +1,41 @@
|
||||
'use strict';
|
||||
import { PropsAllowlists } from './propsAllowlists';
|
||||
import { jsiConfigureProps } from './reanimated2/core';
|
||||
function assertNoOverlapInLists() {
|
||||
for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {
|
||||
if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {
|
||||
throw new Error(
|
||||
`[Reanimated] Property \`${key}\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
import { executeOnUIRuntimeSync } from 'react-native-worklets';
|
||||
|
||||
function configureProps(): void {
|
||||
assertNoOverlapInLists();
|
||||
jsiConfigureProps(
|
||||
Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST),
|
||||
Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST)
|
||||
);
|
||||
}
|
||||
import type { LoggerConfig } from './common';
|
||||
import {
|
||||
getLoggerConfig,
|
||||
SHOULD_BE_USE_WEB,
|
||||
updateLoggerConfig,
|
||||
} from './common';
|
||||
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export function addWhitelistedNativeProps(
|
||||
props: Record<string, boolean>
|
||||
_props: Record<string, boolean>
|
||||
): void {
|
||||
const oldSize = Object.keys(
|
||||
PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST
|
||||
).length;
|
||||
PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST = {
|
||||
...PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST,
|
||||
...props,
|
||||
};
|
||||
if (
|
||||
oldSize !==
|
||||
Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length
|
||||
) {
|
||||
configureProps();
|
||||
}
|
||||
// Do nothing. This is just for backward compatibility.
|
||||
}
|
||||
|
||||
export function addWhitelistedUIProps(props: Record<string, boolean>): void {
|
||||
const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;
|
||||
PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {
|
||||
...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,
|
||||
...props,
|
||||
};
|
||||
if (
|
||||
oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length
|
||||
) {
|
||||
configureProps();
|
||||
}
|
||||
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||
export function addWhitelistedUIProps(_props: Record<string, boolean>): void {
|
||||
// Do nothing. This is just for backward compatibility.
|
||||
}
|
||||
|
||||
const PROCESSED_VIEW_NAMES = new Set();
|
||||
|
||||
export interface ViewConfig {
|
||||
uiViewClassName: string;
|
||||
validAttributes: Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* updates UI props whitelist for given view host instance
|
||||
* this will work just once for every view name
|
||||
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||
* affect Reanimated code executed after call to this function so it should be
|
||||
* called before any Reanimated code is executed to take effect. Each call to
|
||||
* this function will override the previous configuration (it's recommended to
|
||||
* call it only once).
|
||||
*
|
||||
* @param config - The new logger configuration to apply.
|
||||
*/
|
||||
|
||||
export function adaptViewConfig(viewConfig: ViewConfig): void {
|
||||
const viewName = viewConfig.uiViewClassName;
|
||||
const props = viewConfig.validAttributes;
|
||||
|
||||
// update whitelist of UI props for this view name only once
|
||||
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
||||
const propsToAdd: Record<string, boolean> = {};
|
||||
Object.keys(props).forEach((key) => {
|
||||
// we don't want to add native props as they affect layout
|
||||
// we also skip props which repeat here
|
||||
if (
|
||||
!(key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) &&
|
||||
!(key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST)
|
||||
) {
|
||||
propsToAdd[key] = true;
|
||||
}
|
||||
});
|
||||
addWhitelistedUIProps(propsToAdd);
|
||||
|
||||
PROCESSED_VIEW_NAMES.add(viewName);
|
||||
export function configureReanimatedLogger(config: LoggerConfig) {
|
||||
// Get the current config from the React runtime (to have a single source of truth)
|
||||
const currentConfig = getLoggerConfig();
|
||||
// Update the configuration object in the React runtime
|
||||
updateLoggerConfig(currentConfig, config);
|
||||
// Register the updated configuration in the UI runtime
|
||||
if (!SHOULD_BE_USE_WEB) {
|
||||
executeOnUIRuntimeSync(updateLoggerConfig)(currentConfig, config);
|
||||
}
|
||||
}
|
||||
|
||||
configureProps();
|
||||
|
||||
+59
-19
@@ -1,12 +1,14 @@
|
||||
'use strict';
|
||||
import { logger } from './common';
|
||||
import type {
|
||||
ILayoutAnimationBuilder,
|
||||
LayoutAnimationFunction,
|
||||
LayoutAnimationsValues,
|
||||
} from './reanimated2/layoutReanimation';
|
||||
import type { StyleProps } from './reanimated2/commonTypes';
|
||||
LayoutAnimationValues,
|
||||
StyleProps,
|
||||
} from './commonTypes';
|
||||
import type { NestedArray } from './createAnimatedComponent/commonTypes';
|
||||
|
||||
const mockTargetValues: LayoutAnimationsValues = {
|
||||
const mockTargetValues: LayoutAnimationValues = {
|
||||
targetOriginX: 0,
|
||||
targetOriginY: 0,
|
||||
targetWidth: 0,
|
||||
@@ -25,12 +27,57 @@ const mockTargetValues: LayoutAnimationsValues = {
|
||||
currentBorderRadius: 0,
|
||||
};
|
||||
|
||||
function getCommonProperties(
|
||||
layoutStyle: StyleProps,
|
||||
componentStyle: NestedArray<StyleProps>
|
||||
) {
|
||||
let componentStyleFlat = Array.isArray(componentStyle)
|
||||
? componentStyle.flat()
|
||||
: [componentStyle];
|
||||
|
||||
componentStyleFlat = componentStyleFlat.filter(Boolean);
|
||||
|
||||
componentStyleFlat = componentStyleFlat.map((style) =>
|
||||
'initial' in style
|
||||
? style.initial.value // Include properties of animated style
|
||||
: style
|
||||
);
|
||||
|
||||
const componentStylesKeys = componentStyleFlat.flatMap((style) =>
|
||||
Object.keys(style)
|
||||
);
|
||||
|
||||
const commonKeys = Object.keys(layoutStyle).filter((key) =>
|
||||
componentStylesKeys.includes(key)
|
||||
);
|
||||
|
||||
return commonKeys;
|
||||
}
|
||||
|
||||
function maybeReportOverwrittenProperties(
|
||||
layoutAnimationStyle: StyleProps,
|
||||
style: NestedArray<StyleProps>,
|
||||
displayName: string
|
||||
) {
|
||||
const commonProperties = getCommonProperties(layoutAnimationStyle, style);
|
||||
|
||||
if (commonProperties.length > 0) {
|
||||
logger.warn(
|
||||
`${
|
||||
commonProperties.length === 1 ? 'Property' : 'Properties'
|
||||
} "${commonProperties.join(
|
||||
', '
|
||||
)}" of ${displayName} may be overwritten by a layout animation. Please wrap your component with an animated view and apply the layout animation on the wrapper.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function maybeBuild(
|
||||
layoutAnimationOrBuilder:
|
||||
| ILayoutAnimationBuilder
|
||||
| LayoutAnimationFunction
|
||||
| Keyframe,
|
||||
style: StyleProps | undefined,
|
||||
style: NestedArray<StyleProps> | undefined,
|
||||
displayName: string
|
||||
): LayoutAnimationFunction | Keyframe {
|
||||
const isAnimationBuilder = (
|
||||
@@ -41,24 +88,17 @@ export function maybeBuild(
|
||||
|
||||
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
||||
const animationFactory = layoutAnimationOrBuilder.build();
|
||||
const layoutAnimation = animationFactory(mockTargetValues);
|
||||
const animatedStyle = layoutAnimation.animations;
|
||||
|
||||
const getCommonProperties = (obj1: object, obj2: object) =>
|
||||
Object.keys(obj1).filter((key) =>
|
||||
Object.prototype.hasOwnProperty.call(obj2, key)
|
||||
);
|
||||
|
||||
const commonProperties = getCommonProperties(animatedStyle, style || {});
|
||||
if (commonProperties.length > 0) {
|
||||
console.warn(
|
||||
`[Reanimated] ${
|
||||
commonProperties.length === 1 ? 'Property' : 'Properties: '
|
||||
} "${commonProperties}" of ${displayName} may be overwritten with layout animation. Please create a wrapper with the layout animation you want to apply.`
|
||||
if (__DEV__ && style) {
|
||||
const layoutAnimation = animationFactory(mockTargetValues);
|
||||
maybeReportOverwrittenProperties(
|
||||
layoutAnimation.animations,
|
||||
style,
|
||||
displayName
|
||||
);
|
||||
}
|
||||
|
||||
return layoutAnimationOrBuilder.build();
|
||||
return animationFactory;
|
||||
} else {
|
||||
return layoutAnimationOrBuilder;
|
||||
}
|
||||
|
||||
frontend-admin/node_modules/react-native-reanimated/src/createAnimatedComponent/InlinePropManager.ts
Generated
Vendored
+32
-50
@@ -1,24 +1,17 @@
|
||||
'use strict';
|
||||
import type { StyleProps } from '../reanimated2';
|
||||
import type { StyleProps } from '../commonTypes';
|
||||
import { isSharedValue } from '../isSharedValue';
|
||||
import { startMapper, stopMapper } from '../mappers';
|
||||
import { updateProps } from '../updateProps';
|
||||
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
import { makeViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
import type {
|
||||
IAnimatedComponentInternal,
|
||||
AnimatedComponentProps,
|
||||
AnimatedComponentType,
|
||||
IInlinePropManager,
|
||||
ViewInfo,
|
||||
} from './commonTypes';
|
||||
import { flattenArray } from './utils';
|
||||
import { makeViewDescriptorsSet } from '../reanimated2/ViewDescriptorsSet';
|
||||
import type {
|
||||
ViewDescriptorsSet,
|
||||
ViewRefSet,
|
||||
} from '../reanimated2/ViewDescriptorsSet';
|
||||
import { adaptViewConfig } from '../ConfigHelper';
|
||||
import updateProps from '../reanimated2/UpdateProps';
|
||||
import { stopMapper, startMapper } from '../reanimated2/mappers';
|
||||
import { isSharedValue } from '../reanimated2/isSharedValue';
|
||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
||||
|
||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
||||
|
||||
function isInlineStyleTransform(transform: unknown): boolean {
|
||||
if (!Array.isArray(transform)) {
|
||||
@@ -37,29 +30,30 @@ function inlinePropsHasChanged(
|
||||
}
|
||||
|
||||
for (const key of Object.keys(styles1)) {
|
||||
if (styles1[key] !== styles2[key]) return true;
|
||||
if (styles1[key] !== styles2[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getInlinePropsUpdate(inlineProps: Record<string, unknown>) {
|
||||
function getInlinePropsUpdate(styleValue: StyleProps): unknown {
|
||||
'worklet';
|
||||
const update: Record<string, unknown> = {};
|
||||
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
||||
if (isSharedValue(styleValue)) {
|
||||
update[key] = styleValue.value;
|
||||
} else if (Array.isArray(styleValue)) {
|
||||
update[key] = styleValue.map((item) => {
|
||||
return getInlinePropsUpdate(item);
|
||||
});
|
||||
} else if (typeof styleValue === 'object') {
|
||||
update[key] = getInlinePropsUpdate(styleValue as Record<string, unknown>);
|
||||
} else {
|
||||
update[key] = styleValue;
|
||||
}
|
||||
if (isSharedValue(styleValue)) {
|
||||
return styleValue.value;
|
||||
}
|
||||
return update;
|
||||
if (Array.isArray(styleValue)) {
|
||||
return styleValue.map(getInlinePropsUpdate);
|
||||
}
|
||||
if (styleValue && typeof styleValue === 'object') {
|
||||
const update: Record<string, unknown> = {};
|
||||
for (const [key, value] of Object.entries(styleValue)) {
|
||||
update[key] = getInlinePropsUpdate(value);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
return styleValue;
|
||||
}
|
||||
|
||||
function extractSharedValuesMapFromProps(
|
||||
@@ -77,14 +71,14 @@ function extractSharedValuesMapFromProps(
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
for (const [key, styleValue] of Object.entries(style)) {
|
||||
for (const [styleKey, styleValue] of Object.entries(style)) {
|
||||
if (isSharedValue(styleValue)) {
|
||||
inlineProps[key] = styleValue;
|
||||
inlineProps[styleKey] = styleValue;
|
||||
} else if (
|
||||
key === 'transform' &&
|
||||
styleKey === 'transform' &&
|
||||
isInlineStyleTransform(styleValue)
|
||||
) {
|
||||
inlineProps[key] = styleValue;
|
||||
inlineProps[styleKey] = styleValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -114,7 +108,7 @@ export function getInlineStyle(
|
||||
isFirstRender: boolean
|
||||
) {
|
||||
if (isFirstRender) {
|
||||
return getInlinePropsUpdate(style);
|
||||
return getInlinePropsUpdate(style) as Record<string, unknown>;
|
||||
}
|
||||
const newStyle: StyleProps = {};
|
||||
for (const [key, styleValue] of Object.entries(style)) {
|
||||
@@ -134,8 +128,7 @@ export class InlinePropManager implements IInlinePropManager {
|
||||
_inlineProps: StyleProps = {};
|
||||
|
||||
public attachInlineProps(
|
||||
animatedComponent: React.Component<unknown, unknown> &
|
||||
IAnimatedComponentInternal,
|
||||
animatedComponent: AnimatedComponentType,
|
||||
viewInfo: ViewInfo
|
||||
) {
|
||||
const newInlineProps: Record<string, unknown> =
|
||||
@@ -146,31 +139,20 @@ export class InlinePropManager implements IInlinePropManager {
|
||||
if (!this._inlinePropsViewDescriptors) {
|
||||
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
||||
|
||||
const { viewTag, viewName, shadowNodeWrapper, viewConfig } = viewInfo;
|
||||
|
||||
if (Object.keys(newInlineProps).length && viewConfig) {
|
||||
adaptViewConfig(viewConfig);
|
||||
}
|
||||
const { viewTag, shadowNodeWrapper } = viewInfo;
|
||||
|
||||
this._inlinePropsViewDescriptors.add({
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
tag: viewTag as number,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
name: viewName!,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
shadowNodeWrapper: shadowNodeWrapper!,
|
||||
});
|
||||
}
|
||||
const shareableViewDescriptors =
|
||||
this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
||||
|
||||
const maybeViewRef = SHOULD_BE_USE_WEB
|
||||
? ({ items: new Set([animatedComponent]) } as ViewRefSet<unknown>) // see makeViewsRefSet
|
||||
: undefined;
|
||||
const updaterFunction = () => {
|
||||
'worklet';
|
||||
const update = getInlinePropsUpdate(newInlineProps);
|
||||
updateProps(shareableViewDescriptors, update, maybeViewRef);
|
||||
updateProps(shareableViewDescriptors, update);
|
||||
};
|
||||
this._inlineProps = newInlineProps;
|
||||
if (this._inlinePropsMapperId) {
|
||||
|
||||
Generated
Vendored
+42
-108
@@ -1,124 +1,55 @@
|
||||
'use strict';
|
||||
import {
|
||||
NativeEventEmitter,
|
||||
NativeModules,
|
||||
findNodeHandle,
|
||||
} from 'react-native';
|
||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
||||
import type { StyleProps } from '../reanimated2';
|
||||
import { runOnJS, runOnUIImmediately } from '../reanimated2/threads';
|
||||
import { runOnUI } from 'react-native-worklets';
|
||||
|
||||
import { SHOULD_BE_USE_WEB } from '../common';
|
||||
import type {
|
||||
AnimatedComponentProps,
|
||||
AnimatedComponentType,
|
||||
IAnimatedComponentInternal,
|
||||
IJSPropsUpdater,
|
||||
InitialComponentProps,
|
||||
JSPropsOperation,
|
||||
} from './commonTypes';
|
||||
|
||||
interface ListenerData {
|
||||
viewTag: number;
|
||||
props: StyleProps;
|
||||
}
|
||||
class JSPropsUpdaterNative implements IJSPropsUpdater {
|
||||
private static _tagToComponentMapping = new Map<
|
||||
number,
|
||||
AnimatedComponentType
|
||||
>();
|
||||
|
||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
||||
|
||||
class JSPropsUpdaterPaper implements IJSPropsUpdater {
|
||||
private static _tagToComponentMapping = new Map();
|
||||
private _reanimatedEventEmitter: NativeEventEmitter;
|
||||
|
||||
constructor() {
|
||||
this._reanimatedEventEmitter = new NativeEventEmitter(
|
||||
NativeModules.ReanimatedModule
|
||||
);
|
||||
}
|
||||
|
||||
public addOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
IAnimatedComponentInternal
|
||||
public registerComponent(
|
||||
animatedComponent: AnimatedComponentType,
|
||||
jsProps: string[]
|
||||
) {
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterPaper._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 1) {
|
||||
const listener = (data: ListenerData) => {
|
||||
const component = JSPropsUpdaterPaper._tagToComponentMapping.get(
|
||||
data.viewTag
|
||||
);
|
||||
component?._updateFromNative(data.props);
|
||||
};
|
||||
this._reanimatedEventEmitter.addListener(
|
||||
'onReanimatedPropsChange',
|
||||
listener
|
||||
const viewTag = animatedComponent.getComponentViewTag();
|
||||
JSPropsUpdaterNative._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
|
||||
runOnUI(() => {
|
||||
global._tagToJSPropNamesMapping[viewTag] = Object.fromEntries(
|
||||
jsProps.map((propName) => [propName, true])
|
||||
);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
public removeOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
IAnimatedComponentInternal
|
||||
) {
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterPaper._tagToComponentMapping.delete(viewTag);
|
||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 0) {
|
||||
this._reanimatedEventEmitter.removeAllListeners(
|
||||
'onReanimatedPropsChange'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
public unregisterComponent(animatedComponent: AnimatedComponentType) {
|
||||
const viewTag = animatedComponent.getComponentViewTag();
|
||||
JSPropsUpdaterNative._tagToComponentMapping.delete(viewTag);
|
||||
|
||||
class JSPropsUpdaterFabric implements IJSPropsUpdater {
|
||||
private static _tagToComponentMapping = new Map();
|
||||
private static isInitialized = false;
|
||||
|
||||
constructor() {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
const updater = (viewTag: number, props: unknown) => {
|
||||
const component =
|
||||
JSPropsUpdaterFabric._tagToComponentMapping.get(viewTag);
|
||||
component?._updateFromNative(props);
|
||||
};
|
||||
runOnUIImmediately(() => {
|
||||
'worklet';
|
||||
global.updateJSProps = (viewTag: number, props: unknown) => {
|
||||
runOnJS(updater)(viewTag, props);
|
||||
};
|
||||
})();
|
||||
JSPropsUpdaterFabric.isInitialized = true;
|
||||
}
|
||||
runOnUI(() => {
|
||||
delete global._tagToJSPropNamesMapping[viewTag];
|
||||
})();
|
||||
}
|
||||
|
||||
public addOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
IAnimatedComponentInternal
|
||||
) {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
return;
|
||||
}
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterFabric._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||
}
|
||||
|
||||
public removeOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
IAnimatedComponentInternal
|
||||
) {
|
||||
if (!JSPropsUpdaterFabric.isInitialized) {
|
||||
return;
|
||||
}
|
||||
const viewTag = findNodeHandle(animatedComponent);
|
||||
JSPropsUpdaterFabric._tagToComponentMapping.delete(viewTag);
|
||||
public updateProps(operations: JSPropsOperation[]) {
|
||||
operations.forEach(({ tag, updates }) => {
|
||||
const component = JSPropsUpdaterNative._tagToComponentMapping.get(tag);
|
||||
component?.setNativeProps(updates);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||
public addOnJSPropsChangeListener(
|
||||
public registerComponent(
|
||||
_animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
@@ -127,7 +58,7 @@ class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||
// noop
|
||||
}
|
||||
|
||||
public removeOnJSPropsChangeListener(
|
||||
public unregisterComponent(
|
||||
_animatedComponent: React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
@@ -135,20 +66,23 @@ class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||
) {
|
||||
// noop
|
||||
}
|
||||
|
||||
public updateProps(_operations: JSPropsOperation[]) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
type JSPropsUpdaterOptions =
|
||||
| typeof JSPropsUpdaterWeb
|
||||
| typeof JSPropsUpdaterFabric
|
||||
| typeof JSPropsUpdaterPaper;
|
||||
| typeof JSPropsUpdaterNative;
|
||||
|
||||
let JSPropsUpdater: JSPropsUpdaterOptions;
|
||||
if (SHOULD_BE_USE_WEB) {
|
||||
JSPropsUpdater = JSPropsUpdaterWeb;
|
||||
} else if (global._IS_FABRIC) {
|
||||
JSPropsUpdater = JSPropsUpdaterFabric;
|
||||
} else {
|
||||
JSPropsUpdater = JSPropsUpdaterPaper;
|
||||
JSPropsUpdater = JSPropsUpdaterNative;
|
||||
}
|
||||
|
||||
export default JSPropsUpdater;
|
||||
const jsPropsUpdater = new JSPropsUpdater();
|
||||
|
||||
export default jsPropsUpdater;
|
||||
|
||||
Generated
Vendored
+50
-38
@@ -1,19 +1,19 @@
|
||||
'use strict';
|
||||
import type { StyleProps, SharedValue } from '../reanimated2';
|
||||
import { isSharedValue } from '../reanimated2';
|
||||
import { isChromeDebugger } from '../reanimated2/PlatformChecker';
|
||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
||||
import { initialUpdaterRun } from '../reanimated2/animation';
|
||||
import { hasInlineStyles, getInlineStyle } from './InlinePropManager';
|
||||
|
||||
import { initialUpdaterRun } from '../animation';
|
||||
import type { StyleProps } from '../commonTypes';
|
||||
import type { AnimatedStyleHandle } from '../hook/commonTypes';
|
||||
import { isSharedValue } from '../isSharedValue';
|
||||
import { WorkletEventHandler } from '../WorkletEventHandler';
|
||||
import type {
|
||||
AnimatedComponentProps,
|
||||
AnimatedComponentType,
|
||||
AnimatedProps,
|
||||
InitialComponentProps,
|
||||
IAnimatedComponentInternal,
|
||||
IPropsFilter,
|
||||
} from './commonTypes';
|
||||
import { getInlineStyle, hasInlineStyles } from './InlinePropManager';
|
||||
import { flattenArray, has } from './utils';
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
function dummyListener() {
|
||||
// empty listener we use to assign to listener properties for which animated
|
||||
@@ -21,56 +21,68 @@ function dummyListener() {
|
||||
}
|
||||
|
||||
export class PropsFilter implements IPropsFilter {
|
||||
private _initialStyle = {};
|
||||
private _initialPropsMap = new Map<AnimatedStyleHandle, StyleProps>();
|
||||
|
||||
public filterNonAnimatedProps(
|
||||
component: React.Component<unknown, unknown> & IAnimatedComponentInternal
|
||||
component: AnimatedComponentType
|
||||
): Record<string, unknown> {
|
||||
const inputProps =
|
||||
component.props as AnimatedComponentProps<InitialComponentProps>;
|
||||
const props: Record<string, unknown> = {};
|
||||
|
||||
for (const key in inputProps) {
|
||||
const value = inputProps[key];
|
||||
if (key === 'style') {
|
||||
const styleProp = inputProps.style;
|
||||
const styles = flattenArray<StyleProps>(styleProp ?? []);
|
||||
const processedStyle: StyleProps = styles.map((style) => {
|
||||
if (style && style.viewDescriptors) {
|
||||
// this is how we recognize styles returned by useAnimatedStyle
|
||||
style.viewsRef.add(component);
|
||||
|
||||
const processedStyle: StyleProps[] = styles.map((style) => {
|
||||
if (style?.viewDescriptors) {
|
||||
const handle = style as AnimatedStyleHandle;
|
||||
|
||||
if (component._isFirstRender) {
|
||||
this._initialStyle = {
|
||||
...style.initial.value,
|
||||
...this._initialStyle,
|
||||
...initialUpdaterRun<StyleProps>(style.initial.updater),
|
||||
};
|
||||
this._initialPropsMap.set(handle, {
|
||||
...handle.initial.value,
|
||||
...initialUpdaterRun(handle.initial.updater),
|
||||
} as StyleProps);
|
||||
}
|
||||
return this._initialStyle;
|
||||
|
||||
return this._initialPropsMap.get(handle) ?? {};
|
||||
} else if (hasInlineStyles(style)) {
|
||||
return getInlineStyle(style, component._isFirstRender);
|
||||
} else {
|
||||
return style;
|
||||
}
|
||||
});
|
||||
props[key] = StyleSheet.flatten(processedStyle);
|
||||
// keep styles as they were passed by the user
|
||||
// it will help other libs to interpret styles correctly
|
||||
props[key] = processedStyle;
|
||||
} else if (key === 'animatedProps') {
|
||||
const animatedProp = inputProps.animatedProps as Partial<
|
||||
AnimatedComponentProps<AnimatedProps>
|
||||
>;
|
||||
if (animatedProp.initial !== undefined) {
|
||||
Object.keys(animatedProp.initial.value).forEach((key) => {
|
||||
props[key] = animatedProp.initial?.value[key];
|
||||
animatedProp.viewsRef?.add(component);
|
||||
});
|
||||
}
|
||||
const animatedPropsProp = inputProps.animatedProps;
|
||||
const animatedPropsArray = flattenArray<
|
||||
Partial<AnimatedComponentProps<AnimatedProps>>
|
||||
>(animatedPropsProp ?? []);
|
||||
|
||||
animatedPropsArray.forEach((animatedProps) => {
|
||||
if (animatedProps?.viewDescriptors && animatedProps.initial) {
|
||||
Object.keys(animatedProps.initial.value).forEach(
|
||||
(initialValueKey) => {
|
||||
props[initialValueKey] =
|
||||
animatedProps.initial?.value[initialValueKey];
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (
|
||||
has('current', value) &&
|
||||
value.current instanceof WorkletEventHandler
|
||||
has('workletEventHandler', value) &&
|
||||
value.workletEventHandler instanceof WorkletEventHandler
|
||||
) {
|
||||
if (value.current.eventNames.length > 0) {
|
||||
value.current.eventNames.forEach((eventName) => {
|
||||
props[eventName] = has('listeners', value.current)
|
||||
? (value.current.listeners as Record<string, unknown>)[eventName]
|
||||
if (value.workletEventHandler.eventNames.length > 0) {
|
||||
value.workletEventHandler.eventNames.forEach((eventName) => {
|
||||
props[eventName] = has('listeners', value.workletEventHandler)
|
||||
? (
|
||||
value.workletEventHandler.listeners as Record<string, unknown>
|
||||
)[eventName]
|
||||
: dummyListener;
|
||||
});
|
||||
} else {
|
||||
@@ -78,9 +90,9 @@ export class PropsFilter implements IPropsFilter {
|
||||
}
|
||||
} else if (isSharedValue(value)) {
|
||||
if (component._isFirstRender) {
|
||||
props[key] = (value as SharedValue<unknown>).value;
|
||||
props[key] = value.value;
|
||||
}
|
||||
} else if (key !== 'onGestureHandlerStateChange' || !isChromeDebugger()) {
|
||||
} else {
|
||||
props[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+92
-38
@@ -1,32 +1,35 @@
|
||||
'use strict';
|
||||
import type { Ref, Component } from 'react';
|
||||
import type { Component, Ref, RefObject } from 'react';
|
||||
|
||||
import type {
|
||||
StyleProps,
|
||||
BaseAnimationBuilder,
|
||||
ILayoutAnimationBuilder,
|
||||
AnimatedStyle,
|
||||
EntryExitAnimationFunction,
|
||||
SharedTransition,
|
||||
ILayoutAnimationBuilder,
|
||||
ShadowNodeWrapper,
|
||||
SharedValue,
|
||||
} from '../reanimated2';
|
||||
import type {
|
||||
ViewDescriptorsSet,
|
||||
ViewRefSet,
|
||||
} from '../reanimated2/ViewDescriptorsSet';
|
||||
import type { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
||||
import type { ShadowNodeWrapper } from '../reanimated2/commonTypes';
|
||||
import type { ViewConfig } from '../ConfigHelper';
|
||||
StyleProps,
|
||||
StyleUpdaterContainer,
|
||||
} from '../commonTypes';
|
||||
import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
|
||||
import type { BaseAnimationBuilder } from '../layoutReanimation';
|
||||
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||
|
||||
export interface AnimatedProps extends Record<string, unknown> {
|
||||
viewDescriptors?: ViewDescriptorsSet;
|
||||
viewsRef?: ViewRefSet<unknown>;
|
||||
initial?: SharedValue<StyleProps>;
|
||||
styleUpdaterContainer?: StyleUpdaterContainer;
|
||||
}
|
||||
|
||||
export interface ViewInfo {
|
||||
viewTag: number | HTMLElement | null;
|
||||
viewName: string | null;
|
||||
viewTag: number | AnimatedComponentRef | HTMLElement | null;
|
||||
shadowNodeWrapper: ShadowNodeWrapper | null;
|
||||
viewConfig: ViewConfig;
|
||||
// This is a React host instance view name which might differ from the
|
||||
// Fabric component name. For clarity, we use the viewName property
|
||||
// here and componentName in C++ after converting react viewName to
|
||||
// Fabric component name.
|
||||
// (see react/renderer/componentregistry/componentNameByReactViewName.cpp)
|
||||
viewName?: string;
|
||||
DOMElement?: HTMLElement | null;
|
||||
}
|
||||
|
||||
export interface IInlinePropManager {
|
||||
@@ -37,31 +40,49 @@ export interface IInlinePropManager {
|
||||
detachInlineProps(): void;
|
||||
}
|
||||
|
||||
export type AnimatedComponentType = React.Component<unknown, unknown> &
|
||||
IAnimatedComponentInternal;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
||||
export type PropUpdates = StyleProps | AnimatedStyle<any>;
|
||||
|
||||
export interface IPropsFilter {
|
||||
filterNonAnimatedProps: (
|
||||
component: React.Component<unknown, unknown> & IAnimatedComponentInternal
|
||||
component: AnimatedComponentType
|
||||
) => Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type JSPropsOperation = {
|
||||
tag: number;
|
||||
updates: StyleProps;
|
||||
};
|
||||
|
||||
export interface IJSPropsUpdater {
|
||||
addOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<unknown, unknown> &
|
||||
IAnimatedComponentInternal
|
||||
): void;
|
||||
removeOnJSPropsChangeListener(
|
||||
animatedComponent: React.Component<unknown, unknown> &
|
||||
IAnimatedComponentInternal
|
||||
registerComponent(
|
||||
animatedComponent: AnimatedComponentType,
|
||||
jsProps: string[]
|
||||
): void;
|
||||
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||
updateProps(operations: JSPropsOperation[]): void;
|
||||
}
|
||||
|
||||
export interface INativeEventsManager {
|
||||
attachEvents(): void;
|
||||
detachEvents(): void;
|
||||
updateEvents(prevProps: AnimatedComponentProps<InitialComponentProps>): void;
|
||||
}
|
||||
|
||||
export type LayoutAnimationStaticContext = {
|
||||
presetName: string;
|
||||
};
|
||||
|
||||
export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
||||
forwardedRef?: Ref<Component>;
|
||||
export type AnimatedComponentProps<
|
||||
P extends Record<string, unknown> = Record<string, unknown>,
|
||||
> = P & {
|
||||
ref?: Ref<Component>;
|
||||
style?: NestedArray<StyleProps>;
|
||||
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||
jestAnimatedValues?: RefObject<AnimatedProps>;
|
||||
animatedStyle?: StyleProps;
|
||||
layout?: (
|
||||
| BaseAnimationBuilder
|
||||
@@ -83,34 +104,67 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
||||
| Keyframe
|
||||
) &
|
||||
LayoutAnimationStaticContext;
|
||||
sharedTransitionTag?: string;
|
||||
sharedTransitionStyle?: SharedTransition;
|
||||
};
|
||||
|
||||
export type LayoutAnimationOrBuilder = (
|
||||
| BaseAnimationBuilder
|
||||
| typeof BaseAnimationBuilder
|
||||
| EntryExitAnimationFunction
|
||||
| Keyframe
|
||||
| ILayoutAnimationBuilder
|
||||
) &
|
||||
LayoutAnimationStaticContext;
|
||||
|
||||
export interface AnimatedComponentRef extends Component {
|
||||
setNativeProps?: (props: Record<string, unknown>) => void;
|
||||
getScrollableNode?: () => AnimatedComponentRef;
|
||||
getAnimatableRef?: () => AnimatedComponentRef;
|
||||
// Case for SVG components on Web
|
||||
elementRef?: React.RefObject<HTMLElement>;
|
||||
}
|
||||
|
||||
export interface IAnimatedComponentInternal {
|
||||
_styles: StyleProps[] | null;
|
||||
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||
_viewTag: number;
|
||||
export interface IAnimatedComponentInternalBase {
|
||||
ChildComponent: AnyComponent;
|
||||
_componentRef: AnimatedComponentRef | HTMLElement | null;
|
||||
_hasAnimatedRef: boolean;
|
||||
_viewInfo?: ViewInfo;
|
||||
|
||||
/**
|
||||
* Used for Layout Animations and Animated Styles. It is not related to event
|
||||
* handling.
|
||||
*/
|
||||
getComponentViewTag: () => number;
|
||||
}
|
||||
|
||||
export interface IAnimatedComponentInternal
|
||||
extends IAnimatedComponentInternalBase {
|
||||
_animatedStyles: StyleProps[];
|
||||
_prevAnimatedStyles: StyleProps[];
|
||||
_animatedProps: Partial<AnimatedComponentProps<AnimatedProps>>[];
|
||||
_prevAnimatedProps: Partial<AnimatedComponentProps<AnimatedProps>>[];
|
||||
_isFirstRender: boolean;
|
||||
animatedStyle: { value: StyleProps };
|
||||
_component: AnimatedComponentRef | HTMLElement | null;
|
||||
_sharedElementTransition: SharedTransition | null;
|
||||
_jsPropsUpdater: IJSPropsUpdater;
|
||||
jestInlineStyle: NestedArray<StyleProps> | undefined;
|
||||
jestAnimatedStyle: { value: StyleProps };
|
||||
jestAnimatedProps: { value: AnimatedProps };
|
||||
_InlinePropManager: IInlinePropManager;
|
||||
_PropsFilter: IPropsFilter;
|
||||
_viewInfo?: ViewInfo;
|
||||
/** Doesn't exist on web. */
|
||||
_NativeEventsManager?: INativeEventsManager;
|
||||
context: React.ContextType<typeof SkipEnteringContext>;
|
||||
setNativeProps: (props: StyleProps) => void;
|
||||
}
|
||||
|
||||
export type NestedArray<T> = T | NestedArray<T>[];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type AnyComponent = React.ComponentType<any>;
|
||||
|
||||
export interface InitialComponentProps extends Record<string, unknown> {
|
||||
ref?: Ref<Component>;
|
||||
collapsable?: boolean;
|
||||
}
|
||||
|
||||
export type ManagedAnimatedComponent = React.Component<
|
||||
AnimatedComponentProps<InitialComponentProps>
|
||||
> &
|
||||
IAnimatedComponentInternal;
|
||||
|
||||
Generated
Vendored
+59
-563
@@ -1,81 +1,24 @@
|
||||
'use strict';
|
||||
import type {
|
||||
Component,
|
||||
ComponentClass,
|
||||
ComponentType,
|
||||
FunctionComponent,
|
||||
MutableRefObject,
|
||||
Ref,
|
||||
} from 'react';
|
||||
import React from 'react';
|
||||
import { findNodeHandle, Platform } from 'react-native';
|
||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
||||
import '../reanimated2/layoutReanimation/animationsManager';
|
||||
import invariant from 'invariant';
|
||||
import { adaptViewConfig } from '../ConfigHelper';
|
||||
import { RNRenderer } from '../reanimated2/platform-specific/RNRenderer';
|
||||
import {
|
||||
configureLayoutAnimations,
|
||||
enableLayoutAnimations,
|
||||
} from '../reanimated2/core';
|
||||
import {
|
||||
SharedTransition,
|
||||
LayoutAnimationType,
|
||||
} from '../reanimated2/layoutReanimation';
|
||||
import type { StyleProps, ShadowNodeWrapper } from '../reanimated2/commonTypes';
|
||||
import { getShadowNodeWrapperFromRef } from '../reanimated2/fabricUtils';
|
||||
import { removeFromPropsRegistry } from '../reanimated2/PropsRegistry';
|
||||
import { getReduceMotionFromConfig } from '../reanimated2/animation/util';
|
||||
import { maybeBuild } from '../animationBuilder';
|
||||
import { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
||||
import type { AnimateProps } from '../reanimated2';
|
||||
import JSPropsUpdater from './JSPropsUpdater';
|
||||
import type {
|
||||
AnimatedComponentProps,
|
||||
AnimatedProps,
|
||||
InitialComponentProps,
|
||||
AnimatedComponentRef,
|
||||
IAnimatedComponentInternal,
|
||||
ViewInfo,
|
||||
} from './commonTypes';
|
||||
import { has, flattenArray } from './utils';
|
||||
import setAndForwardRef from './setAndForwardRef';
|
||||
import {
|
||||
isFabric,
|
||||
isJest,
|
||||
isWeb,
|
||||
shouldBeUseWeb,
|
||||
} from '../reanimated2/PlatformChecker';
|
||||
import { InlinePropManager } from './InlinePropManager';
|
||||
import { PropsFilter } from './PropsFilter';
|
||||
import {
|
||||
startWebLayoutAnimation,
|
||||
tryActivateLayoutTransition,
|
||||
configureWebLayoutAnimations,
|
||||
getReducedMotionFromConfig,
|
||||
} from '../reanimated2/layoutReanimation/web';
|
||||
import type { CustomConfig } from '../reanimated2/layoutReanimation/web/config';
|
||||
import type { FlatList, FlatListProps } from 'react-native';
|
||||
|
||||
const IS_WEB = isWeb();
|
||||
const IS_FABRIC = isFabric();
|
||||
import type { AnimatedProps } from '../helperTypes';
|
||||
import type { Options } from './AnimatedComponent';
|
||||
import AnimatedComponentImpl from './AnimatedComponent';
|
||||
import type {
|
||||
AnimatedComponentProps,
|
||||
InitialComponentProps,
|
||||
} from './commonTypes';
|
||||
|
||||
function onlyAnimatedStyles(styles: StyleProps[]): StyleProps[] {
|
||||
return styles.filter((style) => style?.viewDescriptors);
|
||||
}
|
||||
|
||||
function isSameAnimatedStyle(
|
||||
style1?: StyleProps,
|
||||
style2?: StyleProps
|
||||
): boolean {
|
||||
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
||||
// Instead, we can compare its viewsRefs.
|
||||
return style1?.viewsRef === style2?.viewsRef;
|
||||
}
|
||||
|
||||
const isSameAnimatedProps = isSameAnimatedStyle;
|
||||
|
||||
type Options<P> = {
|
||||
setNativeProps: (ref: AnimatedComponentRef, props: P) => void;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type AnimatableComponent<C extends ComponentType<any>> = C & {
|
||||
jsProps?: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -86,517 +29,70 @@ type Options<P> = {
|
||||
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
||||
*/
|
||||
|
||||
// Don't change the order of overloads, since such a change breaks current behavior
|
||||
export function createAnimatedComponent<P extends object>(
|
||||
component: AnimatableComponent<FunctionComponent<P>>,
|
||||
options?: Options<P>
|
||||
): FunctionComponent<AnimatedProps<P>>;
|
||||
|
||||
export function createAnimatedComponent<P extends object>(
|
||||
component: AnimatableComponent<ComponentClass<P>>,
|
||||
options?: Options<P>
|
||||
): ComponentClass<AnimatedProps<P>>;
|
||||
|
||||
export function createAnimatedComponent<P extends object>(
|
||||
// Actually ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P> but we need this overload too
|
||||
// since some external components (like FastImage) are typed just as ComponentType
|
||||
component: AnimatableComponent<ComponentType<P>>,
|
||||
options?: Options<P>
|
||||
): FunctionComponent<AnimatedProps<P>> | ComponentClass<AnimatedProps<P>>;
|
||||
|
||||
/**
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
* @deprecated Please use `Animated.FlatList` component instead of calling
|
||||
* `Animated.createAnimatedComponent(FlatList)` manually.
|
||||
*/
|
||||
// @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList
|
||||
export function createAnimatedComponent(
|
||||
component: typeof FlatList<unknown>,
|
||||
options?: Options<any>
|
||||
): ComponentClass<AnimateProps<FlatListProps<unknown>>>;
|
||||
|
||||
export function createAnimatedComponent<P extends object>(
|
||||
component: FunctionComponent<P>,
|
||||
options?: Options<P>
|
||||
): FunctionComponent<AnimateProps<P>>;
|
||||
|
||||
export function createAnimatedComponent<P extends object>(
|
||||
component: ComponentClass<P>,
|
||||
options?: Options<P>
|
||||
): ComponentClass<AnimateProps<P>>;
|
||||
component: AnimatableComponent<typeof FlatList<unknown>>,
|
||||
options?: Options<typeof FlatList<unknown>>
|
||||
): ComponentClass<AnimatedProps<FlatListProps<unknown>>>;
|
||||
|
||||
export function createAnimatedComponent(
|
||||
Component: ComponentType<InitialComponentProps>,
|
||||
Component: AnimatableComponent<ComponentType<InitialComponentProps>>,
|
||||
options?: Options<InitialComponentProps>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): any {
|
||||
invariant(
|
||||
typeof Component !== 'function' ||
|
||||
(Component.prototype && Component.prototype.isReactComponent),
|
||||
`Looks like you're passing a function component \`${Component.name}\` to \`createAnimatedComponent\` function which supports only class components. Please wrap your function component with \`React.forwardRef()\` or use a class component instead.`
|
||||
);
|
||||
|
||||
class AnimatedComponent
|
||||
extends React.Component<AnimatedComponentProps<InitialComponentProps>>
|
||||
implements IAnimatedComponentInternal
|
||||
{
|
||||
_styles: StyleProps[] | null = null;
|
||||
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||
_viewTag = -1;
|
||||
_isFirstRender = true;
|
||||
animatedStyle: { value: StyleProps } = { value: {} };
|
||||
_component: AnimatedComponentRef | HTMLElement | null = null;
|
||||
_sharedElementTransition: SharedTransition | null = null;
|
||||
_jsPropsUpdater = new JSPropsUpdater();
|
||||
_InlinePropManager = new InlinePropManager();
|
||||
_PropsFilter = new PropsFilter();
|
||||
_viewInfo?: ViewInfo;
|
||||
static displayName: string;
|
||||
static contextType = SkipEnteringContext;
|
||||
context!: React.ContextType<typeof SkipEnteringContext>;
|
||||
class AnimatedComponent extends AnimatedComponentImpl {
|
||||
static displayName = `AnimatedComponent(${
|
||||
Component.displayName || Component.name || 'Component'
|
||||
})`;
|
||||
|
||||
constructor(props: AnimatedComponentProps<InitialComponentProps>) {
|
||||
super(props);
|
||||
if (isJest()) {
|
||||
this.animatedStyle = { value: {} };
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._attachNativeEvents();
|
||||
this._jsPropsUpdater.addOnJSPropsChangeListener(this);
|
||||
this._attachAnimatedStyles();
|
||||
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
|
||||
|
||||
if (IS_WEB) {
|
||||
configureWebLayoutAnimations();
|
||||
|
||||
if (!this.props.entering) {
|
||||
this._isFirstRender = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (getReducedMotionFromConfig(this.props.entering as CustomConfig)) {
|
||||
this._isFirstRender = false;
|
||||
return;
|
||||
}
|
||||
|
||||
startWebLayoutAnimation(
|
||||
this.props,
|
||||
this._component as HTMLElement,
|
||||
LayoutAnimationType.ENTERING
|
||||
);
|
||||
}
|
||||
|
||||
this._isFirstRender = false;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this._detachNativeEvents();
|
||||
this._jsPropsUpdater.removeOnJSPropsChangeListener(this);
|
||||
this._detachStyles();
|
||||
this._InlinePropManager.detachInlineProps();
|
||||
this._sharedElementTransition?.unregisterTransition(this._viewTag);
|
||||
|
||||
if (
|
||||
IS_WEB &&
|
||||
this.props.exiting &&
|
||||
!getReducedMotionFromConfig(this.props.exiting as CustomConfig)
|
||||
) {
|
||||
startWebLayoutAnimation(
|
||||
this.props,
|
||||
this._component as HTMLElement,
|
||||
LayoutAnimationType.EXITING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_getEventViewRef() {
|
||||
// Make sure to get the scrollable node for components that implement
|
||||
// `ScrollResponder.Mixin`.
|
||||
return (this._component as AnimatedComponentRef)?.getScrollableNode
|
||||
? (this._component as AnimatedComponentRef).getScrollableNode?.()
|
||||
: this._component;
|
||||
}
|
||||
|
||||
_attachNativeEvents() {
|
||||
const node = this._getEventViewRef() as AnimatedComponentRef;
|
||||
let viewTag = null; // We set it only if needed
|
||||
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (
|
||||
has('current', prop) &&
|
||||
prop.current instanceof WorkletEventHandler
|
||||
) {
|
||||
if (viewTag === null) {
|
||||
viewTag = findNodeHandle(options?.setNativeProps ? this : node);
|
||||
}
|
||||
prop.current.registerForEvents(viewTag as number, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_detachNativeEvents() {
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (
|
||||
has('current', prop) &&
|
||||
prop.current instanceof WorkletEventHandler
|
||||
) {
|
||||
prop.current.unregisterFromEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_detachStyles() {
|
||||
if (IS_WEB && this._styles !== null) {
|
||||
for (const style of this._styles) {
|
||||
if (style?.viewsRef) {
|
||||
style.viewsRef.remove(this);
|
||||
}
|
||||
}
|
||||
} else if (this._viewTag !== -1 && this._styles !== null) {
|
||||
for (const style of this._styles) {
|
||||
style.viewDescriptors.remove(this._viewTag);
|
||||
}
|
||||
if (this.props.animatedProps?.viewDescriptors) {
|
||||
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
|
||||
}
|
||||
if (IS_FABRIC) {
|
||||
removeFromPropsRegistry(this._viewTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_reattachNativeEvents(
|
||||
prevProps: AnimatedComponentProps<InitialComponentProps>
|
||||
) {
|
||||
for (const key in prevProps) {
|
||||
const prop = this.props[key];
|
||||
if (
|
||||
has('current', prop) &&
|
||||
prop.current instanceof WorkletEventHandler &&
|
||||
prop.current.reattachNeeded
|
||||
) {
|
||||
prop.current.unregisterFromEvents();
|
||||
}
|
||||
}
|
||||
|
||||
let viewTag = null;
|
||||
|
||||
for (const key in this.props) {
|
||||
const prop = this.props[key];
|
||||
if (
|
||||
has('current', prop) &&
|
||||
prop.current instanceof WorkletEventHandler &&
|
||||
prop.current.reattachNeeded
|
||||
) {
|
||||
if (viewTag === null) {
|
||||
const node = this._getEventViewRef() as AnimatedComponentRef;
|
||||
viewTag = findNodeHandle(options?.setNativeProps ? this : node);
|
||||
}
|
||||
prop.current.registerForEvents(viewTag as number, key);
|
||||
prop.current.reattachNeeded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_updateFromNative(props: StyleProps) {
|
||||
if (options?.setNativeProps) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
options.setNativeProps(this._component as AnimatedComponentRef, props);
|
||||
} else {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
(this._component as AnimatedComponentRef)?.setNativeProps?.(props);
|
||||
}
|
||||
}
|
||||
|
||||
_getViewInfo(): ViewInfo {
|
||||
if (this._viewInfo !== undefined) {
|
||||
return this._viewInfo;
|
||||
}
|
||||
|
||||
let viewTag: number | HTMLElement | null;
|
||||
let viewName: string | null;
|
||||
let shadowNodeWrapper: ShadowNodeWrapper | null = null;
|
||||
let viewConfig;
|
||||
// Component can specify ref which should be animated when animated version of the component is created.
|
||||
// Otherwise, we animate the component itself.
|
||||
const component = (this._component as AnimatedComponentRef)
|
||||
?.getAnimatableRef
|
||||
? (this._component as AnimatedComponentRef).getAnimatableRef?.()
|
||||
: this;
|
||||
|
||||
if (IS_WEB) {
|
||||
// At this point I assume that `_setComponentRef` was already called and `_component` is set.
|
||||
// `this._component` on web represents HTMLElement of our component, that's why we use casting
|
||||
viewTag = this._component as HTMLElement;
|
||||
viewName = null;
|
||||
shadowNodeWrapper = null;
|
||||
viewConfig = null;
|
||||
} else {
|
||||
// hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
|
||||
const hostInstance = RNRenderer.findHostInstance_DEPRECATED(component);
|
||||
if (!hostInstance) {
|
||||
throw new Error(
|
||||
'[Reanimated] Cannot find host instance for this component. Maybe it renders nothing?'
|
||||
);
|
||||
}
|
||||
// we can access view tag in the same way it's accessed here https://github.com/facebook/react/blob/e3f4eb7272d4ca0ee49f27577156b57eeb07cf73/packages/react-native-renderer/src/ReactFabric.js#L146
|
||||
viewTag = hostInstance?._nativeTag;
|
||||
/**
|
||||
* RN uses viewConfig for components for storing different properties of the component(example: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js#L24).
|
||||
* The name we're looking for is in the field named uiViewClassName.
|
||||
*/
|
||||
viewName = hostInstance?.viewConfig?.uiViewClassName;
|
||||
|
||||
viewConfig = hostInstance?.viewConfig;
|
||||
|
||||
if (IS_FABRIC) {
|
||||
shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
|
||||
}
|
||||
}
|
||||
this._viewInfo = { viewTag, viewName, shadowNodeWrapper, viewConfig };
|
||||
return this._viewInfo;
|
||||
}
|
||||
|
||||
_attachAnimatedStyles() {
|
||||
const styles = this.props.style
|
||||
? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
|
||||
: [];
|
||||
const prevStyles = this._styles;
|
||||
this._styles = styles;
|
||||
|
||||
const prevAnimatedProps = this._animatedProps;
|
||||
this._animatedProps = this.props.animatedProps;
|
||||
|
||||
const { viewTag, viewName, shadowNodeWrapper, viewConfig } =
|
||||
this._getViewInfo();
|
||||
|
||||
// update UI props whitelist for this view
|
||||
const hasReanimated2Props =
|
||||
this.props.animatedProps?.viewDescriptors || styles.length;
|
||||
if (hasReanimated2Props && viewConfig) {
|
||||
adaptViewConfig(viewConfig);
|
||||
}
|
||||
|
||||
this._viewTag = viewTag as number;
|
||||
|
||||
// remove old styles
|
||||
if (prevStyles) {
|
||||
// in most of the cases, views have only a single animated style and it remains unchanged
|
||||
const hasOneSameStyle =
|
||||
styles.length === 1 &&
|
||||
prevStyles.length === 1 &&
|
||||
isSameAnimatedStyle(styles[0], prevStyles[0]);
|
||||
|
||||
if (!hasOneSameStyle) {
|
||||
// otherwise, remove each style that is not present in new styles
|
||||
for (const prevStyle of prevStyles) {
|
||||
const isPresent = styles.some((style) =>
|
||||
isSameAnimatedStyle(style, prevStyle)
|
||||
);
|
||||
if (!isPresent) {
|
||||
prevStyle.viewDescriptors.remove(viewTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
styles.forEach((style) => {
|
||||
style.viewDescriptors.add({
|
||||
tag: viewTag,
|
||||
name: viewName,
|
||||
shadowNodeWrapper,
|
||||
});
|
||||
if (isJest()) {
|
||||
/**
|
||||
* We need to connect Jest's TestObject instance whose contains just props object
|
||||
* with the updateProps() function where we update the properties of the component.
|
||||
* We can't update props object directly because TestObject contains a copy of props - look at render function:
|
||||
* const props = this._filterNonAnimatedProps(this.props);
|
||||
*/
|
||||
this.animatedStyle.value = {
|
||||
...this.animatedStyle.value,
|
||||
...style.initial.value,
|
||||
};
|
||||
style.animatedStyle.current = this.animatedStyle;
|
||||
}
|
||||
});
|
||||
|
||||
// detach old animatedProps
|
||||
if (
|
||||
prevAnimatedProps &&
|
||||
!isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)
|
||||
) {
|
||||
prevAnimatedProps.viewDescriptors!.remove(viewTag as number);
|
||||
}
|
||||
|
||||
// attach animatedProps property
|
||||
if (this.props.animatedProps?.viewDescriptors) {
|
||||
this.props.animatedProps.viewDescriptors.add({
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
tag: viewTag as number,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
name: viewName!,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
shadowNodeWrapper: shadowNodeWrapper!,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(
|
||||
prevProps: AnimatedComponentProps<InitialComponentProps>,
|
||||
_prevState: Readonly<unknown>,
|
||||
// This type comes straight from React
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
snapshot: DOMRect | null
|
||||
) {
|
||||
this._reattachNativeEvents(prevProps);
|
||||
this._attachAnimatedStyles();
|
||||
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
|
||||
|
||||
// Snapshot won't be undefined because it comes from getSnapshotBeforeUpdate method
|
||||
if (
|
||||
IS_WEB &&
|
||||
snapshot !== null &&
|
||||
this.props.layout &&
|
||||
!getReducedMotionFromConfig(this.props.layout as CustomConfig)
|
||||
) {
|
||||
tryActivateLayoutTransition(
|
||||
this.props,
|
||||
this._component as HTMLElement,
|
||||
snapshot
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_setComponentRef = setAndForwardRef<Component | HTMLElement>({
|
||||
getForwardedRef: () =>
|
||||
this.props.forwardedRef as MutableRefObject<
|
||||
Component<Record<string, unknown>, Record<string, unknown>, unknown>
|
||||
>,
|
||||
setLocalRef: (ref) => {
|
||||
// TODO update config
|
||||
|
||||
const tag = IS_WEB
|
||||
? (ref as HTMLElement)
|
||||
: findNodeHandle(ref as Component);
|
||||
|
||||
const { layout, entering, exiting, sharedTransitionTag } = this.props;
|
||||
if (
|
||||
(layout || entering || exiting || sharedTransitionTag) &&
|
||||
tag != null
|
||||
) {
|
||||
if (!shouldBeUseWeb()) {
|
||||
enableLayoutAnimations(true, false);
|
||||
}
|
||||
if (layout) {
|
||||
configureLayoutAnimations(
|
||||
tag,
|
||||
LayoutAnimationType.LAYOUT,
|
||||
maybeBuild(
|
||||
layout,
|
||||
undefined /* We don't have to warn user if style has common properties with animation for LAYOUT */,
|
||||
AnimatedComponent.displayName
|
||||
)
|
||||
);
|
||||
}
|
||||
const skipEntering = this.context?.current;
|
||||
if (entering && !skipEntering) {
|
||||
configureLayoutAnimations(
|
||||
tag,
|
||||
LayoutAnimationType.ENTERING,
|
||||
maybeBuild(
|
||||
entering,
|
||||
this.props?.style,
|
||||
AnimatedComponent.displayName
|
||||
)
|
||||
);
|
||||
}
|
||||
if (exiting) {
|
||||
const reduceMotionInExiting =
|
||||
'getReduceMotion' in exiting &&
|
||||
typeof exiting.getReduceMotion === 'function'
|
||||
? getReduceMotionFromConfig(exiting.getReduceMotion())
|
||||
: getReduceMotionFromConfig();
|
||||
if (!reduceMotionInExiting) {
|
||||
configureLayoutAnimations(
|
||||
tag,
|
||||
LayoutAnimationType.EXITING,
|
||||
maybeBuild(
|
||||
exiting,
|
||||
this.props?.style,
|
||||
AnimatedComponent.displayName
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (sharedTransitionTag && !IS_WEB) {
|
||||
const sharedElementTransition =
|
||||
this.props.sharedTransitionStyle ?? new SharedTransition();
|
||||
const reduceMotionInTransition = getReduceMotionFromConfig(
|
||||
sharedElementTransition.getReduceMotion()
|
||||
);
|
||||
if (!reduceMotionInTransition) {
|
||||
sharedElementTransition.registerTransition(
|
||||
tag as number,
|
||||
sharedTransitionTag
|
||||
);
|
||||
this._sharedElementTransition = sharedElementTransition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ref !== this._component) {
|
||||
this._component = ref;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// This is a component lifecycle method from React, therefore we are not calling it directly.
|
||||
// It is called before the component gets rerendered. This way we can access components' position before it changed
|
||||
// and later on, in componentDidUpdate, calculate translation for layout transition.
|
||||
getSnapshotBeforeUpdate() {
|
||||
if (
|
||||
(this._component as HTMLElement).getBoundingClientRect !== undefined
|
||||
) {
|
||||
return (this._component as HTMLElement).getBoundingClientRect();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
const props = this._PropsFilter.filterNonAnimatedProps(this);
|
||||
|
||||
if (isJest()) {
|
||||
props.animatedStyle = this.animatedStyle;
|
||||
}
|
||||
|
||||
// Layout animations on web are set inside `componentDidMount` method, which is called after first render.
|
||||
// Because of that we can encounter a situation in which component is visible for a short amount of time, and later on animation triggers.
|
||||
// I've tested that on various browsers and devices and it did not happen to me. To be sure that it won't happen to someone else,
|
||||
// I've decided to hide component at first render. Its visibility is reset in `componentDidMount`.
|
||||
if (
|
||||
this._isFirstRender &&
|
||||
IS_WEB &&
|
||||
props.entering &&
|
||||
!getReducedMotionFromConfig(props.entering as CustomConfig)
|
||||
) {
|
||||
props.style = {
|
||||
...(props.style ?? {}),
|
||||
visibility: 'hidden', // Hide component until `componentDidMount` triggers
|
||||
};
|
||||
}
|
||||
|
||||
const platformProps = Platform.select({
|
||||
web: {},
|
||||
default: { collapsable: false },
|
||||
});
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
// Casting is used here, because ref can be null - in that case it cannot be assigned to HTMLElement.
|
||||
// After spending some time trying to figure out what to do with this problem, we decided to leave it this way
|
||||
ref={this._setComponentRef as (ref: Component) => void}
|
||||
{...platformProps}
|
||||
/>
|
||||
);
|
||||
// User can override component-defined jsProps via options
|
||||
const jsProps = options?.jsProps ?? Component.jsProps;
|
||||
const modifiedOptions = jsProps?.length
|
||||
? { ...options, jsProps }
|
||||
: options;
|
||||
super(Component, props, AnimatedComponent.displayName, modifiedOptions);
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedComponent.displayName = `AnimatedComponent(${
|
||||
Component.displayName || Component.name || 'Component'
|
||||
})`;
|
||||
|
||||
return React.forwardRef<Component>((props, ref) => {
|
||||
const animatedComponent = (
|
||||
props: AnimatedComponentProps & { ref: Ref<AnimatedComponent> }
|
||||
) => {
|
||||
return (
|
||||
<AnimatedComponent
|
||||
{...props}
|
||||
{...(ref === null ? null : { forwardedRef: ref })}
|
||||
// Needed to prevent react from signing AnimatedComponent to the ref
|
||||
// (we want to handle the ref assignment in the AnimatedComponent)
|
||||
ref={null}
|
||||
{...(props.ref === null ? null : { forwardedRef: props.ref })}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
animatedComponent.displayName =
|
||||
Component.displayName || Component.name || 'Component';
|
||||
|
||||
return animatedComponent;
|
||||
}
|
||||
|
||||
Generated
Vendored
+26
-1
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
import type { StyleProps } from '../commonTypes';
|
||||
import type { CSSStyle } from '../css';
|
||||
import type { NestedArray } from './commonTypes';
|
||||
|
||||
export function flattenArray<T>(array: NestedArray<T>): T[] {
|
||||
@@ -23,7 +25,7 @@ export function flattenArray<T>(array: NestedArray<T>): T[] {
|
||||
export const has = <K extends string>(
|
||||
key: K,
|
||||
x: unknown
|
||||
): x is typeof x & { [key in K]: unknown } => {
|
||||
): x is { [key in K]: unknown } => {
|
||||
if (typeof x === 'function' || typeof x === 'object') {
|
||||
if (x === null || x === undefined) {
|
||||
return false;
|
||||
@@ -33,3 +35,26 @@ export const has = <K extends string>(
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
type FilteredStyles = {
|
||||
cssStyle: CSSStyle | null;
|
||||
animatedStyles: StyleProps[];
|
||||
};
|
||||
|
||||
export function filterStyles(styles: StyleProps[] | undefined): FilteredStyles {
|
||||
if (!styles) {
|
||||
return { animatedStyles: [], cssStyle: null };
|
||||
}
|
||||
|
||||
return styles.reduce<FilteredStyles>(
|
||||
({ animatedStyles, cssStyle }, style) => {
|
||||
if (style?.viewDescriptors) {
|
||||
animatedStyles.push(style);
|
||||
} else {
|
||||
cssStyle = { ...cssStyle, ...style } as CSSStyle;
|
||||
}
|
||||
return { animatedStyles, cssStyle };
|
||||
},
|
||||
{ animatedStyles: [], cssStyle: null }
|
||||
);
|
||||
}
|
||||
|
||||
+296
-1
@@ -1,5 +1,300 @@
|
||||
'use strict';
|
||||
|
||||
import './publicGlobals';
|
||||
|
||||
import { initializeReanimatedModule } from './initializers';
|
||||
import { ReanimatedModule } from './ReanimatedModule';
|
||||
|
||||
// TODO: Specify the initialization pipeline since now there's no
|
||||
// universal source of truth for it.
|
||||
initializeReanimatedModule(ReanimatedModule);
|
||||
|
||||
// eslint-disable-next-line import/first
|
||||
import * as Animated from './Animated';
|
||||
|
||||
export * from './reanimated2';
|
||||
export default Animated;
|
||||
|
||||
export { createAnimatedComponent } from './Animated';
|
||||
export type {
|
||||
DecayAnimation,
|
||||
DelayAnimation,
|
||||
RepeatAnimation,
|
||||
SequenceAnimation,
|
||||
SpringAnimation,
|
||||
StyleLayoutAnimation,
|
||||
TimingAnimation,
|
||||
WithDecayConfig,
|
||||
WithSpringConfig,
|
||||
WithTimingConfig,
|
||||
} from './animation';
|
||||
export {
|
||||
cancelAnimation,
|
||||
defineAnimation,
|
||||
GentleSpringConfig,
|
||||
GentleSpringConfigWithDuration,
|
||||
Reanimated3DefaultSpringConfig,
|
||||
Reanimated3DefaultSpringConfigWithDuration,
|
||||
SnappySpringConfig,
|
||||
SnappySpringConfigWithDuration,
|
||||
WigglySpringConfig,
|
||||
WigglySpringConfigWithDuration,
|
||||
withClamp,
|
||||
withDecay,
|
||||
withDelay,
|
||||
withRepeat,
|
||||
withSequence,
|
||||
withSpring,
|
||||
withTiming,
|
||||
} from './animation';
|
||||
export type { ParsedColorArray } from './Colors';
|
||||
export { convertToRGBA, isColor } from './Colors';
|
||||
export { processColor, ReanimatedLogLevel } from './common';
|
||||
export type {
|
||||
AnimatableValue,
|
||||
AnimatableValueObject,
|
||||
AnimatedKeyboardInfo,
|
||||
AnimatedKeyboardOptions,
|
||||
AnimatedSensor,
|
||||
AnimatedStyle,
|
||||
AnimatedTransform,
|
||||
Animation,
|
||||
AnimationCallback,
|
||||
AnimationObject,
|
||||
BaseLayoutAnimationConfig,
|
||||
EasingFunction,
|
||||
EntryAnimationsValues,
|
||||
EntryExitAnimationFunction,
|
||||
ExitAnimationsValues,
|
||||
IEntryExitAnimationBuilder,
|
||||
ILayoutAnimationBuilder,
|
||||
KeyframeProps,
|
||||
LayoutAnimation,
|
||||
LayoutAnimationFunction,
|
||||
LayoutAnimationStartFunction,
|
||||
LayoutAnimationValues as LayoutAnimationsValues,
|
||||
LayoutAnimationType,
|
||||
MeasuredDimensions,
|
||||
SensorConfig,
|
||||
SharedValue,
|
||||
StyleProps,
|
||||
TransformArrayItem,
|
||||
Value3D,
|
||||
ValueRotation,
|
||||
} from './commonTypes';
|
||||
export {
|
||||
InterfaceOrientation,
|
||||
IOSReferenceFrame,
|
||||
KeyboardState,
|
||||
ReduceMotion,
|
||||
SensorType,
|
||||
} from './commonTypes';
|
||||
export type { FlatListPropsWithLayout } from './component/FlatList';
|
||||
export { LayoutAnimationConfig } from './component/LayoutAnimationConfig';
|
||||
export type { PerformanceMonitorProps } from './component/PerformanceMonitor';
|
||||
export { PerformanceMonitor } from './component/PerformanceMonitor';
|
||||
export { ReducedMotionConfig } from './component/ReducedMotionConfig';
|
||||
export type { AnimatedScrollViewProps } from './component/ScrollView';
|
||||
export { configureReanimatedLogger } from './ConfigHelper';
|
||||
export {
|
||||
enableLayoutAnimations,
|
||||
getViewProp,
|
||||
isConfigured,
|
||||
isReanimated3,
|
||||
makeMutable,
|
||||
} from './core';
|
||||
export * from './css';
|
||||
export type { EasingFunctionFactory } from './Easing';
|
||||
export { Easing } from './Easing';
|
||||
export { getStaticFeatureFlag, setDynamicFeatureFlag } from './featureFlags';
|
||||
export type { FrameInfo } from './frameCallback';
|
||||
export type { AnimatedProps, EntryOrExitLayoutType } from './helperTypes';
|
||||
export type {
|
||||
AnimatedRef,
|
||||
DerivedValue,
|
||||
EventHandler,
|
||||
EventHandlerProcessed,
|
||||
FrameCallback,
|
||||
ReanimatedEvent,
|
||||
ScrollEvent,
|
||||
ScrollHandler,
|
||||
ScrollHandlerProcessed,
|
||||
ScrollHandlers,
|
||||
UseHandlerContext,
|
||||
} from './hook';
|
||||
export {
|
||||
useAnimatedKeyboard,
|
||||
useAnimatedProps,
|
||||
useAnimatedReaction,
|
||||
useAnimatedRef,
|
||||
useAnimatedScrollHandler,
|
||||
useAnimatedSensor,
|
||||
useAnimatedStyle,
|
||||
useComposedEventHandler,
|
||||
useDerivedValue,
|
||||
useEvent,
|
||||
useFrameCallback,
|
||||
useHandler,
|
||||
useReducedMotion,
|
||||
useScrollOffset,
|
||||
/** @deprecated Please use {@link useScrollOffset} instead. */
|
||||
useScrollOffset as useScrollViewOffset,
|
||||
useSharedValue,
|
||||
} from './hook';
|
||||
export type {
|
||||
InterpolateConfig,
|
||||
InterpolateHSV,
|
||||
InterpolateRGB,
|
||||
InterpolationOptions,
|
||||
} from './interpolateColor';
|
||||
export {
|
||||
ColorSpace,
|
||||
/** @deprecated Please use {@link Extrapolation} instead. */
|
||||
Extrapolate,
|
||||
interpolateColor,
|
||||
useInterpolateConfig,
|
||||
} from './interpolateColor';
|
||||
export type { ExtrapolationConfig, ExtrapolationType } from './interpolation';
|
||||
export { clamp, Extrapolation, interpolate } from './interpolation';
|
||||
export { isSharedValue } from './isSharedValue';
|
||||
export {
|
||||
advanceAnimationByFrame,
|
||||
advanceAnimationByTime,
|
||||
getAnimatedStyle,
|
||||
setUpTests,
|
||||
withReanimatedTimer,
|
||||
} from './jestUtils';
|
||||
export type { ReanimatedKeyframe } from './layoutReanimation';
|
||||
export {
|
||||
BaseAnimationBuilder,
|
||||
// Bounce
|
||||
BounceIn,
|
||||
BounceInDown,
|
||||
BounceInLeft,
|
||||
BounceInRight,
|
||||
BounceInUp,
|
||||
BounceOut,
|
||||
BounceOutDown,
|
||||
BounceOutLeft,
|
||||
BounceOutRight,
|
||||
BounceOutUp,
|
||||
ComplexAnimationBuilder,
|
||||
CurvedTransition,
|
||||
EntryExitTransition,
|
||||
// Fade
|
||||
FadeIn,
|
||||
FadeInDown,
|
||||
FadeInLeft,
|
||||
FadeInRight,
|
||||
FadeInUp,
|
||||
FadeOut,
|
||||
FadeOutDown,
|
||||
FadeOutLeft,
|
||||
FadeOutRight,
|
||||
FadeOutUp,
|
||||
FadingTransition,
|
||||
FlipInEasyX,
|
||||
FlipInEasyY,
|
||||
FlipInXDown,
|
||||
// Flip
|
||||
FlipInXUp,
|
||||
FlipInYLeft,
|
||||
FlipInYRight,
|
||||
FlipOutEasyX,
|
||||
FlipOutEasyY,
|
||||
FlipOutXDown,
|
||||
FlipOutXUp,
|
||||
FlipOutYLeft,
|
||||
FlipOutYRight,
|
||||
JumpingTransition,
|
||||
Keyframe,
|
||||
// Transitions
|
||||
Layout,
|
||||
LightSpeedInLeft,
|
||||
// Lightspeed
|
||||
LightSpeedInRight,
|
||||
LightSpeedOutLeft,
|
||||
LightSpeedOutRight,
|
||||
LinearTransition,
|
||||
// Pinwheel
|
||||
PinwheelIn,
|
||||
PinwheelOut,
|
||||
// Roll
|
||||
RollInLeft,
|
||||
RollInRight,
|
||||
RollOutLeft,
|
||||
RollOutRight,
|
||||
// Rotate
|
||||
RotateInDownLeft,
|
||||
RotateInDownRight,
|
||||
RotateInUpLeft,
|
||||
RotateInUpRight,
|
||||
RotateOutDownLeft,
|
||||
RotateOutDownRight,
|
||||
RotateOutUpLeft,
|
||||
RotateOutUpRight,
|
||||
SequencedTransition,
|
||||
SlideInDown,
|
||||
SlideInLeft,
|
||||
// Slide
|
||||
SlideInRight,
|
||||
SlideInUp,
|
||||
SlideOutDown,
|
||||
SlideOutLeft,
|
||||
SlideOutRight,
|
||||
SlideOutUp,
|
||||
// Stretch
|
||||
StretchInX,
|
||||
StretchInY,
|
||||
StretchOutX,
|
||||
StretchOutY,
|
||||
// Zoom
|
||||
ZoomIn,
|
||||
ZoomInDown,
|
||||
ZoomInEasyDown,
|
||||
ZoomInEasyUp,
|
||||
ZoomInLeft,
|
||||
ZoomInRight,
|
||||
ZoomInRotate,
|
||||
ZoomInUp,
|
||||
ZoomOut,
|
||||
ZoomOutDown,
|
||||
ZoomOutEasyDown,
|
||||
ZoomOutEasyUp,
|
||||
ZoomOutLeft,
|
||||
ZoomOutRight,
|
||||
ZoomOutRotate,
|
||||
ZoomOutUp,
|
||||
} from './layoutReanimation';
|
||||
export { startMapper, stopMapper } from './mappers';
|
||||
export { jsVersion as reanimatedVersion } from './platform-specific/jsVersion';
|
||||
export type { ComponentCoords } from './platformFunctions';
|
||||
export {
|
||||
dispatchCommand,
|
||||
getRelativeCoords,
|
||||
measure,
|
||||
scrollTo,
|
||||
setGestureState,
|
||||
setNativeProps,
|
||||
} from './platformFunctions';
|
||||
export { getUseOfValueInStyleWarning } from './pluginUtils';
|
||||
export { createAnimatedPropAdapter } from './PropAdapters';
|
||||
export type {
|
||||
AnimatedScreenTransition,
|
||||
GoBackGesture,
|
||||
ScreenTransitionConfig,
|
||||
} from './screenTransition';
|
||||
export {
|
||||
finishScreenTransition,
|
||||
ScreenTransition,
|
||||
startScreenTransition,
|
||||
} from './screenTransition';
|
||||
export type { WorkletRuntime } from './workletFunctions';
|
||||
export {
|
||||
createWorkletRuntime,
|
||||
executeOnUIRuntimeSync,
|
||||
isWorkletFunction,
|
||||
makeShareableCloneRecursive,
|
||||
runOnJS,
|
||||
runOnRuntime,
|
||||
runOnUI,
|
||||
} from './workletFunctions';
|
||||
|
||||
Generated
+19
-63
@@ -25,7 +25,7 @@
|
||||
"react-native": "0.81.5",
|
||||
"react-native-gesture-handler": "~2.28.0",
|
||||
"react-native-maps": "1.20.1",
|
||||
"react-native-reanimated": "~3.6.0",
|
||||
"react-native-reanimated": "~4.1.1",
|
||||
"react-native-safe-area-context": "~5.6.0",
|
||||
"react-native-screens": "~4.16.0",
|
||||
"react-native-web": "^0.21.0",
|
||||
@@ -475,41 +475,6 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-proposal-nullish-coalescing-operator": {
|
||||
"version": "7.18.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
|
||||
"integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
|
||||
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.18.6",
|
||||
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-proposal-optional-chaining": {
|
||||
"version": "7.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz",
|
||||
"integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==",
|
||||
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.20.2",
|
||||
"@babel/helper-skip-transparent-expression-wrappers": "^7.20.0",
|
||||
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-syntax-async-generators": {
|
||||
"version": "7.8.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
|
||||
@@ -1053,20 +1018,6 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-object-assign": {
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.27.1.tgz",
|
||||
"integrity": "sha512-LP6tsnirA6iy13uBKiYgjJsfQrodmlSrpZModtlo1Vk8sOO68gfo7dfA9TGJyEgxTiO7czK4EGZm8FJEZtk4kQ==",
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.27.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-object-rest-spread": {
|
||||
"version": "7.28.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.6.tgz",
|
||||
@@ -6998,24 +6949,29 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-reanimated": {
|
||||
"version": "3.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.6.3.tgz",
|
||||
"integrity": "sha512-2KkkPozoIvDbJcHuf8qeyoLROXQxizSi+2CTCkuNVkVZOxxY4B0Omvgq61aOQhSZUh/649x1YHoAaTyGMGDJUw==",
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-4.1.6.tgz",
|
||||
"integrity": "sha512-F+ZJBYiok/6Jzp1re75F/9aLzkgoQCOh4yxrnwATa8392RvM3kx+fiXXFvwcgE59v48lMwd9q0nzF1oJLXpfxQ==",
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"convert-source-map": "^2.0.0",
|
||||
"invariant": "^2.2.4"
|
||||
"react-native-is-edge-to-edge": "^1.2.1",
|
||||
"semver": "7.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.0.0-0",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.0.0-0",
|
||||
"@babel/plugin-transform-shorthand-properties": "^7.0.0-0",
|
||||
"@babel/plugin-transform-template-literals": "^7.0.0-0",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
"react-native": "*",
|
||||
"react-native-worklets": ">=0.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-reanimated/node_modules/semver": {
|
||||
"version": "7.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-safe-area-context": {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"react-native": "0.81.5",
|
||||
"react-native-gesture-handler": "~2.28.0",
|
||||
"react-native-maps": "1.20.1",
|
||||
"react-native-reanimated": "~3.6.0",
|
||||
"react-native-reanimated": "~4.1.1",
|
||||
"react-native-safe-area-context": "~5.6.0",
|
||||
"react-native-screens": "~4.16.0",
|
||||
"react-native-web": "^0.21.0",
|
||||
|
||||
Reference in New Issue
Block a user