chore: update map
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/icon.png",
|
||||||
"userInterfaceStyle": "dark",
|
"userInterfaceStyle": "dark",
|
||||||
"newArchEnabled": false,
|
"newArchEnabled": true,
|
||||||
"splash": {
|
"splash": {
|
||||||
"image": "./assets/splash-icon.png",
|
"image": "./assets/splash-icon.png",
|
||||||
"resizeMode": "contain",
|
"resizeMode": "contain",
|
||||||
|
|||||||
+18
-62
@@ -441,41 +441,6 @@
|
|||||||
"@babel/core": "^7.0.0-0"
|
"@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": {
|
"node_modules/@babel/plugin-syntax-async-generators": {
|
||||||
"version": "7.8.4",
|
"version": "7.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
|
"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"
|
"@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": {
|
"node_modules/@babel/plugin-transform-object-rest-spread": {
|
||||||
"version": "7.28.6",
|
"version": "7.28.6",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.6.tgz",
|
"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": {
|
"node_modules/react-native-reanimated": {
|
||||||
"version": "3.6.3",
|
"version": "4.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-4.1.6.tgz",
|
||||||
"integrity": "sha512-2KkkPozoIvDbJcHuf8qeyoLROXQxizSi+2CTCkuNVkVZOxxY4B0Omvgq61aOQhSZUh/649x1YHoAaTyGMGDJUw==",
|
"integrity": "sha512-F+ZJBYiok/6Jzp1re75F/9aLzkgoQCOh4yxrnwATa8392RvM3kx+fiXXFvwcgE59v48lMwd9q0nzF1oJLXpfxQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
"react-native-is-edge-to-edge": "^1.2.1",
|
||||||
"@babel/preset-typescript": "^7.16.7",
|
"semver": "7.7.2"
|
||||||
"convert-source-map": "^2.0.0",
|
|
||||||
"invariant": "^2.2.4"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0",
|
"@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": "*",
|
||||||
"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": {
|
"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%">
|
<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
|
> Reanimated 4 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.
|
|
||||||
|
|
||||||
### Nightly CI state
|
### 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/npm-reanimated-publish-nightly.yml)
|
||||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/build-monorepo-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)
|
||||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-static-framework-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/check-react-native-nightly.yml)
|
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/reanimated-compatibility-check-nightly.yml)
|
||||||
[](https://github.com/software-mansion/react-native-reanimated/actions/workflows/check-expo-dev-client-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/check-TS-react-native.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/build-v8-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/build-on-windows-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/detect-broken-urls-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
|
## 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.
|
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
|
## Documentation
|
||||||
|
|
||||||
@@ -35,8 +34,8 @@ Check out our dedicated documentation page for info about this library, API refe
|
|||||||
|
|
||||||
## Examples
|
## 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.
|
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/ directory README for installation instructions.
|
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
|
## License
|
||||||
|
|
||||||
@@ -49,3 +48,11 @@ This project has been built and is maintained thanks to the support from [Shopif
|
|||||||
[](https://shopify.com)
|
[](https://shopify.com)
|
||||||
[](https://expo.io)
|
[](https://expo.io)
|
||||||
[](https://swmansion.com)
|
[](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")))
|
reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||||
$config = find_config()
|
$config = find_config()
|
||||||
assert_latest_react_native_with_new_architecture($config, reanimated_package_json)
|
|
||||||
assert_minimal_react_native_version($config)
|
assert_minimal_react_native_version($config)
|
||||||
|
|
||||||
$new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
$new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] != '0'
|
||||||
is_release = ENV['PRODUCTION'] == '1'
|
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'
|
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' : ''
|
example_flag = $config[:is_reanimated_example_app] ? '-DIS_REANIMATED_EXAMPLE_APP' : ''
|
||||||
version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"]
|
version_flags = "-DREACT_NATIVE_MINOR_VERSION=#{$config[:react_native_minor_version]} -DREANIMATED_VERSION=#{reanimated_package_json['version']}"
|
||||||
debug_flag = is_release ? '-DNDEBUG' : ''
|
ios_min_version = '13.4'
|
||||||
ios_min_version = $config[:react_native_minor_version] >= 73 ? '13.4' : '9.0'
|
|
||||||
|
|
||||||
def self.install_modules_dependencies_legacy(s)
|
# Directory in which data for further processing for clangd will be stored.
|
||||||
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
compilation_metadata_dir = "CompilationDatabase"
|
||||||
s.dependency "React-Core"
|
# We want generate the metadata only within the monorepo of Reanimated.
|
||||||
if $new_arch_enabled
|
compilation_metadata_generation_flag = $config[:is_reanimated_example_app] ? "-gen-cdb-fragment-path #{compilation_metadata_dir}" : ''
|
||||||
s.dependency "React-RCTFabric"
|
|
||||||
s.dependency "React-Codegen"
|
feature_flags = "-DREANIMATED_FEATURE_FLAGS=\"#{get_static_feature_flags()}\""
|
||||||
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
|
|
||||||
|
|
||||||
Pod::Spec.new do |s|
|
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.homepage = "https://github.com/software-mansion/react-native-reanimated"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.author = { "author" => "author@domain.cn" }
|
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 = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }
|
||||||
|
|
||||||
s.source_files = [
|
s.dependency "RNWorklets"
|
||||||
"apple/**/*.{mm,h,m}",
|
|
||||||
"Common/cpp/**/*.{cpp,h}"
|
|
||||||
]
|
|
||||||
|
|
||||||
s.preserve_paths = [
|
s.subspec "reanimated" do |ss|
|
||||||
"Common/cpp/hidden_headers/**"
|
ss.source_files = "Common/cpp/reanimated/**/*.{cpp,h}"
|
||||||
]
|
ss.header_dir = "reanimated"
|
||||||
|
ss.header_mappings_dir = "Common/cpp/reanimated"
|
||||||
|
|
||||||
gcc_debug_definitions = "$(inherited)"
|
ss.subspec "apple" do |sss|
|
||||||
if $config[:react_native_minor_version] >= 73 || !is_release
|
sss.source_files = "apple/reanimated/**/*.{mm,h,m}"
|
||||||
gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1"
|
sss.header_dir = "reanimated"
|
||||||
|
sss.header_mappings_dir = "apple/reanimated"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
s.pod_target_xcconfig = {
|
s.pod_target_xcconfig = {
|
||||||
"USE_HEADERMAP" => "YES",
|
"USE_HEADERMAP" => "YES",
|
||||||
"DEFINES_MODULE" => "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\"",
|
"HEADER_SEARCH_PATHS" => [
|
||||||
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
|
'"$(PODS_TARGET_SRCROOT)/ReactCommon"',
|
||||||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
'"$(PODS_TARGET_SRCROOT)"',
|
||||||
"GCC_PREPROCESSOR_DEFINITIONS[config=Debug]" => gcc_debug_definitions,
|
'"$(PODS_ROOT)/RCT-Folly"',
|
||||||
"GCC_PREPROCESSOR_DEFINITIONS[config=Release]" => "$(inherited) NDEBUG=1",
|
'"$(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 = {
|
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]}\"",
|
"HEADER_SEARCH_PATHS" => [
|
||||||
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags + " " + example_flag + " " + version_flag + " " + debug_flag
|
'"$(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.requires_arc = true
|
||||||
s.dependency "ReactCommon/turbomodule/core"
|
|
||||||
if defined?(install_modules_dependencies()) != nil
|
install_modules_dependencies(s)
|
||||||
install_modules_dependencies(s)
|
|
||||||
else
|
s.dependency 'React-jsi'
|
||||||
install_modules_dependencies_legacy(s)
|
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
||||||
|
if using_hermes && !$config[:is_tvos_target]
|
||||||
|
s.dependency 'React-hermes'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+76
-293
@@ -1,319 +1,102 @@
|
|||||||
project(Reanimated)
|
project(Reanimated)
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73)
|
|
||||||
set (CMAKE_CXX_STANDARD 20)
|
|
||||||
else()
|
|
||||||
set (CMAKE_CXX_STANDARD 17)
|
|
||||||
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"
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
# default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections
|
||||||
include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
|
# -funwind-tables -fstack-protector-strong -no-canonical-prefixes
|
||||||
add_compile_options(${folly_FLAGS})
|
# -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"
|
||||||
else()
|
include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
|
||||||
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")
|
add_compile_options(${folly_FLAGS})
|
||||||
string(APPEND CMAKE_CXX_FLAGS " ${folly_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
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(${REANIMATED_PROFILING})
|
||||||
|
string(APPEND CMAKE_CXX_FLAGS " -DREANIMATED_PROFILING")
|
||||||
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${IS_REANIMATED_EXAMPLE_APP})
|
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()
|
endif()
|
||||||
|
|
||||||
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
set(ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp")
|
||||||
|
set(COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp")
|
||||||
|
|
||||||
set (PACKAGE_NAME "reanimated")
|
file(GLOB_RECURSE REANIMATED_COMMON_CPP_SOURCES CONFIGURE_DEPENDS
|
||||||
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
"${COMMON_CPP_DIR}/reanimated/*.cpp")
|
||||||
set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
|
file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS
|
||||||
set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")
|
"${ANDROID_CPP_DIR}/reanimated/*.cpp")
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES_COMMON CONFIGURE_DEPENDS "${COMMON_SRC_DIR}/cpp/**.cpp")
|
find_package(fbjni REQUIRED CONFIG)
|
||||||
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${SRC_DIR}/main/cpp/**.cpp")
|
find_package(ReactAndroid REQUIRED CONFIG)
|
||||||
|
|
||||||
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 71)
|
add_library(reanimated SHARED ${REANIMATED_COMMON_CPP_SOURCES}
|
||||||
# Consume shared libraries and headers from prefabs
|
${REANIMATED_ANDROID_CPP_SOURCES})
|
||||||
find_package(fbjni REQUIRED CONFIG)
|
|
||||||
find_package(ReactAndroid REQUIRED CONFIG)
|
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
|
||||||
if(${JS_RUNTIME} STREQUAL "hermes")
|
include(
|
||||||
find_package(hermes-engine REQUIRED CONFIG)
|
"${REACT_NATIVE_DIR}/ReactCommon/cmake-utils/react-native-flags.cmake")
|
||||||
endif()
|
target_compile_reactnative_options(reanimated PUBLIC)
|
||||||
else()
|
else()
|
||||||
# Consume shared libraries from found .so files
|
string(APPEND CMAKE_CXX_FLAGS
|
||||||
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
" -fexceptions -frtti -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
|
||||||
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}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(
|
|
||||||
${PACKAGE_NAME}
|
|
||||||
SHARED
|
|
||||||
${SOURCES_COMMON}
|
|
||||||
${SOURCES_ANDROID}
|
|
||||||
${INCLUDE_JSI_CPP}
|
|
||||||
${INCLUDE_JSIDYNAMIC_CPP}
|
|
||||||
)
|
|
||||||
|
|
||||||
# includes
|
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${PACKAGE_NAME}
|
reanimated
|
||||||
PRIVATE
|
PRIVATE "${COMMON_CPP_DIR}"
|
||||||
"${COMMON_SRC_DIR}/cpp/AnimatedSensor"
|
"${ANDROID_CPP_DIR}"
|
||||||
"${COMMON_SRC_DIR}/cpp/Fabric"
|
"${REACT_NATIVE_DIR}/ReactCommon"
|
||||||
"${COMMON_SRC_DIR}/cpp/hidden_headers"
|
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
|
||||||
"${COMMON_SRC_DIR}/cpp/LayoutAnimations"
|
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
||||||
"${COMMON_SRC_DIR}/cpp/NativeModules"
|
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
||||||
"${COMMON_SRC_DIR}/cpp/ReanimatedRuntime"
|
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
||||||
"${COMMON_SRC_DIR}/cpp/Registries"
|
"${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
|
||||||
"${COMMON_SRC_DIR}/cpp/SharedItems"
|
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
||||||
"${COMMON_SRC_DIR}/cpp/Tools"
|
"${REACT_NATIVE_WORKLETS_DIR}/Common/cpp"
|
||||||
"${SRC_DIR}/main/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)
|
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
target_include_directories(
|
# remove dead code sections
|
||||||
${PACKAGE_NAME}
|
set_target_properties(reanimated PROPERTIES LINK_FLAGS "-Wl,--gc-sections")
|
||||||
PRIVATE
|
|
||||||
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
target_link_libraries(reanimated log ReactAndroid::jsi fbjni::fbjni android
|
||||||
"${REACT_NATIVE_DIR}/ReactCommon"
|
worklets)
|
||||||
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
|
||||||
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
||||||
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
target_link_libraries(reanimated ReactAndroid::reactnative)
|
||||||
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
file(GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR})
|
target_link_libraries(reanimated ReactAndroid::react_nativemodule_core)
|
||||||
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"
|
|
||||||
)
|
|
||||||
endif()
|
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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
+1
@@ -1,2 +1,3 @@
|
|||||||
-keep class com.swmansion.reanimated.** { *; }
|
-keep class com.swmansion.reanimated.** { *; }
|
||||||
-keep class com.facebook.react.turbomodule.** { *; }
|
-keep class com.facebook.react.turbomodule.** { *; }
|
||||||
|
-keep class com.facebook.react.fabric.** { *; }
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ apply plugin: 'com.diffplug.spotless'
|
|||||||
|
|
||||||
spotless {
|
spotless {
|
||||||
java {
|
java {
|
||||||
target 'src/main/java/**/*.java'
|
target 'src/**/*.java'
|
||||||
googleJavaFormat()
|
googleJavaFormat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
Vendored
+1
-4
@@ -1,5 +1,2 @@
|
|||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
|
||||||
package="com.swmansion.reanimated">
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
|
|||||||
Generated
Vendored
+94
-328
@@ -1,103 +1,49 @@
|
|||||||
package com.swmansion.reanimated;
|
package com.swmansion.reanimated;
|
||||||
|
|
||||||
import static java.lang.Float.NaN;
|
import android.os.SystemClock;
|
||||||
|
import androidx.tracing.Trace;
|
||||||
import android.view.View;
|
|
||||||
import com.facebook.react.bridge.Arguments;
|
|
||||||
import com.facebook.react.bridge.GuardedRunnable;
|
|
||||||
import com.facebook.react.bridge.JavaOnlyMap;
|
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactContext;
|
import com.facebook.react.bridge.UIManager;
|
||||||
import com.facebook.react.bridge.ReadableArray;
|
|
||||||
import com.facebook.react.bridge.ReadableMap;
|
|
||||||
import com.facebook.react.bridge.ReadableType;
|
|
||||||
import com.facebook.react.bridge.UiThreadUtil;
|
import com.facebook.react.bridge.UiThreadUtil;
|
||||||
import com.facebook.react.bridge.WritableArray;
|
|
||||||
import com.facebook.react.bridge.WritableMap;
|
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.DeviceEventManagerModule;
|
||||||
import com.facebook.react.modules.core.ReactChoreographer;
|
import com.facebook.react.modules.core.ReactChoreographer;
|
||||||
import com.facebook.react.uimanager.GuardedFrameCallback;
|
import com.facebook.react.uimanager.GuardedFrameCallback;
|
||||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
import com.facebook.react.uimanager.UIManagerHelper;
|
||||||
import com.facebook.react.uimanager.ReactShadowNode;
|
|
||||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
|
||||||
import com.facebook.react.uimanager.UIImplementation;
|
|
||||||
import com.facebook.react.uimanager.UIManagerModule;
|
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.Event;
|
||||||
import com.facebook.react.uimanager.events.EventDispatcherListener;
|
import com.facebook.react.uimanager.events.EventDispatcherListener;
|
||||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||||
import com.swmansion.reanimated.layoutReanimation.AnimationsManager;
|
|
||||||
import com.swmansion.reanimated.nativeProxy.NoopEventHandler;
|
import com.swmansion.reanimated.nativeProxy.NoopEventHandler;
|
||||||
|
import com.swmansion.worklets.WorkletsModule;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
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.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.Semaphore;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class NodesManager implements EventDispatcherListener {
|
public class NodesManager implements EventDispatcherListener {
|
||||||
|
|
||||||
public void scrollTo(int viewTag, double x, double y, boolean animated) {
|
private Long mFirstUptime = SystemClock.uptimeMillis();
|
||||||
View view;
|
private boolean mSlowAnimationsEnabled = false;
|
||||||
try {
|
private int mAnimationsDragFactor;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnAnimationFrame {
|
public interface OnAnimationFrame {
|
||||||
void onAnimationFrame(double timestampMs);
|
void onAnimationFrame(double timestampMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnimationsManager mAnimationManager;
|
|
||||||
private final UIImplementation mUIImplementation;
|
|
||||||
private final DeviceEventManagerModule.RCTDeviceEventEmitter mEventEmitter;
|
private final DeviceEventManagerModule.RCTDeviceEventEmitter mEventEmitter;
|
||||||
private final ReactChoreographer mReactChoreographer;
|
private final ReactChoreographer mReactChoreographer;
|
||||||
private final GuardedFrameCallback mChoreographerCallback;
|
private final GuardedFrameCallback mChoreographerCallback;
|
||||||
protected final UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
protected final UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
||||||
private final AtomicBoolean mCallbackPosted = new AtomicBoolean();
|
private final AtomicBoolean mCallbackPosted = new AtomicBoolean();
|
||||||
private final ReactContext mContext;
|
|
||||||
private final UIManagerModule mUIManager;
|
|
||||||
private ReactApplicationContext mReactApplicationContext;
|
|
||||||
private RCTEventEmitter mCustomEventHandler = new NoopEventHandler();
|
private RCTEventEmitter mCustomEventHandler = new NoopEventHandler();
|
||||||
private List<OnAnimationFrame> mFrameCallbacks = new ArrayList<>();
|
private List<OnAnimationFrame> mFrameCallbacks = new ArrayList<>();
|
||||||
private ConcurrentLinkedQueue<CopiedEvent> mEventQueue = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<CopiedEvent> mEventQueue = new ConcurrentLinkedQueue<>();
|
||||||
private double lastFrameTimeMs;
|
private double lastFrameTimeMs;
|
||||||
public Set<String> uiProps = Collections.emptySet();
|
private FabricUIManager mFabricUIManager;
|
||||||
public Set<String> nativeProps = Collections.emptySet();
|
|
||||||
private ReaCompatibility compatibility;
|
|
||||||
|
|
||||||
public NativeProxy getNativeProxy() {
|
public NativeProxy getNativeProxy() {
|
||||||
return mNativeProxy;
|
return mNativeProxy;
|
||||||
@@ -105,47 +51,23 @@ public class NodesManager implements EventDispatcherListener {
|
|||||||
|
|
||||||
private NativeProxy mNativeProxy;
|
private NativeProxy mNativeProxy;
|
||||||
|
|
||||||
public AnimationsManager getAnimationsManager() {
|
public void invalidate() {
|
||||||
return mAnimationManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCatalystInstanceDestroy() {
|
|
||||||
if (mAnimationManager != null) {
|
|
||||||
mAnimationManager.onCatalystInstanceDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mNativeProxy != null) {
|
if (mNativeProxy != null) {
|
||||||
mNativeProxy.onCatalystInstanceDestroy();
|
mNativeProxy.invalidate();
|
||||||
mNativeProxy = null;
|
mNativeProxy = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void initWithContext(ReactApplicationContext reactApplicationContext) {
|
if (mFabricUIManager != null) {
|
||||||
mReactApplicationContext = reactApplicationContext;
|
mFabricUIManager.getEventDispatcher().removeListener(this);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Queue<NativeUpdateOperation> mOperationsInBatch = new LinkedList<>();
|
public NodesManager(ReactApplicationContext context, WorkletsModule workletsModule) {
|
||||||
private boolean mTryRunBatchUpdatesSynchronously = false;
|
context.assertOnJSQueueThread();
|
||||||
|
|
||||||
public NodesManager(ReactContext context) {
|
UIManager uiManager = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC);
|
||||||
mContext = context;
|
assert uiManager != null;
|
||||||
mUIManager = context.getNativeModule(UIManagerModule.class);
|
mCustomEventNamesResolver = uiManager::resolveCustomDirectEventName;
|
||||||
mUIImplementation = mUIManager.getUIImplementation();
|
|
||||||
mCustomEventNamesResolver = mUIManager.getDirectEventNamesResolver();
|
|
||||||
mEventEmitter = context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
mEventEmitter = context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
||||||
|
|
||||||
mReactChoreographer = ReactChoreographer.getInstance();
|
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
|
mNativeProxy = new NativeProxy(context, workletsModule, this);
|
||||||
// contructing an object yet.
|
mFabricUIManager = (FabricUIManager) uiManager;
|
||||||
// This lead to a crash described in
|
mFabricUIManager.getEventDispatcher().addListener(this);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onHostPause() {
|
public void onHostPause() {
|
||||||
@@ -202,99 +116,58 @@ public class NodesManager implements EventDispatcherListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performOperations() {
|
public void performOperations() {
|
||||||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
UiThreadUtil.assertOnUiThread();
|
||||||
if (mNativeProxy != null) {
|
if (mNativeProxy != null) {
|
||||||
mNativeProxy.performOperations();
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAnimationFrame(long frameTimeNanos) {
|
private void onAnimationFrame(long frameTimeNanos) {
|
||||||
// Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "onAnimationFrame");
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
|
||||||
double currentFrameTimeMs = frameTimeNanos / 1000000.;
|
try {
|
||||||
|
if (BuildConfig.REANIMATED_PROFILING) {
|
||||||
if (currentFrameTimeMs > lastFrameTimeMs) {
|
Trace.beginSection("onAnimationFrame");
|
||||||
// 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()) {
|
double currentFrameTimeMs = frameTimeNanos / 1000000.;
|
||||||
List<OnAnimationFrame> frameCallbacks = mFrameCallbacks;
|
if (mSlowAnimationsEnabled) {
|
||||||
mFrameCallbacks = new ArrayList<>(frameCallbacks.size());
|
currentFrameTimeMs =
|
||||||
for (int i = 0, size = frameCallbacks.size(); i < size; i++) {
|
mFirstUptime + (currentFrameTimeMs - mFirstUptime) / mAnimationsDragFactor;
|
||||||
frameCallbacks.get(i).onAnimationFrame(currentFrameTimeMs);
|
}
|
||||||
|
|
||||||
|
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) {
|
public void postOnAnimation(OnAnimationFrame onAnimationFrame) {
|
||||||
@@ -304,22 +177,32 @@ public class NodesManager implements EventDispatcherListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEventDispatch(Event event) {
|
public void onEventDispatch(Event event) {
|
||||||
if (mNativeProxy == null) {
|
try {
|
||||||
return;
|
if (BuildConfig.REANIMATED_PROFILING) {
|
||||||
}
|
Trace.beginSection("onEventDispatch");
|
||||||
// Events can be dispatched from any thread so we have to make sure handleEvent is run from the
|
}
|
||||||
// UI thread.
|
|
||||||
if (UiThreadUtil.isOnUiThread()) {
|
if (mNativeProxy == null) {
|
||||||
handleEvent(event);
|
return;
|
||||||
performOperations();
|
}
|
||||||
} else {
|
// Events can be dispatched from any thread so we have to make sure handleEvent is run from
|
||||||
String eventName = mCustomEventNamesResolver.resolveCustomEventName(event.getEventName());
|
// the UI thread.
|
||||||
int viewTag = event.getViewTag();
|
if (UiThreadUtil.isOnUiThread()) {
|
||||||
boolean shouldSaveEvent = mNativeProxy.isAnyHandlerWaitingForEvent(eventName, viewTag);
|
handleEvent(event);
|
||||||
if (shouldSaveEvent) {
|
performOperations();
|
||||||
mEventQueue.offer(new CopiedEvent(event));
|
} 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);
|
mEventEmitter.emit(name, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProps(int viewTag, Map<String, Object> props) {
|
public void enableSlowAnimations(boolean slowAnimationsEnabled, int animationsDragFactor) {
|
||||||
// TODO: update PropsNode to use this method instead of its own way of updating props
|
mSlowAnimationsEnabled = slowAnimationsEnabled;
|
||||||
boolean hasUIProps = false;
|
mAnimationsDragFactor = animationsDragFactor;
|
||||||
boolean hasNativeProps = false;
|
if (slowAnimationsEnabled) {
|
||||||
boolean hasJSProps = false;
|
mFirstUptime = SystemClock.uptimeMillis();
|
||||||
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.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
Vendored
+24
-78
@@ -1,55 +1,38 @@
|
|||||||
package com.swmansion.reanimated;
|
package com.swmansion.reanimated;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import com.facebook.react.bridge.LifecycleEventListener;
|
import com.facebook.react.bridge.LifecycleEventListener;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
||||||
import com.facebook.react.bridge.ReactMethod;
|
import com.facebook.react.bridge.ReactMethod;
|
||||||
import com.facebook.react.module.annotations.ReactModule;
|
import com.facebook.react.module.annotations.ReactModule;
|
||||||
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
import com.swmansion.worklets.WorkletsModule;
|
||||||
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;
|
|
||||||
|
|
||||||
@ReactModule(name = ReanimatedModule.NAME)
|
@ReactModule(name = ReanimatedModule.NAME)
|
||||||
public class ReanimatedModule extends ReactContextBaseJavaModule
|
public class ReanimatedModule extends NativeReanimatedModuleSpec implements LifecycleEventListener {
|
||||||
implements LifecycleEventListener, UIManagerModuleListener {
|
private final NodesManager mNodesManager;
|
||||||
|
private final WorkletsModule mWorkletsModule;
|
||||||
public static final String NAME = "ReanimatedModule";
|
|
||||||
|
|
||||||
private interface UIThreadOperation {
|
|
||||||
void execute(NodesManager nodesManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<UIThreadOperation> mOperations = new ArrayList<>();
|
|
||||||
private @Nullable NodesManager mNodesManager;
|
|
||||||
|
|
||||||
public ReanimatedModule(ReactApplicationContext reactContext) {
|
public ReanimatedModule(ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
|
reactContext.assertOnJSQueueThread();
|
||||||
|
mWorkletsModule = reactContext.getNativeModule(WorkletsModule.class);
|
||||||
|
mNodesManager = new NodesManager(reactContext, mWorkletsModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
ReactApplicationContext reactCtx = getReactApplicationContext();
|
ReactApplicationContext reactContext = getReactApplicationContext();
|
||||||
UIManagerModule uiManager = reactCtx.getNativeModule(UIManagerModule.class);
|
reactContext.assertOnJSQueueThread();
|
||||||
reactCtx.addLifecycleEventListener(this);
|
reactContext.addLifecycleEventListener(this);
|
||||||
uiManager.addUIManagerListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHostPause() {
|
public void onHostPause() {
|
||||||
if (mNodesManager != null) {
|
mNodesManager.onHostPause();
|
||||||
mNodesManager.onHostPause();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHostResume() {
|
public void onHostResume() {
|
||||||
if (mNodesManager != null) {
|
mNodesManager.onHostResume();
|
||||||
mNodesManager.onHostResume();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,70 +40,33 @@ public class ReanimatedModule extends ReactContextBaseJavaModule
|
|||||||
// do nothing
|
// 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() {
|
public NodesManager getNodesManager() {
|
||||||
if (mNodesManager == null) {
|
// This method is called from react-native-gesture-handler.
|
||||||
mNodesManager = new NodesManager(getReactApplicationContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
return mNodesManager;
|
return mNodesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod(isBlockingSynchronousMethod = true)
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||||
public void installTurboModule() {
|
public boolean installTurboModule() {
|
||||||
// When debugging in chrome the JS context is not available.
|
getReactApplicationContext().assertOnJSQueueThread();
|
||||||
// https://github.com/facebook/react-native/blob/v0.67.0-rc.6/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.java#L25
|
mNodesManager.getNativeProxy().installJSIBindings();
|
||||||
Utils.isChromeDebugger = getReactApplicationContext().getJavaScriptContextHolder().get() == 0;
|
return true;
|
||||||
|
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void addListener(String eventName) {
|
public void addListener(String ignoredEventName) {
|
||||||
// Keep: Required for RN built in Event Emitter Calls.
|
// Keep: Required for RN built in Event Emitter Calls.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void removeListeners(Integer count) {
|
public void removeListeners(Integer ignoredCount) {
|
||||||
// Keep: Required for RN built in Event Emitter Calls.
|
// Keep: Required for RN built in Event Emitter Calls.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCatalystInstanceDestroy() {
|
public void invalidate() {
|
||||||
super.onCatalystInstanceDestroy();
|
super.invalidate();
|
||||||
|
mNodesManager.invalidate();
|
||||||
if (mNodesManager != null) {
|
ReactApplicationContext reactContext = getReactApplicationContext();
|
||||||
mNodesManager.onCatalystInstanceDestroy();
|
reactContext.removeLifecycleEventListener(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
Vendored
+21
-47
@@ -1,84 +1,58 @@
|
|||||||
package com.swmansion.reanimated;
|
package com.swmansion.reanimated;
|
||||||
|
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
|
import androidx.annotation.NonNull;
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
|
import com.facebook.react.BaseReactPackage;
|
||||||
|
|
||||||
import com.facebook.react.ReactApplication;
|
import com.facebook.react.ReactApplication;
|
||||||
import com.facebook.react.ReactInstanceManager;
|
import com.facebook.react.ReactInstanceManager;
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
import com.facebook.react.TurboReactPackage;
|
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
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.ReactModule;
|
||||||
|
import com.facebook.react.module.annotations.ReactModuleList;
|
||||||
import com.facebook.react.module.model.ReactModuleInfo;
|
import com.facebook.react.module.model.ReactModuleInfo;
|
||||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
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.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
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
|
@Override
|
||||||
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
public NativeModule getModule(
|
||||||
if (name.equals(ReanimatedModule.NAME)) {
|
@NonNull String name, @NonNull ReactApplicationContext reactContext) {
|
||||||
return new ReanimatedModule(reactContext);
|
return switch (name) {
|
||||||
}
|
case ReanimatedModule.NAME -> new ReanimatedModule(reactContext);
|
||||||
if (name.equals(ReanimatedUIManager.NAME)) {
|
default -> null;
|
||||||
return createUIManager(reactContext);
|
};
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
||||||
Class<? extends NativeModule>[] moduleList =
|
Class<? extends NativeModule>[] moduleList =
|
||||||
new Class[] {
|
new Class[] {
|
||||||
ReanimatedModule.class, ReanimatedUIManager.class,
|
ReanimatedModule.class,
|
||||||
};
|
};
|
||||||
|
|
||||||
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
|
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
|
||||||
for (Class<? extends NativeModule> moduleClass : moduleList) {
|
for (Class<? extends NativeModule> moduleClass : moduleList) {
|
||||||
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);
|
ReactModule reactModule =
|
||||||
|
Objects.requireNonNull(moduleClass.getAnnotation(ReactModule.class));
|
||||||
|
|
||||||
reactModuleInfoMap.put(
|
reactModuleInfoMap.put(
|
||||||
reactModule.name(),
|
reactModule.name(),
|
||||||
new ReactModuleInfo(
|
new ReactModuleInfo(
|
||||||
reactModule.name(),
|
reactModule.name(),
|
||||||
moduleClass.getName(),
|
moduleClass.getName(),
|
||||||
true,
|
reactModule.canOverrideExistingModule(),
|
||||||
reactModule.needsEagerInit(),
|
reactModule.needsEagerInit(),
|
||||||
reactModule.hasConstants(),
|
|
||||||
reactModule.isCxxModule(),
|
reactModule.isCxxModule(),
|
||||||
TurboModule.class.isAssignableFrom(moduleClass)));
|
true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReactModuleInfoProvider() {
|
return () -> reactModuleInfoMap;
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Generated
Vendored
+10
-2
@@ -8,8 +8,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static boolean isChromeDebugger = false;
|
|
||||||
|
|
||||||
public static Map<String, Integer> processMapping(ReadableMap style) {
|
public static Map<String, Integer> processMapping(ReadableMap style) {
|
||||||
ReadableMapKeySetIterator iter = style.keySetIterator();
|
ReadableMapKeySetIterator iter = style.keySetIterator();
|
||||||
HashMap<String, Integer> mapping = new HashMap<>();
|
HashMap<String, Integer> mapping = new HashMap<>();
|
||||||
@@ -46,4 +44,14 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return 0;
|
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 {
|
public class EventHandler implements RCTEventEmitter {
|
||||||
|
|
||||||
@DoNotStrip private final HybridData mHybridData;
|
@DoNotStrip private final HybridData mHybridData;
|
||||||
UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
|
||||||
|
public UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
private EventHandler(HybridData hybridData) {
|
private EventHandler(HybridData hybridData) {
|
||||||
|
|||||||
Generated
Vendored
+2
-1
@@ -17,6 +17,7 @@ public class ReanimatedSensor {
|
|||||||
Sensor sensor;
|
Sensor sensor;
|
||||||
ReanimatedSensorType sensorType;
|
ReanimatedSensorType sensorType;
|
||||||
int interval;
|
int interval;
|
||||||
|
private static final int DEFAULT_INTERVAL = 8;
|
||||||
|
|
||||||
ReanimatedSensor(
|
ReanimatedSensor(
|
||||||
WeakReference<ReactApplicationContext> reactContext,
|
WeakReference<ReactApplicationContext> reactContext,
|
||||||
@@ -30,7 +31,7 @@ public class ReanimatedSensor {
|
|||||||
(SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE);
|
(SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE);
|
||||||
this.sensorType = sensorType;
|
this.sensorType = sensorType;
|
||||||
if (interval == -1) {
|
if (interval == -1) {
|
||||||
this.interval = SensorManager.SENSOR_DELAY_UI;
|
this.interval = DEFAULT_INTERVAL;
|
||||||
} else {
|
} else {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-57
@@ -1,61 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||||
export { AnimatedText as Text } from './reanimated2/component/Text';
|
export { AnimatedImage as Image } from './component/Image';
|
||||||
export { AnimatedView as View } from './reanimated2/component/View';
|
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||||
export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
|
export { AnimatedText as Text } from './component/Text';
|
||||||
export { AnimatedImage as Image } from './reanimated2/component/Image';
|
export { AnimatedView as View } from './component/View';
|
||||||
export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
|
|
||||||
export { addWhitelistedNativeProps, addWhitelistedUIProps } from './ConfigHelper';
|
export { addWhitelistedNativeProps, addWhitelistedUIProps } from './ConfigHelper';
|
||||||
/**
|
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||||
* @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.
|
|
||||||
* */
|
|
||||||
//# sourceMappingURL=Animated.js.map
|
//# 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';
|
'use strict';
|
||||||
|
|
||||||
import { PropsAllowlists } from './propsAllowlists';
|
import { executeOnUIRuntimeSync } from 'react-native-worklets';
|
||||||
import { jsiConfigureProps } from './reanimated2/core';
|
import { getLoggerConfig, SHOULD_BE_USE_WEB, updateLoggerConfig } from './common';
|
||||||
function assertNoOverlapInLists() {
|
|
||||||
for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {
|
export function addWhitelistedNativeProps(_props) {
|
||||||
throw new Error(`[Reanimated] Property \`${key}\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`);
|
// Do nothing. This is just for backward compatibility.
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function configureProps() {
|
|
||||||
assertNoOverlapInLists();
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
jsiConfigureProps(Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST), Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST));
|
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
|
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||||
* this will work just once for every view name
|
* 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 configureReanimatedLogger(config) {
|
||||||
export function adaptViewConfig(viewConfig) {
|
// Get the current config from the React runtime (to have a single source of truth)
|
||||||
const viewName = viewConfig.uiViewClassName;
|
const currentConfig = getLoggerConfig();
|
||||||
const props = viewConfig.validAttributes;
|
// Update the configuration object in the React runtime
|
||||||
|
updateLoggerConfig(currentConfig, config);
|
||||||
// update whitelist of UI props for this view name only once
|
// Register the updated configuration in the UI runtime
|
||||||
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
if (!SHOULD_BE_USE_WEB) {
|
||||||
const propsToAdd = {};
|
executeOnUIRuntimeSync(updateLoggerConfig)(currentConfig, config);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
configureProps();
|
|
||||||
//# sourceMappingURL=ConfigHelper.js.map
|
//# 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';
|
'use strict';
|
||||||
|
|
||||||
|
import { logger } from './common';
|
||||||
const mockTargetValues = {
|
const mockTargetValues = {
|
||||||
targetOriginX: 0,
|
targetOriginX: 0,
|
||||||
targetOriginY: 0,
|
targetOriginY: 0,
|
||||||
@@ -18,18 +19,30 @@ const mockTargetValues = {
|
|||||||
currentGlobalOriginY: 0,
|
currentGlobalOriginY: 0,
|
||||||
currentBorderRadius: 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) {
|
export function maybeBuild(layoutAnimationOrBuilder, style, displayName) {
|
||||||
const isAnimationBuilder = value => 'build' in layoutAnimationOrBuilder && typeof layoutAnimationOrBuilder.build === 'function';
|
const isAnimationBuilder = value => 'build' in layoutAnimationOrBuilder && typeof layoutAnimationOrBuilder.build === 'function';
|
||||||
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
||||||
const animationFactory = layoutAnimationOrBuilder.build();
|
const animationFactory = layoutAnimationOrBuilder.build();
|
||||||
const layoutAnimation = animationFactory(mockTargetValues);
|
if (__DEV__ && style) {
|
||||||
const animatedStyle = layoutAnimation.animations;
|
const layoutAnimation = animationFactory(mockTargetValues);
|
||||||
const getCommonProperties = (obj1, obj2) => Object.keys(obj1).filter(key => Object.prototype.hasOwnProperty.call(obj2, key));
|
maybeReportOverwrittenProperties(layoutAnimation.animations, style, displayName);
|
||||||
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.`);
|
|
||||||
}
|
}
|
||||||
return layoutAnimationOrBuilder.build();
|
return animationFactory;
|
||||||
} else {
|
} else {
|
||||||
return layoutAnimationOrBuilder;
|
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';
|
'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; }
|
import { isSharedValue } from '../isSharedValue';
|
||||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
import { startMapper, stopMapper } from '../mappers';
|
||||||
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 { updateProps } from '../updateProps';
|
||||||
|
import { makeViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||||
import { flattenArray } from './utils';
|
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) {
|
function isInlineStyleTransform(transform) {
|
||||||
if (!Array.isArray(transform)) {
|
if (!Array.isArray(transform)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -22,28 +16,29 @@ function inlinePropsHasChanged(styles1, styles2) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (const key of Object.keys(styles1)) {
|
for (const key of Object.keys(styles1)) {
|
||||||
if (styles1[key] !== styles2[key]) return true;
|
if (styles1[key] !== styles2[key]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function getInlinePropsUpdate(inlineProps) {
|
function getInlinePropsUpdate(styleValue) {
|
||||||
'worklet';
|
'worklet';
|
||||||
|
|
||||||
const update = {};
|
if (isSharedValue(styleValue)) {
|
||||||
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
return styleValue.value;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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) {
|
function extractSharedValuesMapFromProps(props) {
|
||||||
const inlineProps = {};
|
const inlineProps = {};
|
||||||
@@ -55,11 +50,11 @@ function extractSharedValuesMapFromProps(props) {
|
|||||||
if (!style) {
|
if (!style) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const [key, styleValue] of Object.entries(style)) {
|
for (const [styleKey, styleValue] of Object.entries(style)) {
|
||||||
if (isSharedValue(styleValue)) {
|
if (isSharedValue(styleValue)) {
|
||||||
inlineProps[key] = styleValue;
|
inlineProps[styleKey] = styleValue;
|
||||||
} else if (key === 'transform' && isInlineStyleTransform(styleValue)) {
|
} else if (styleKey === 'transform' && isInlineStyleTransform(styleValue)) {
|
||||||
inlineProps[key] = styleValue;
|
inlineProps[styleKey] = styleValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -91,11 +86,9 @@ export function getInlineStyle(style, isFirstRender) {
|
|||||||
return newStyle;
|
return newStyle;
|
||||||
}
|
}
|
||||||
export class InlinePropManager {
|
export class InlinePropManager {
|
||||||
constructor() {
|
_inlinePropsViewDescriptors = null;
|
||||||
_defineProperty(this, "_inlinePropsViewDescriptors", null);
|
_inlinePropsMapperId = null;
|
||||||
_defineProperty(this, "_inlinePropsMapperId", null);
|
_inlineProps = {};
|
||||||
_defineProperty(this, "_inlineProps", {});
|
|
||||||
}
|
|
||||||
attachInlineProps(animatedComponent, viewInfo) {
|
attachInlineProps(animatedComponent, viewInfo) {
|
||||||
const newInlineProps = extractSharedValuesMapFromProps(animatedComponent.props);
|
const newInlineProps = extractSharedValuesMapFromProps(animatedComponent.props);
|
||||||
const hasChanged = inlinePropsHasChanged(newInlineProps, this._inlineProps);
|
const hasChanged = inlinePropsHasChanged(newInlineProps, this._inlineProps);
|
||||||
@@ -104,32 +97,19 @@ export class InlinePropManager {
|
|||||||
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
||||||
const {
|
const {
|
||||||
viewTag,
|
viewTag,
|
||||||
viewName,
|
shadowNodeWrapper
|
||||||
shadowNodeWrapper,
|
|
||||||
viewConfig
|
|
||||||
} = viewInfo;
|
} = viewInfo;
|
||||||
if (Object.keys(newInlineProps).length && viewConfig) {
|
|
||||||
adaptViewConfig(viewConfig);
|
|
||||||
}
|
|
||||||
this._inlinePropsViewDescriptors.add({
|
this._inlinePropsViewDescriptors.add({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
tag: viewTag,
|
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
|
shadowNodeWrapper: shadowNodeWrapper
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const shareableViewDescriptors = this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
const shareableViewDescriptors = this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
||||||
const maybeViewRef = SHOULD_BE_USE_WEB ? {
|
|
||||||
items: new Set([animatedComponent])
|
|
||||||
} // see makeViewsRefSet
|
|
||||||
: undefined;
|
|
||||||
const updaterFunction = () => {
|
const updaterFunction = () => {
|
||||||
'worklet';
|
'worklet';
|
||||||
|
|
||||||
const update = getInlinePropsUpdate(newInlineProps);
|
const update = getInlinePropsUpdate(newInlineProps);
|
||||||
updateProps(shareableViewDescriptors, update, maybeViewRef);
|
updateProps(shareableViewDescriptors, update);
|
||||||
};
|
};
|
||||||
this._inlineProps = newInlineProps;
|
this._inlineProps = newInlineProps;
|
||||||
if (this._inlinePropsMapperId) {
|
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';
|
'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; }
|
import { runOnUI } from 'react-native-worklets';
|
||||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
import { SHOULD_BE_USE_WEB } from '../common';
|
||||||
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); }
|
class JSPropsUpdaterNative {
|
||||||
import { NativeEventEmitter, NativeModules, findNodeHandle } from 'react-native';
|
static _tagToComponentMapping = new Map();
|
||||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
registerComponent(animatedComponent, jsProps) {
|
||||||
import { runOnJS, runOnUIImmediately } from '../reanimated2/threads';
|
const viewTag = animatedComponent.getComponentViewTag();
|
||||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
JSPropsUpdaterNative._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||||
class JSPropsUpdaterPaper {
|
runOnUI(() => {
|
||||||
constructor() {
|
global._tagToJSPropNamesMapping[viewTag] = Object.fromEntries(jsProps.map(propName => [propName, true]));
|
||||||
_defineProperty(this, "_reanimatedEventEmitter", void 0);
|
})();
|
||||||
this._reanimatedEventEmitter = new NativeEventEmitter(NativeModules.ReanimatedModule);
|
|
||||||
}
|
}
|
||||||
addOnJSPropsChangeListener(animatedComponent) {
|
unregisterComponent(animatedComponent) {
|
||||||
const viewTag = findNodeHandle(animatedComponent);
|
const viewTag = animatedComponent.getComponentViewTag();
|
||||||
JSPropsUpdaterPaper._tagToComponentMapping.set(viewTag, animatedComponent);
|
JSPropsUpdaterNative._tagToComponentMapping.delete(viewTag);
|
||||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 1) {
|
runOnUI(() => {
|
||||||
const listener = data => {
|
delete global._tagToJSPropNamesMapping[viewTag];
|
||||||
const component = JSPropsUpdaterPaper._tagToComponentMapping.get(data.viewTag);
|
})();
|
||||||
component === null || component === void 0 ? void 0 : component._updateFromNative(data.props);
|
|
||||||
};
|
|
||||||
this._reanimatedEventEmitter.addListener('onReanimatedPropsChange', listener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
removeOnJSPropsChangeListener(animatedComponent) {
|
updateProps(operations) {
|
||||||
const viewTag = findNodeHandle(animatedComponent);
|
operations.forEach(({
|
||||||
JSPropsUpdaterPaper._tagToComponentMapping.delete(viewTag);
|
tag,
|
||||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 0) {
|
updates
|
||||||
this._reanimatedEventEmitter.removeAllListeners('onReanimatedPropsChange');
|
}) => {
|
||||||
}
|
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 {
|
class JSPropsUpdaterWeb {
|
||||||
addOnJSPropsChangeListener(_animatedComponent) {
|
registerComponent(_animatedComponent) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
removeOnJSPropsChangeListener(_animatedComponent) {
|
unregisterComponent(_animatedComponent) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
updateProps(_operations) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let JSPropsUpdater;
|
let JSPropsUpdater;
|
||||||
if (SHOULD_BE_USE_WEB) {
|
if (SHOULD_BE_USE_WEB) {
|
||||||
JSPropsUpdater = JSPropsUpdaterWeb;
|
JSPropsUpdater = JSPropsUpdaterWeb;
|
||||||
} else if (global._IS_FABRIC) {
|
|
||||||
JSPropsUpdater = JSPropsUpdaterFabric;
|
|
||||||
} else {
|
} else {
|
||||||
JSPropsUpdater = JSPropsUpdaterPaper;
|
JSPropsUpdater = JSPropsUpdaterNative;
|
||||||
}
|
}
|
||||||
export default JSPropsUpdater;
|
const jsPropsUpdater = new JSPropsUpdater();
|
||||||
|
export default jsPropsUpdater;
|
||||||
//# sourceMappingURL=JSPropsUpdater.js.map
|
//# 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';
|
'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; }
|
import { initialUpdaterRun } from '../animation';
|
||||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
import { isSharedValue } from '../isSharedValue';
|
||||||
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 { WorkletEventHandler } from '../WorkletEventHandler';
|
||||||
import { isSharedValue } from '../reanimated2';
|
import { getInlineStyle, hasInlineStyles } from './InlinePropManager';
|
||||||
import { isChromeDebugger } from '../reanimated2/PlatformChecker';
|
|
||||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
|
||||||
import { initialUpdaterRun } from '../reanimated2/animation';
|
|
||||||
import { hasInlineStyles, getInlineStyle } from './InlinePropManager';
|
|
||||||
import { flattenArray, has } from './utils';
|
import { flattenArray, has } from './utils';
|
||||||
import { StyleSheet } from 'react-native';
|
|
||||||
function dummyListener() {
|
function dummyListener() {
|
||||||
// empty listener we use to assign to listener properties for which animated
|
// empty listener we use to assign to listener properties for which animated
|
||||||
// event is used.
|
// event is used.
|
||||||
}
|
}
|
||||||
export class PropsFilter {
|
export class PropsFilter {
|
||||||
constructor() {
|
_initialPropsMap = new Map();
|
||||||
_defineProperty(this, "_initialStyle", {});
|
|
||||||
}
|
|
||||||
filterNonAnimatedProps(component) {
|
filterNonAnimatedProps(component) {
|
||||||
const inputProps = component.props;
|
const inputProps = component.props;
|
||||||
const props = {};
|
const props = {};
|
||||||
@@ -27,37 +20,38 @@ export class PropsFilter {
|
|||||||
const styleProp = inputProps.style;
|
const styleProp = inputProps.style;
|
||||||
const styles = flattenArray(styleProp ?? []);
|
const styles = flattenArray(styleProp ?? []);
|
||||||
const processedStyle = styles.map(style => {
|
const processedStyle = styles.map(style => {
|
||||||
if (style && style.viewDescriptors) {
|
if (style?.viewDescriptors) {
|
||||||
// this is how we recognize styles returned by useAnimatedStyle
|
const handle = style;
|
||||||
style.viewsRef.add(component);
|
|
||||||
if (component._isFirstRender) {
|
if (component._isFirstRender) {
|
||||||
this._initialStyle = {
|
this._initialPropsMap.set(handle, {
|
||||||
...style.initial.value,
|
...handle.initial.value,
|
||||||
...this._initialStyle,
|
...initialUpdaterRun(handle.initial.updater)
|
||||||
...initialUpdaterRun(style.initial.updater)
|
});
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return this._initialStyle;
|
return this._initialPropsMap.get(handle) ?? {};
|
||||||
} else if (hasInlineStyles(style)) {
|
} else if (hasInlineStyles(style)) {
|
||||||
return getInlineStyle(style, component._isFirstRender);
|
return getInlineStyle(style, component._isFirstRender);
|
||||||
} else {
|
} else {
|
||||||
return style;
|
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') {
|
} else if (key === 'animatedProps') {
|
||||||
const animatedProp = inputProps.animatedProps;
|
const animatedPropsProp = inputProps.animatedProps;
|
||||||
if (animatedProp.initial !== undefined) {
|
const animatedPropsArray = flattenArray(animatedPropsProp ?? []);
|
||||||
Object.keys(animatedProp.initial.value).forEach(key => {
|
animatedPropsArray.forEach(animatedProps => {
|
||||||
var _animatedProp$initial, _animatedProp$viewsRe;
|
if (animatedProps?.viewDescriptors && animatedProps.initial) {
|
||||||
props[key] = (_animatedProp$initial = animatedProp.initial) === null || _animatedProp$initial === void 0 ? void 0 : _animatedProp$initial.value[key];
|
Object.keys(animatedProps.initial.value).forEach(initialValueKey => {
|
||||||
(_animatedProp$viewsRe = animatedProp.viewsRef) === null || _animatedProp$viewsRe === void 0 ? void 0 : _animatedProp$viewsRe.add(component);
|
props[initialValueKey] = animatedProps.initial?.value[initialValueKey];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (has('current', value) && value.current instanceof WorkletEventHandler) {
|
});
|
||||||
if (value.current.eventNames.length > 0) {
|
} else if (has('workletEventHandler', value) && value.workletEventHandler instanceof WorkletEventHandler) {
|
||||||
value.current.eventNames.forEach(eventName => {
|
if (value.workletEventHandler.eventNames.length > 0) {
|
||||||
props[eventName] = has('listeners', value.current) ? value.current.listeners[eventName] : dummyListener;
|
value.workletEventHandler.eventNames.forEach(eventName => {
|
||||||
|
props[eventName] = has('listeners', value.workletEventHandler) ? value.workletEventHandler.listeners[eventName] : dummyListener;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
props[key] = dummyListener;
|
props[key] = dummyListener;
|
||||||
@@ -66,7 +60,7 @@ export class PropsFilter {
|
|||||||
if (component._isFirstRender) {
|
if (component._isFirstRender) {
|
||||||
props[key] = value.value;
|
props[key] = value.value;
|
||||||
}
|
}
|
||||||
} else if (key !== 'onGestureHandlerStateChange' || !isChromeDebugger()) {
|
} else {
|
||||||
props[key] = value;
|
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';
|
'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 React from 'react';
|
||||||
import { findNodeHandle, Platform } from 'react-native';
|
import AnimatedComponentImpl from './AnimatedComponent';
|
||||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
|
||||||
import '../reanimated2/layoutReanimation/animationsManager';
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets you create an Animated version of any React Native component.
|
* 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
|
* @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.
|
* @deprecated Please use `Animated.FlatList` component instead of calling
|
||||||
*/ // @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList
|
* `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) {
|
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 AnimatedComponentImpl {
|
||||||
class AnimatedComponent extends React.Component {
|
static displayName = `AnimatedComponent(${Component.displayName || Component.name || 'Component'})`;
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
// User can override component-defined jsProps via options
|
||||||
_defineProperty(this, "_styles", null);
|
const jsProps = options?.jsProps ?? Component.jsProps;
|
||||||
_defineProperty(this, "_animatedProps", void 0);
|
const modifiedOptions = jsProps?.length ? {
|
||||||
_defineProperty(this, "_viewTag", -1);
|
...options,
|
||||||
_defineProperty(this, "_isFirstRender", true);
|
jsProps
|
||||||
_defineProperty(this, "animatedStyle", {
|
} : options;
|
||||||
value: {}
|
super(Component, props, AnimatedComponent.displayName, modifiedOptions);
|
||||||
});
|
|
||||||
_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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_defineProperty(AnimatedComponent, "displayName", void 0);
|
const animatedComponent = props => {
|
||||||
_defineProperty(AnimatedComponent, "contextType", SkipEnteringContext);
|
return /*#__PURE__*/_jsx(AnimatedComponent, {
|
||||||
AnimatedComponent.displayName = `AnimatedComponent(${Component.displayName || Component.name || 'Component'})`;
|
...props,
|
||||||
return /*#__PURE__*/React.forwardRef((props, ref) => {
|
// Needed to prevent react from signing AnimatedComponent to the ref
|
||||||
return /*#__PURE__*/React.createElement(AnimatedComponent, _extends({}, props, ref === null ? null : {
|
// (we want to handle the ref assignment in the AnimatedComponent)
|
||||||
forwardedRef: ref
|
ref: null,
|
||||||
}));
|
...(props.ref === null ? null : {
|
||||||
});
|
forwardedRef: props.ref
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
animatedComponent.displayName = Component.displayName || Component.name || 'Component';
|
||||||
|
return animatedComponent;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=createAnimatedComponent.js.map
|
//# 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;
|
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
|
//# 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';
|
'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';
|
import * as Animated from './Animated';
|
||||||
export * from './reanimated2';
|
|
||||||
export default Animated;
|
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
|
//# 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';
|
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||||
import type { SharedValue as _SharedValue } from './reanimated2/commonTypes';
|
export { AnimatedImage as Image } from './component/Image';
|
||||||
import type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';
|
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||||
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';
|
export { AnimatedText as Text } from './component/Text';
|
||||||
import type { EasingFunction as _EasingFunction } from './reanimated2/Easing';
|
export { AnimatedView as View } from './component/View';
|
||||||
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 { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
|
export { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
|
||||||
/**
|
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||||
* @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
|
//# sourceMappingURL=Animated.d.ts.map
|
||||||
*/
|
|
||||||
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>;
|
|
||||||
Generated
Vendored
+14
-9
@@ -1,11 +1,16 @@
|
|||||||
export declare function addWhitelistedNativeProps(props: Record<string, boolean>): void;
|
import type { LoggerConfig } from './common';
|
||||||
export declare function addWhitelistedUIProps(props: Record<string, boolean>): void;
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
export interface ViewConfig {
|
export declare function addWhitelistedNativeProps(_props: Record<string, boolean>): void;
|
||||||
uiViewClassName: string;
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
validAttributes: Record<string, unknown>;
|
export declare function addWhitelistedUIProps(_props: Record<string, boolean>): void;
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* updates UI props whitelist for given view host instance
|
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||||
* this will work just once for every view name
|
* 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 { ILayoutAnimationBuilder, LayoutAnimationFunction, StyleProps } from './commonTypes';
|
||||||
import type { StyleProps } from './reanimated2/commonTypes';
|
import type { NestedArray } from './createAnimatedComponent/commonTypes';
|
||||||
export declare function maybeBuild(layoutAnimationOrBuilder: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe, style: StyleProps | undefined, displayName: string): LayoutAnimationFunction | Keyframe;
|
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 '../commonTypes';
|
||||||
import type { StyleProps } from '../reanimated2';
|
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||||
import type { IAnimatedComponentInternal, IInlinePropManager, ViewInfo } from './commonTypes';
|
import type { AnimatedComponentType, IInlinePropManager, ViewInfo } from './commonTypes';
|
||||||
import type { ViewDescriptorsSet } from '../reanimated2/ViewDescriptorsSet';
|
|
||||||
export declare function hasInlineStyles(style: StyleProps): boolean;
|
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 {
|
export declare class InlinePropManager implements IInlinePropManager {
|
||||||
_inlinePropsViewDescriptors: ViewDescriptorsSet | null;
|
_inlinePropsViewDescriptors: ViewDescriptorsSet | null;
|
||||||
_inlinePropsMapperId: number | null;
|
_inlinePropsMapperId: number | null;
|
||||||
_inlineProps: StyleProps;
|
_inlineProps: StyleProps;
|
||||||
attachInlineProps(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal, viewInfo: ViewInfo): void;
|
attachInlineProps(animatedComponent: AnimatedComponentType, viewInfo: ViewInfo): void;
|
||||||
detachInlineProps(): void;
|
detachInlineProps(): void;
|
||||||
}
|
}
|
||||||
|
//# sourceMappingURL=InlinePropManager.d.ts.map
|
||||||
Generated
Vendored
+11
-19
@@ -1,23 +1,15 @@
|
|||||||
/// <reference types="react" />
|
import type { AnimatedComponentProps, AnimatedComponentType, IAnimatedComponentInternal, IJSPropsUpdater, InitialComponentProps, JSPropsOperation } from './commonTypes';
|
||||||
import type { AnimatedComponentProps, IAnimatedComponentInternal, IJSPropsUpdater, InitialComponentProps } from './commonTypes';
|
declare class JSPropsUpdaterNative implements IJSPropsUpdater {
|
||||||
declare class JSPropsUpdaterPaper implements IJSPropsUpdater {
|
|
||||||
private static _tagToComponentMapping;
|
private static _tagToComponentMapping;
|
||||||
private _reanimatedEventEmitter;
|
registerComponent(animatedComponent: AnimatedComponentType, jsProps: string[]): void;
|
||||||
constructor();
|
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||||
addOnJSPropsChangeListener(animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
updateProps(operations: JSPropsOperation[]): 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;
|
|
||||||
}
|
}
|
||||||
declare class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
declare class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||||
addOnJSPropsChangeListener(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
registerComponent(_animatedComponent: React.Component<AnimatedComponentProps<InitialComponentProps>> & IAnimatedComponentInternal): void;
|
||||||
removeOnJSPropsChangeListener(_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 const jsPropsUpdater: JSPropsUpdaterNative | JSPropsUpdaterWeb;
|
||||||
declare let JSPropsUpdater: JSPropsUpdaterOptions;
|
export default jsPropsUpdater;
|
||||||
export default JSPropsUpdater;
|
//# sourceMappingURL=JSPropsUpdater.d.ts.map
|
||||||
Generated
Vendored
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="react" />
|
import type { AnimatedComponentType, IPropsFilter } from './commonTypes';
|
||||||
import type { IAnimatedComponentInternal, IPropsFilter } from './commonTypes';
|
|
||||||
export declare class PropsFilter implements IPropsFilter {
|
export declare class PropsFilter implements IPropsFilter {
|
||||||
private _initialStyle;
|
private _initialPropsMap;
|
||||||
filterNonAnimatedProps(component: React.Component<unknown, unknown> & IAnimatedComponentInternal): Record<string, unknown>;
|
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 { Component, Ref, RefObject } from 'react';
|
||||||
import type { StyleProps, BaseAnimationBuilder, ILayoutAnimationBuilder, EntryExitAnimationFunction, SharedTransition, SharedValue } from '../reanimated2';
|
import type { AnimatedStyle, EntryExitAnimationFunction, ILayoutAnimationBuilder, ShadowNodeWrapper, SharedValue, StyleProps, StyleUpdaterContainer } from '../commonTypes';
|
||||||
import type { ViewDescriptorsSet, ViewRefSet } from '../reanimated2/ViewDescriptorsSet';
|
import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
|
||||||
import type { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
import type { BaseAnimationBuilder } from '../layoutReanimation';
|
||||||
import type { ShadowNodeWrapper } from '../reanimated2/commonTypes';
|
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||||
import type { ViewConfig } from '../ConfigHelper';
|
|
||||||
export interface AnimatedProps extends Record<string, unknown> {
|
export interface AnimatedProps extends Record<string, unknown> {
|
||||||
viewDescriptors?: ViewDescriptorsSet;
|
viewDescriptors?: ViewDescriptorsSet;
|
||||||
viewsRef?: ViewRefSet<unknown>;
|
|
||||||
initial?: SharedValue<StyleProps>;
|
initial?: SharedValue<StyleProps>;
|
||||||
|
styleUpdaterContainer?: StyleUpdaterContainer;
|
||||||
}
|
}
|
||||||
export interface ViewInfo {
|
export interface ViewInfo {
|
||||||
viewTag: number | HTMLElement | null;
|
viewTag: number | AnimatedComponentRef | HTMLElement | null;
|
||||||
viewName: string | null;
|
|
||||||
shadowNodeWrapper: ShadowNodeWrapper | null;
|
shadowNodeWrapper: ShadowNodeWrapper | null;
|
||||||
viewConfig: ViewConfig;
|
viewName?: string;
|
||||||
|
DOMElement?: HTMLElement | null;
|
||||||
}
|
}
|
||||||
export interface IInlinePropManager {
|
export interface IInlinePropManager {
|
||||||
attachInlineProps(animatedComponent: React.Component<unknown, unknown>, viewInfo: ViewInfo): void;
|
attachInlineProps(animatedComponent: React.Component<unknown, unknown>, viewInfo: ViewInfo): void;
|
||||||
detachInlineProps(): void;
|
detachInlineProps(): void;
|
||||||
}
|
}
|
||||||
|
export type AnimatedComponentType = React.Component<unknown, unknown> & IAnimatedComponentInternal;
|
||||||
|
export type PropUpdates = StyleProps | AnimatedStyle<any>;
|
||||||
export interface IPropsFilter {
|
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 {
|
export interface IJSPropsUpdater {
|
||||||
addOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
|
registerComponent(animatedComponent: AnimatedComponentType, jsProps: string[]): void;
|
||||||
removeOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
|
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||||
|
updateProps(operations: JSPropsOperation[]): void;
|
||||||
|
}
|
||||||
|
export interface INativeEventsManager {
|
||||||
|
attachEvents(): void;
|
||||||
|
detachEvents(): void;
|
||||||
|
updateEvents(prevProps: AnimatedComponentProps<InitialComponentProps>): void;
|
||||||
}
|
}
|
||||||
export type LayoutAnimationStaticContext = {
|
export type LayoutAnimationStaticContext = {
|
||||||
presetName: string;
|
presetName: string;
|
||||||
};
|
};
|
||||||
export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
export type AnimatedComponentProps<P extends Record<string, unknown> = Record<string, unknown>> = P & {
|
||||||
forwardedRef?: Ref<Component>;
|
ref?: Ref<Component>;
|
||||||
style?: NestedArray<StyleProps>;
|
style?: NestedArray<StyleProps>;
|
||||||
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||||
|
jestAnimatedValues?: RefObject<AnimatedProps>;
|
||||||
animatedStyle?: StyleProps;
|
animatedStyle?: StyleProps;
|
||||||
layout?: (BaseAnimationBuilder | ILayoutAnimationBuilder | typeof BaseAnimationBuilder) & LayoutAnimationStaticContext;
|
layout?: (BaseAnimationBuilder | ILayoutAnimationBuilder | typeof BaseAnimationBuilder) & LayoutAnimationStaticContext;
|
||||||
entering?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
|
entering?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
|
||||||
exiting?: (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 {
|
export interface AnimatedComponentRef extends Component {
|
||||||
setNativeProps?: (props: Record<string, unknown>) => void;
|
setNativeProps?: (props: Record<string, unknown>) => void;
|
||||||
getScrollableNode?: () => AnimatedComponentRef;
|
getScrollableNode?: () => AnimatedComponentRef;
|
||||||
getAnimatableRef?: () => AnimatedComponentRef;
|
getAnimatableRef?: () => AnimatedComponentRef;
|
||||||
|
elementRef?: React.RefObject<HTMLElement>;
|
||||||
}
|
}
|
||||||
export interface IAnimatedComponentInternal {
|
export interface IAnimatedComponentInternalBase {
|
||||||
_styles: StyleProps[] | null;
|
ChildComponent: AnyComponent;
|
||||||
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
_componentRef: AnimatedComponentRef | HTMLElement | null;
|
||||||
_viewTag: number;
|
_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;
|
_isFirstRender: boolean;
|
||||||
animatedStyle: {
|
jestInlineStyle: NestedArray<StyleProps> | undefined;
|
||||||
|
jestAnimatedStyle: {
|
||||||
value: StyleProps;
|
value: StyleProps;
|
||||||
};
|
};
|
||||||
_component: AnimatedComponentRef | HTMLElement | null;
|
jestAnimatedProps: {
|
||||||
_sharedElementTransition: SharedTransition | null;
|
value: AnimatedProps;
|
||||||
_jsPropsUpdater: IJSPropsUpdater;
|
};
|
||||||
_InlinePropManager: IInlinePropManager;
|
_InlinePropManager: IInlinePropManager;
|
||||||
_PropsFilter: IPropsFilter;
|
_PropsFilter: IPropsFilter;
|
||||||
_viewInfo?: ViewInfo;
|
/** Doesn't exist on web. */
|
||||||
|
_NativeEventsManager?: INativeEventsManager;
|
||||||
context: React.ContextType<typeof SkipEnteringContext>;
|
context: React.ContextType<typeof SkipEnteringContext>;
|
||||||
|
setNativeProps: (props: StyleProps) => void;
|
||||||
}
|
}
|
||||||
export type NestedArray<T> = T | NestedArray<T>[];
|
export type NestedArray<T> = T | NestedArray<T>[];
|
||||||
|
export type AnyComponent = React.ComponentType<any>;
|
||||||
export interface InitialComponentProps extends Record<string, unknown> {
|
export interface InitialComponentProps extends Record<string, unknown> {
|
||||||
ref?: Ref<Component>;
|
ref?: Ref<Component>;
|
||||||
collapsable?: boolean;
|
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 type { ComponentClass, ComponentType, FunctionComponent } from 'react';
|
||||||
import '../reanimated2/layoutReanimation/animationsManager';
|
|
||||||
import type { AnimateProps } from '../reanimated2';
|
|
||||||
import type { AnimatedComponentRef } from './commonTypes';
|
|
||||||
import type { FlatList, FlatListProps } from 'react-native';
|
import type { FlatList, FlatListProps } from 'react-native';
|
||||||
type Options<P> = {
|
import type { AnimatedProps } from '../helperTypes';
|
||||||
setNativeProps: (ref: AnimatedComponentRef, props: P) => void;
|
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.
|
* 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.
|
* @returns A component that Reanimated is capable of animating.
|
||||||
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
* @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(component: AnimatableComponent<typeof FlatList<unknown>>, options?: Options<typeof FlatList<unknown>>): ComponentClass<AnimatedProps<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 {};
|
export {};
|
||||||
|
//# sourceMappingURL=createAnimatedComponent.d.ts.map
|
||||||
Generated
Vendored
+1
@@ -1 +1,2 @@
|
|||||||
export { createAnimatedComponent } from './createAnimatedComponent';
|
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';
|
import type { NestedArray } from './commonTypes';
|
||||||
export declare function flattenArray<T>(array: NestedArray<T>): T[];
|
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; };
|
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';
|
import * as Animated from './Animated';
|
||||||
export * from './reanimated2';
|
|
||||||
export default Animated;
|
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 @@
|
|||||||
/**
|
const Reanimated = require('./src/mock');
|
||||||
* Mock implementation for test runners.
|
// @ts-expect-error
|
||||||
*
|
const Animated = Reanimated.default;
|
||||||
* 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,
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
__esModule: true,
|
|
||||||
|
|
||||||
...Reanimated,
|
...Reanimated,
|
||||||
...ReanimatedV2,
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
...Reanimated,
|
...Animated,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+106
-111
@@ -1,54 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-reanimated",
|
"name": "react-native-reanimated",
|
||||||
"version": "3.6.3",
|
"version": "4.1.6",
|
||||||
"description": "More powerful alternative to Animated library for React Native.",
|
"description": "More powerful alternative to Animated library for React Native.",
|
||||||
|
"keywords": [
|
||||||
|
"react-native",
|
||||||
|
"react",
|
||||||
|
"native",
|
||||||
|
"reanimated"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
|
"test": "jest",
|
||||||
"test:unit": "jest",
|
"lint": "yarn lint:js && yarn lint:common && yarn lint:android && yarn lint:apple",
|
||||||
"test:update-snapshot": "jest --updateSnapshot",
|
"lint:js": "eslint src __tests__ __typetests__ && yarn prettier --check src __tests__ __typetests__",
|
||||||
"lint": "yarn lint:js && yarn lint:plugin && yarn lint:cpp && yarn lint:java && yarn lint:ios",
|
"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:js": "eslint --ext '.js,.ts,.tsx' src __tests__ __typetests__ && yarn prettier --check src __tests__ __typetests__",
|
"lint:common": "../../scripts/validate-common.sh && ../../scripts/cpplint.sh Common && yarn format:common --dry-run -Werror",
|
||||||
"lint:plugin": "cd plugin && yarn lint && cd ..",
|
"lint:clang-tidy": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs ../../scripts/clang-tidy-lint.sh",
|
||||||
"lint:docs": "cd docs && yarn lint && cd ..",
|
"lint:apple": "../../scripts/validate-apple.sh && yarn format:apple --dry-run -Werror",
|
||||||
"lint:java": "./android/gradlew -p android spotlessCheck -q",
|
"lint:cmake": "find ./android -type d \\( -name build -o -name .cxx \\) -prune -o -type f -name 'CMakeLists.txt' -print | xargs ../../scripts/lint-cmake.sh",
|
||||||
"lint:cpp": "./scripts/cpplint.sh",
|
"format": "yarn format:js && yarn format:apple && yarn format:android && yarn format:common",
|
||||||
"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",
|
|
||||||
"format:js": "prettier --write --list-different src __tests__ __typetests__",
|
"format:js": "prettier --write --list-different src __tests__ __typetests__",
|
||||||
"format:plugin": "cd plugin && yarn format && cd ..",
|
"format:apple": "find apple -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
||||||
"format:java": "node ./scripts/format-java.js",
|
"format:android": "yarn format:android:java && yarn format:android:cpp && yarn format:android:cmake",
|
||||||
"format:ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i --Werror",
|
"format:android:java": "node ../../scripts/format-java.js",
|
||||||
"format:android": "find android/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
|
"format:android:cpp": "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: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:docs": "cd docs && yarn format && cd ..",
|
"format:common": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
|
||||||
"find-unused-code:js": "yarn ts-prune --ignore \"index|.web.\" --error ",
|
"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:src": "yarn tsc --noEmit",
|
||||||
"type:check:plugin": "cd plugin && yarn type:check:src && cd ..",
|
"type:check:app": "yarn workspace common-app type:check",
|
||||||
"type:check:app": "./scripts/test-ts.sh app/src/App.tsx",
|
"type:check:tests:common": "../../scripts/test-ts.sh __typetests__/common",
|
||||||
"type:check:tests:common": "./scripts/test-ts.sh __typetests__/common.tsx",
|
"build": "yarn workspace react-native-worklets build && bob build",
|
||||||
"type:check:tests:0.72+": "./scripts/test-ts.sh __typetests__/0.72+.tsx",
|
"circular-dependency-check": "yarn madge --extensions js,jsx --circular lib",
|
||||||
"type:check:tests:legacy": "./scripts/test-ts.sh __typetests__/legacy.tsx",
|
"use-strict-check": "node ../../scripts/validate-use-strict.js",
|
||||||
"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",
|
"prepack": "cp ../../README.md ./README.md",
|
||||||
"prepare": "yarn plugin && bob build && husky install && yarn app",
|
"postpack": "rm ./README.md"
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"main": "lib/module/index",
|
"main": "lib/module/index",
|
||||||
"module": "lib/module/index",
|
"module": "lib/module/index",
|
||||||
"react-native": "src/index",
|
"react-native": "src/index",
|
||||||
"source": "src/index",
|
"source": "src/index",
|
||||||
"types": "lib/typescript/index",
|
"types": "lib/typescript/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"Common/",
|
"Common/",
|
||||||
"src/",
|
"src/",
|
||||||
@@ -60,9 +52,14 @@
|
|||||||
"apple/",
|
"apple/",
|
||||||
"RNReanimated.podspec",
|
"RNReanimated.podspec",
|
||||||
"scripts/reanimated_utils.rb",
|
"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",
|
"mock.js",
|
||||||
"plugin/index.js",
|
"plugin/index.js",
|
||||||
"plugin/build/plugin.js",
|
"metro-config",
|
||||||
"!**/__tests__",
|
"!**/__tests__",
|
||||||
"!**/__fixtures__",
|
"!**/__fixtures__",
|
||||||
"!**/__mocks__",
|
"!**/__mocks__",
|
||||||
@@ -77,7 +74,8 @@
|
|||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"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": {
|
"author": {
|
||||||
"email": "krzys.magiera@gmail.com",
|
"email": "krzys.magiera@gmail.com",
|
||||||
@@ -88,106 +86,103 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/software-mansion/react-native-reanimated/issues"
|
"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": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
"react-native-is-edge-to-edge": "^1.2.1",
|
||||||
"@babel/preset-typescript": "^7.16.7",
|
"semver": "7.7.2"
|
||||||
"convert-source-map": "^2.0.0",
|
|
||||||
"invariant": "^2.2.4"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0",
|
"@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": "*",
|
||||||
"react-native": "*"
|
"react-native": "*",
|
||||||
|
"react-native-worklets": ">=0.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.20.0",
|
"@babel/cli": "^7.20.0",
|
||||||
"@babel/core": "^7.20.0",
|
"@babel/core": "^7.25.2",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
"@babel/preset-env": "^7.25.3",
|
||||||
"@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/types": "^7.20.0",
|
"@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/jest-native": "^4.0.4",
|
||||||
"@testing-library/react-hooks": "^8.0.0",
|
"@testing-library/react-hooks": "^8.0.1",
|
||||||
"@testing-library/react-native": "^7.1.0",
|
"@testing-library/react-native": "^13.0.1",
|
||||||
"@types/babel__core": "^7.20.0",
|
"@types/babel__core": "^7.20.0",
|
||||||
"@types/babel__generator": "^7.6.4",
|
"@types/babel__generator": "^7.6.4",
|
||||||
"@types/babel__traverse": "^7.14.2",
|
"@types/babel__traverse": "^7.14.2",
|
||||||
"@types/convert-source-map": "^2.0.0",
|
"@types/convert-source-map": "^2.0.0",
|
||||||
"@types/invariant": "^2.2.35",
|
"@types/jest": "^29.5.13",
|
||||||
"@types/jest": "^29.0.0",
|
|
||||||
"@types/node": "^18.0.0",
|
"@types/node": "^18.0.0",
|
||||||
"@types/react": "^18.0.26",
|
"@types/react": "^19.1.0",
|
||||||
"@types/react-test-renderer": "17.0.2",
|
"@types/react-test-renderer": "^19.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
"@types/semver": "^7",
|
||||||
"@typescript-eslint/parser": "^5.11.0",
|
"@typescript-eslint/parser": "^6.19.0",
|
||||||
"axios": "^1.4.0",
|
"@typescript-eslint/rule-tester": "^6.21.0",
|
||||||
|
"axios": "^1.8.2",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"babel-jest": "^27.5.1",
|
|
||||||
"babel-plugin-module-resolver": "^5.0.0",
|
"babel-plugin-module-resolver": "^5.0.0",
|
||||||
"clang-format": "^1.6.0",
|
"clang-format-node": "^1.3.1",
|
||||||
"code-tag": "^1.1.0",
|
"code-tag": "^1.1.0",
|
||||||
"eslint": "^8.44.0",
|
"cspell": "^8.8.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint": "^9.29.0",
|
||||||
"eslint-config-standard": "^16.0.3",
|
"eslint-config-standard": "^17.1.0",
|
||||||
"eslint-import-resolver-babel-module": "^5.3.1",
|
"eslint-import-resolver-babel-module": "^5.3.2",
|
||||||
"eslint-plugin-import": "^2.25.4",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^28.13.0",
|
||||||
|
"eslint-plugin-n": "^17.19.0",
|
||||||
"eslint-plugin-no-inline-styles": "^1.0.5",
|
"eslint-plugin-no-inline-styles": "^1.0.5",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-promise": "^7.2.1",
|
||||||
"eslint-plugin-promise": "^6.0.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-reanimated": "workspace:*",
|
||||||
"eslint-plugin-standard": "^5.0.0",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"eslint-plugin-tsdoc": "^0.2.17",
|
"eslint-plugin-tsdoc": "^0.4.0",
|
||||||
"husky": "^7.0.4",
|
|
||||||
"jest": "^29.0.0",
|
"jest": "^29.0.0",
|
||||||
"lint-staged": "^11.2.0",
|
"knip": "^5.61.3",
|
||||||
"madge": "^5.0.1",
|
"madge": "^5.0.1",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^3.3.3",
|
||||||
"react": "17.0.2",
|
"react": "19.1.0",
|
||||||
"react-native": "0.72.6",
|
"react-native": "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-96e336150b.patch",
|
||||||
"react-native-builder-bob": "^0.18.3",
|
"react-native-builder-bob": "0.40.13",
|
||||||
"react-native-gesture-handler": "^2.13.2",
|
"react-native-gesture-handler": "2.28.0",
|
||||||
"react-native-web": "~0.18.12",
|
"react-native-svg": "15.12.1",
|
||||||
"react-test-renderer": "17.0.2",
|
"react-native-worklets": "workspace:*",
|
||||||
|
"react-test-renderer": "19.1.0",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"ts-prune": "^0.10.3",
|
"typescript": "5.8.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"
|
|
||||||
},
|
},
|
||||||
"react-native-builder-bob": {
|
"react-native-builder-bob": {
|
||||||
"source": "src",
|
"source": "src",
|
||||||
"output": "lib",
|
"output": "lib",
|
||||||
"targets": [
|
"targets": [
|
||||||
"module",
|
[
|
||||||
|
"module",
|
||||||
|
{
|
||||||
|
"esm": false,
|
||||||
|
"jsxRuntime": "automatic"
|
||||||
|
}
|
||||||
|
],
|
||||||
"typescript"
|
"typescript"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"codegenConfig": {
|
||||||
|
"name": "rnreanimated",
|
||||||
|
"type": "modules",
|
||||||
|
"jsSrcsDir": "./src/specs",
|
||||||
|
"android": {
|
||||||
|
"javaPackageName": "com.swmansion.reanimated"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
"./lib/reanimated2/core",
|
"./src/layoutReanimation/animationsManager.ts",
|
||||||
"./lib/index"
|
"./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,
|
:react_native_minor_version => nil,
|
||||||
:is_tvos_target => nil,
|
:is_tvos_target => nil,
|
||||||
:react_native_node_modules_dir => nil,
|
:react_native_node_modules_dir => nil,
|
||||||
:reanimated_node_modules_dir => nil,
|
|
||||||
:react_native_common_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')"`), '..')
|
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`.'
|
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
|
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[:is_tvos_target] = react_native_json['name'] == 'react-native-tvos'
|
||||||
result[:react_native_version] = react_native_json['version']
|
result[:react_native_version] = react_native_json['version']
|
||||||
result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
|
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
|
result[:react_native_minor_version] = 1000
|
||||||
end
|
end
|
||||||
result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
|
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
|
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_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
|
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
|
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
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
|
def assert_minimal_react_native_version(config)
|
||||||
reanimated_version = reanimated_package_json['version']
|
validate_react_native_version_script = File.expand_path(File.join(__dir__, 'validate-react-native-version.js'))
|
||||||
reanimated_major_version = reanimated_version.split('.')[0].to_i
|
unless system("node \"#{validate_react_native_version_script}\" #{config[:react_native_version]}")
|
||||||
react_native_minor_version = config[:react_native_minor_version]
|
raise "[Reanimated] React Native version is not compatible with Reanimated"
|
||||||
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."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_minimal_react_native_version(config)
|
def assert_new_architecture_enabled(new_arch_enabled)
|
||||||
if config[:react_native_minor_version] < 66
|
if !new_arch_enabled
|
||||||
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
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."
|
||||||
raise "[Reanimated] Unsupported React Native version. Please use 0.66 or newer."
|
|
||||||
end
|
end
|
||||||
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';
|
'use strict';
|
||||||
import type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';
|
export { ReanimatedFlatList as FlatList } from './component/FlatList';
|
||||||
import type { SharedValue as _SharedValue } from './reanimated2/commonTypes';
|
export { AnimatedImage as Image } from './component/Image';
|
||||||
import type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';
|
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
|
||||||
import type {
|
export { AnimatedText as Text } from './component/Text';
|
||||||
TransformStyleTypes as _TransformStyleTypes,
|
export { AnimatedView as View } from './component/View';
|
||||||
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 {
|
export {
|
||||||
addWhitelistedNativeProps,
|
addWhitelistedNativeProps,
|
||||||
addWhitelistedUIProps,
|
addWhitelistedUIProps,
|
||||||
} from './ConfigHelper';
|
} from './ConfigHelper';
|
||||||
/**
|
export { createAnimatedComponent } from './createAnimatedComponent';
|
||||||
* @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>;
|
|
||||||
|
|||||||
+28
-74
@@ -1,87 +1,41 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { PropsAllowlists } from './propsAllowlists';
|
import { executeOnUIRuntimeSync } from 'react-native-worklets';
|
||||||
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.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function configureProps(): void {
|
import type { LoggerConfig } from './common';
|
||||||
assertNoOverlapInLists();
|
import {
|
||||||
jsiConfigureProps(
|
getLoggerConfig,
|
||||||
Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST),
|
SHOULD_BE_USE_WEB,
|
||||||
Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST)
|
updateLoggerConfig,
|
||||||
);
|
} from './common';
|
||||||
}
|
|
||||||
|
|
||||||
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
export function addWhitelistedNativeProps(
|
export function addWhitelistedNativeProps(
|
||||||
props: Record<string, boolean>
|
_props: Record<string, boolean>
|
||||||
): void {
|
): void {
|
||||||
const oldSize = Object.keys(
|
// Do nothing. This is just for backward compatibility.
|
||||||
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: Record<string, boolean>): void {
|
/** @deprecated This function is a no-op in Reanimated 4. */
|
||||||
const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;
|
export function addWhitelistedUIProps(_props: Record<string, boolean>): void {
|
||||||
PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {
|
// Do nothing. This is just for backward compatibility.
|
||||||
...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,
|
|
||||||
...props,
|
|
||||||
};
|
|
||||||
if (
|
|
||||||
oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length
|
|
||||||
) {
|
|
||||||
configureProps();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PROCESSED_VIEW_NAMES = new Set();
|
|
||||||
|
|
||||||
export interface ViewConfig {
|
|
||||||
uiViewClassName: string;
|
|
||||||
validAttributes: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* updates UI props whitelist for given view host instance
|
* Updates Reanimated logger config with the user-provided configuration. Will
|
||||||
* this will work just once for every view name
|
* 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 configureReanimatedLogger(config: LoggerConfig) {
|
||||||
export function adaptViewConfig(viewConfig: ViewConfig): void {
|
// Get the current config from the React runtime (to have a single source of truth)
|
||||||
const viewName = viewConfig.uiViewClassName;
|
const currentConfig = getLoggerConfig();
|
||||||
const props = viewConfig.validAttributes;
|
// Update the configuration object in the React runtime
|
||||||
|
updateLoggerConfig(currentConfig, config);
|
||||||
// update whitelist of UI props for this view name only once
|
// Register the updated configuration in the UI runtime
|
||||||
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
|
if (!SHOULD_BE_USE_WEB) {
|
||||||
const propsToAdd: Record<string, boolean> = {};
|
executeOnUIRuntimeSync(updateLoggerConfig)(currentConfig, config);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureProps();
|
|
||||||
|
|||||||
+59
-19
@@ -1,12 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
import { logger } from './common';
|
||||||
import type {
|
import type {
|
||||||
ILayoutAnimationBuilder,
|
ILayoutAnimationBuilder,
|
||||||
LayoutAnimationFunction,
|
LayoutAnimationFunction,
|
||||||
LayoutAnimationsValues,
|
LayoutAnimationValues,
|
||||||
} from './reanimated2/layoutReanimation';
|
StyleProps,
|
||||||
import type { StyleProps } from './reanimated2/commonTypes';
|
} from './commonTypes';
|
||||||
|
import type { NestedArray } from './createAnimatedComponent/commonTypes';
|
||||||
|
|
||||||
const mockTargetValues: LayoutAnimationsValues = {
|
const mockTargetValues: LayoutAnimationValues = {
|
||||||
targetOriginX: 0,
|
targetOriginX: 0,
|
||||||
targetOriginY: 0,
|
targetOriginY: 0,
|
||||||
targetWidth: 0,
|
targetWidth: 0,
|
||||||
@@ -25,12 +27,57 @@ const mockTargetValues: LayoutAnimationsValues = {
|
|||||||
currentBorderRadius: 0,
|
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(
|
export function maybeBuild(
|
||||||
layoutAnimationOrBuilder:
|
layoutAnimationOrBuilder:
|
||||||
| ILayoutAnimationBuilder
|
| ILayoutAnimationBuilder
|
||||||
| LayoutAnimationFunction
|
| LayoutAnimationFunction
|
||||||
| Keyframe,
|
| Keyframe,
|
||||||
style: StyleProps | undefined,
|
style: NestedArray<StyleProps> | undefined,
|
||||||
displayName: string
|
displayName: string
|
||||||
): LayoutAnimationFunction | Keyframe {
|
): LayoutAnimationFunction | Keyframe {
|
||||||
const isAnimationBuilder = (
|
const isAnimationBuilder = (
|
||||||
@@ -41,24 +88,17 @@ export function maybeBuild(
|
|||||||
|
|
||||||
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
|
||||||
const animationFactory = layoutAnimationOrBuilder.build();
|
const animationFactory = layoutAnimationOrBuilder.build();
|
||||||
const layoutAnimation = animationFactory(mockTargetValues);
|
|
||||||
const animatedStyle = layoutAnimation.animations;
|
|
||||||
|
|
||||||
const getCommonProperties = (obj1: object, obj2: object) =>
|
if (__DEV__ && style) {
|
||||||
Object.keys(obj1).filter((key) =>
|
const layoutAnimation = animationFactory(mockTargetValues);
|
||||||
Object.prototype.hasOwnProperty.call(obj2, key)
|
maybeReportOverwrittenProperties(
|
||||||
);
|
layoutAnimation.animations,
|
||||||
|
style,
|
||||||
const commonProperties = getCommonProperties(animatedStyle, style || {});
|
displayName
|
||||||
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.`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return layoutAnimationOrBuilder.build();
|
return animationFactory;
|
||||||
} else {
|
} else {
|
||||||
return layoutAnimationOrBuilder;
|
return layoutAnimationOrBuilder;
|
||||||
}
|
}
|
||||||
|
|||||||
frontend-admin/node_modules/react-native-reanimated/src/createAnimatedComponent/InlinePropManager.ts
Generated
Vendored
+32
-50
@@ -1,24 +1,17 @@
|
|||||||
'use strict';
|
'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 {
|
import type {
|
||||||
IAnimatedComponentInternal,
|
|
||||||
AnimatedComponentProps,
|
AnimatedComponentProps,
|
||||||
|
AnimatedComponentType,
|
||||||
IInlinePropManager,
|
IInlinePropManager,
|
||||||
ViewInfo,
|
ViewInfo,
|
||||||
} from './commonTypes';
|
} from './commonTypes';
|
||||||
import { flattenArray } from './utils';
|
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 {
|
function isInlineStyleTransform(transform: unknown): boolean {
|
||||||
if (!Array.isArray(transform)) {
|
if (!Array.isArray(transform)) {
|
||||||
@@ -37,29 +30,30 @@ function inlinePropsHasChanged(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const key of Object.keys(styles1)) {
|
for (const key of Object.keys(styles1)) {
|
||||||
if (styles1[key] !== styles2[key]) return true;
|
if (styles1[key] !== styles2[key]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInlinePropsUpdate(inlineProps: Record<string, unknown>) {
|
function getInlinePropsUpdate(styleValue: StyleProps): unknown {
|
||||||
'worklet';
|
'worklet';
|
||||||
const update: Record<string, unknown> = {};
|
if (isSharedValue(styleValue)) {
|
||||||
for (const [key, styleValue] of Object.entries(inlineProps)) {
|
return styleValue.value;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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(
|
function extractSharedValuesMapFromProps(
|
||||||
@@ -77,14 +71,14 @@ function extractSharedValuesMapFromProps(
|
|||||||
if (!style) {
|
if (!style) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const [key, styleValue] of Object.entries(style)) {
|
for (const [styleKey, styleValue] of Object.entries(style)) {
|
||||||
if (isSharedValue(styleValue)) {
|
if (isSharedValue(styleValue)) {
|
||||||
inlineProps[key] = styleValue;
|
inlineProps[styleKey] = styleValue;
|
||||||
} else if (
|
} else if (
|
||||||
key === 'transform' &&
|
styleKey === 'transform' &&
|
||||||
isInlineStyleTransform(styleValue)
|
isInlineStyleTransform(styleValue)
|
||||||
) {
|
) {
|
||||||
inlineProps[key] = styleValue;
|
inlineProps[styleKey] = styleValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -114,7 +108,7 @@ export function getInlineStyle(
|
|||||||
isFirstRender: boolean
|
isFirstRender: boolean
|
||||||
) {
|
) {
|
||||||
if (isFirstRender) {
|
if (isFirstRender) {
|
||||||
return getInlinePropsUpdate(style);
|
return getInlinePropsUpdate(style) as Record<string, unknown>;
|
||||||
}
|
}
|
||||||
const newStyle: StyleProps = {};
|
const newStyle: StyleProps = {};
|
||||||
for (const [key, styleValue] of Object.entries(style)) {
|
for (const [key, styleValue] of Object.entries(style)) {
|
||||||
@@ -134,8 +128,7 @@ export class InlinePropManager implements IInlinePropManager {
|
|||||||
_inlineProps: StyleProps = {};
|
_inlineProps: StyleProps = {};
|
||||||
|
|
||||||
public attachInlineProps(
|
public attachInlineProps(
|
||||||
animatedComponent: React.Component<unknown, unknown> &
|
animatedComponent: AnimatedComponentType,
|
||||||
IAnimatedComponentInternal,
|
|
||||||
viewInfo: ViewInfo
|
viewInfo: ViewInfo
|
||||||
) {
|
) {
|
||||||
const newInlineProps: Record<string, unknown> =
|
const newInlineProps: Record<string, unknown> =
|
||||||
@@ -146,31 +139,20 @@ export class InlinePropManager implements IInlinePropManager {
|
|||||||
if (!this._inlinePropsViewDescriptors) {
|
if (!this._inlinePropsViewDescriptors) {
|
||||||
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
this._inlinePropsViewDescriptors = makeViewDescriptorsSet();
|
||||||
|
|
||||||
const { viewTag, viewName, shadowNodeWrapper, viewConfig } = viewInfo;
|
const { viewTag, shadowNodeWrapper } = viewInfo;
|
||||||
|
|
||||||
if (Object.keys(newInlineProps).length && viewConfig) {
|
|
||||||
adaptViewConfig(viewConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._inlinePropsViewDescriptors.add({
|
this._inlinePropsViewDescriptors.add({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
tag: viewTag as number,
|
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!,
|
shadowNodeWrapper: shadowNodeWrapper!,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const shareableViewDescriptors =
|
const shareableViewDescriptors =
|
||||||
this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
this._inlinePropsViewDescriptors.shareableViewDescriptors;
|
||||||
|
|
||||||
const maybeViewRef = SHOULD_BE_USE_WEB
|
|
||||||
? ({ items: new Set([animatedComponent]) } as ViewRefSet<unknown>) // see makeViewsRefSet
|
|
||||||
: undefined;
|
|
||||||
const updaterFunction = () => {
|
const updaterFunction = () => {
|
||||||
'worklet';
|
'worklet';
|
||||||
const update = getInlinePropsUpdate(newInlineProps);
|
const update = getInlinePropsUpdate(newInlineProps);
|
||||||
updateProps(shareableViewDescriptors, update, maybeViewRef);
|
updateProps(shareableViewDescriptors, update);
|
||||||
};
|
};
|
||||||
this._inlineProps = newInlineProps;
|
this._inlineProps = newInlineProps;
|
||||||
if (this._inlinePropsMapperId) {
|
if (this._inlinePropsMapperId) {
|
||||||
|
|||||||
Generated
Vendored
+42
-108
@@ -1,124 +1,55 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import {
|
import { runOnUI } from 'react-native-worklets';
|
||||||
NativeEventEmitter,
|
|
||||||
NativeModules,
|
import { SHOULD_BE_USE_WEB } from '../common';
|
||||||
findNodeHandle,
|
|
||||||
} from 'react-native';
|
|
||||||
import { shouldBeUseWeb } from '../reanimated2/PlatformChecker';
|
|
||||||
import type { StyleProps } from '../reanimated2';
|
|
||||||
import { runOnJS, runOnUIImmediately } from '../reanimated2/threads';
|
|
||||||
import type {
|
import type {
|
||||||
AnimatedComponentProps,
|
AnimatedComponentProps,
|
||||||
|
AnimatedComponentType,
|
||||||
IAnimatedComponentInternal,
|
IAnimatedComponentInternal,
|
||||||
IJSPropsUpdater,
|
IJSPropsUpdater,
|
||||||
InitialComponentProps,
|
InitialComponentProps,
|
||||||
|
JSPropsOperation,
|
||||||
} from './commonTypes';
|
} from './commonTypes';
|
||||||
|
|
||||||
interface ListenerData {
|
class JSPropsUpdaterNative implements IJSPropsUpdater {
|
||||||
viewTag: number;
|
private static _tagToComponentMapping = new Map<
|
||||||
props: StyleProps;
|
number,
|
||||||
}
|
AnimatedComponentType
|
||||||
|
>();
|
||||||
|
|
||||||
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
public registerComponent(
|
||||||
|
animatedComponent: AnimatedComponentType,
|
||||||
class JSPropsUpdaterPaper implements IJSPropsUpdater {
|
jsProps: string[]
|
||||||
private static _tagToComponentMapping = new Map();
|
|
||||||
private _reanimatedEventEmitter: NativeEventEmitter;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this._reanimatedEventEmitter = new NativeEventEmitter(
|
|
||||||
NativeModules.ReanimatedModule
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public addOnJSPropsChangeListener(
|
|
||||||
animatedComponent: React.Component<
|
|
||||||
AnimatedComponentProps<InitialComponentProps>
|
|
||||||
> &
|
|
||||||
IAnimatedComponentInternal
|
|
||||||
) {
|
) {
|
||||||
const viewTag = findNodeHandle(animatedComponent);
|
const viewTag = animatedComponent.getComponentViewTag();
|
||||||
JSPropsUpdaterPaper._tagToComponentMapping.set(viewTag, animatedComponent);
|
JSPropsUpdaterNative._tagToComponentMapping.set(viewTag, animatedComponent);
|
||||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 1) {
|
|
||||||
const listener = (data: ListenerData) => {
|
runOnUI(() => {
|
||||||
const component = JSPropsUpdaterPaper._tagToComponentMapping.get(
|
global._tagToJSPropNamesMapping[viewTag] = Object.fromEntries(
|
||||||
data.viewTag
|
jsProps.map((propName) => [propName, true])
|
||||||
);
|
|
||||||
component?._updateFromNative(data.props);
|
|
||||||
};
|
|
||||||
this._reanimatedEventEmitter.addListener(
|
|
||||||
'onReanimatedPropsChange',
|
|
||||||
listener
|
|
||||||
);
|
);
|
||||||
}
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeOnJSPropsChangeListener(
|
public unregisterComponent(animatedComponent: AnimatedComponentType) {
|
||||||
animatedComponent: React.Component<
|
const viewTag = animatedComponent.getComponentViewTag();
|
||||||
AnimatedComponentProps<InitialComponentProps>
|
JSPropsUpdaterNative._tagToComponentMapping.delete(viewTag);
|
||||||
> &
|
|
||||||
IAnimatedComponentInternal
|
|
||||||
) {
|
|
||||||
const viewTag = findNodeHandle(animatedComponent);
|
|
||||||
JSPropsUpdaterPaper._tagToComponentMapping.delete(viewTag);
|
|
||||||
if (JSPropsUpdaterPaper._tagToComponentMapping.size === 0) {
|
|
||||||
this._reanimatedEventEmitter.removeAllListeners(
|
|
||||||
'onReanimatedPropsChange'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class JSPropsUpdaterFabric implements IJSPropsUpdater {
|
runOnUI(() => {
|
||||||
private static _tagToComponentMapping = new Map();
|
delete global._tagToJSPropNamesMapping[viewTag];
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addOnJSPropsChangeListener(
|
public updateProps(operations: JSPropsOperation[]) {
|
||||||
animatedComponent: React.Component<
|
operations.forEach(({ tag, updates }) => {
|
||||||
AnimatedComponentProps<InitialComponentProps>
|
const component = JSPropsUpdaterNative._tagToComponentMapping.get(tag);
|
||||||
> &
|
component?.setNativeProps(updates);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
||||||
public addOnJSPropsChangeListener(
|
public registerComponent(
|
||||||
_animatedComponent: React.Component<
|
_animatedComponent: React.Component<
|
||||||
AnimatedComponentProps<InitialComponentProps>
|
AnimatedComponentProps<InitialComponentProps>
|
||||||
> &
|
> &
|
||||||
@@ -127,7 +58,7 @@ class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeOnJSPropsChangeListener(
|
public unregisterComponent(
|
||||||
_animatedComponent: React.Component<
|
_animatedComponent: React.Component<
|
||||||
AnimatedComponentProps<InitialComponentProps>
|
AnimatedComponentProps<InitialComponentProps>
|
||||||
> &
|
> &
|
||||||
@@ -135,20 +66,23 @@ class JSPropsUpdaterWeb implements IJSPropsUpdater {
|
|||||||
) {
|
) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateProps(_operations: JSPropsOperation[]) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type JSPropsUpdaterOptions =
|
type JSPropsUpdaterOptions =
|
||||||
| typeof JSPropsUpdaterWeb
|
| typeof JSPropsUpdaterWeb
|
||||||
| typeof JSPropsUpdaterFabric
|
| typeof JSPropsUpdaterNative;
|
||||||
| typeof JSPropsUpdaterPaper;
|
|
||||||
|
|
||||||
let JSPropsUpdater: JSPropsUpdaterOptions;
|
let JSPropsUpdater: JSPropsUpdaterOptions;
|
||||||
if (SHOULD_BE_USE_WEB) {
|
if (SHOULD_BE_USE_WEB) {
|
||||||
JSPropsUpdater = JSPropsUpdaterWeb;
|
JSPropsUpdater = JSPropsUpdaterWeb;
|
||||||
} else if (global._IS_FABRIC) {
|
|
||||||
JSPropsUpdater = JSPropsUpdaterFabric;
|
|
||||||
} else {
|
} 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';
|
'use strict';
|
||||||
import type { StyleProps, SharedValue } from '../reanimated2';
|
|
||||||
import { isSharedValue } from '../reanimated2';
|
import { initialUpdaterRun } from '../animation';
|
||||||
import { isChromeDebugger } from '../reanimated2/PlatformChecker';
|
import type { StyleProps } from '../commonTypes';
|
||||||
import WorkletEventHandler from '../reanimated2/WorkletEventHandler';
|
import type { AnimatedStyleHandle } from '../hook/commonTypes';
|
||||||
import { initialUpdaterRun } from '../reanimated2/animation';
|
import { isSharedValue } from '../isSharedValue';
|
||||||
import { hasInlineStyles, getInlineStyle } from './InlinePropManager';
|
import { WorkletEventHandler } from '../WorkletEventHandler';
|
||||||
import type {
|
import type {
|
||||||
AnimatedComponentProps,
|
AnimatedComponentProps,
|
||||||
|
AnimatedComponentType,
|
||||||
AnimatedProps,
|
AnimatedProps,
|
||||||
InitialComponentProps,
|
InitialComponentProps,
|
||||||
IAnimatedComponentInternal,
|
|
||||||
IPropsFilter,
|
IPropsFilter,
|
||||||
} from './commonTypes';
|
} from './commonTypes';
|
||||||
|
import { getInlineStyle, hasInlineStyles } from './InlinePropManager';
|
||||||
import { flattenArray, has } from './utils';
|
import { flattenArray, has } from './utils';
|
||||||
import { StyleSheet } from 'react-native';
|
|
||||||
|
|
||||||
function dummyListener() {
|
function dummyListener() {
|
||||||
// empty listener we use to assign to listener properties for which animated
|
// empty listener we use to assign to listener properties for which animated
|
||||||
@@ -21,56 +21,68 @@ function dummyListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PropsFilter implements IPropsFilter {
|
export class PropsFilter implements IPropsFilter {
|
||||||
private _initialStyle = {};
|
private _initialPropsMap = new Map<AnimatedStyleHandle, StyleProps>();
|
||||||
|
|
||||||
public filterNonAnimatedProps(
|
public filterNonAnimatedProps(
|
||||||
component: React.Component<unknown, unknown> & IAnimatedComponentInternal
|
component: AnimatedComponentType
|
||||||
): Record<string, unknown> {
|
): Record<string, unknown> {
|
||||||
const inputProps =
|
const inputProps =
|
||||||
component.props as AnimatedComponentProps<InitialComponentProps>;
|
component.props as AnimatedComponentProps<InitialComponentProps>;
|
||||||
const props: Record<string, unknown> = {};
|
const props: Record<string, unknown> = {};
|
||||||
|
|
||||||
for (const key in inputProps) {
|
for (const key in inputProps) {
|
||||||
const value = inputProps[key];
|
const value = inputProps[key];
|
||||||
if (key === 'style') {
|
if (key === 'style') {
|
||||||
const styleProp = inputProps.style;
|
const styleProp = inputProps.style;
|
||||||
const styles = flattenArray<StyleProps>(styleProp ?? []);
|
const styles = flattenArray<StyleProps>(styleProp ?? []);
|
||||||
const processedStyle: StyleProps = styles.map((style) => {
|
|
||||||
if (style && style.viewDescriptors) {
|
const processedStyle: StyleProps[] = styles.map((style) => {
|
||||||
// this is how we recognize styles returned by useAnimatedStyle
|
if (style?.viewDescriptors) {
|
||||||
style.viewsRef.add(component);
|
const handle = style as AnimatedStyleHandle;
|
||||||
|
|
||||||
if (component._isFirstRender) {
|
if (component._isFirstRender) {
|
||||||
this._initialStyle = {
|
this._initialPropsMap.set(handle, {
|
||||||
...style.initial.value,
|
...handle.initial.value,
|
||||||
...this._initialStyle,
|
...initialUpdaterRun(handle.initial.updater),
|
||||||
...initialUpdaterRun<StyleProps>(style.initial.updater),
|
} as StyleProps);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return this._initialStyle;
|
|
||||||
|
return this._initialPropsMap.get(handle) ?? {};
|
||||||
} else if (hasInlineStyles(style)) {
|
} else if (hasInlineStyles(style)) {
|
||||||
return getInlineStyle(style, component._isFirstRender);
|
return getInlineStyle(style, component._isFirstRender);
|
||||||
} else {
|
} else {
|
||||||
return style;
|
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') {
|
} else if (key === 'animatedProps') {
|
||||||
const animatedProp = inputProps.animatedProps as Partial<
|
const animatedPropsProp = inputProps.animatedProps;
|
||||||
AnimatedComponentProps<AnimatedProps>
|
const animatedPropsArray = flattenArray<
|
||||||
>;
|
Partial<AnimatedComponentProps<AnimatedProps>>
|
||||||
if (animatedProp.initial !== undefined) {
|
>(animatedPropsProp ?? []);
|
||||||
Object.keys(animatedProp.initial.value).forEach((key) => {
|
|
||||||
props[key] = animatedProp.initial?.value[key];
|
animatedPropsArray.forEach((animatedProps) => {
|
||||||
animatedProp.viewsRef?.add(component);
|
if (animatedProps?.viewDescriptors && animatedProps.initial) {
|
||||||
});
|
Object.keys(animatedProps.initial.value).forEach(
|
||||||
}
|
(initialValueKey) => {
|
||||||
|
props[initialValueKey] =
|
||||||
|
animatedProps.initial?.value[initialValueKey];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (
|
} else if (
|
||||||
has('current', value) &&
|
has('workletEventHandler', value) &&
|
||||||
value.current instanceof WorkletEventHandler
|
value.workletEventHandler instanceof WorkletEventHandler
|
||||||
) {
|
) {
|
||||||
if (value.current.eventNames.length > 0) {
|
if (value.workletEventHandler.eventNames.length > 0) {
|
||||||
value.current.eventNames.forEach((eventName) => {
|
value.workletEventHandler.eventNames.forEach((eventName) => {
|
||||||
props[eventName] = has('listeners', value.current)
|
props[eventName] = has('listeners', value.workletEventHandler)
|
||||||
? (value.current.listeners as Record<string, unknown>)[eventName]
|
? (
|
||||||
|
value.workletEventHandler.listeners as Record<string, unknown>
|
||||||
|
)[eventName]
|
||||||
: dummyListener;
|
: dummyListener;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -78,9 +90,9 @@ export class PropsFilter implements IPropsFilter {
|
|||||||
}
|
}
|
||||||
} else if (isSharedValue(value)) {
|
} else if (isSharedValue(value)) {
|
||||||
if (component._isFirstRender) {
|
if (component._isFirstRender) {
|
||||||
props[key] = (value as SharedValue<unknown>).value;
|
props[key] = value.value;
|
||||||
}
|
}
|
||||||
} else if (key !== 'onGestureHandlerStateChange' || !isChromeDebugger()) {
|
} else {
|
||||||
props[key] = value;
|
props[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
Vendored
+92
-38
@@ -1,32 +1,35 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import type { Ref, Component } from 'react';
|
import type { Component, Ref, RefObject } from 'react';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
StyleProps,
|
AnimatedStyle,
|
||||||
BaseAnimationBuilder,
|
|
||||||
ILayoutAnimationBuilder,
|
|
||||||
EntryExitAnimationFunction,
|
EntryExitAnimationFunction,
|
||||||
SharedTransition,
|
ILayoutAnimationBuilder,
|
||||||
|
ShadowNodeWrapper,
|
||||||
SharedValue,
|
SharedValue,
|
||||||
} from '../reanimated2';
|
StyleProps,
|
||||||
import type {
|
StyleUpdaterContainer,
|
||||||
ViewDescriptorsSet,
|
} from '../commonTypes';
|
||||||
ViewRefSet,
|
import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
|
||||||
} from '../reanimated2/ViewDescriptorsSet';
|
import type { BaseAnimationBuilder } from '../layoutReanimation';
|
||||||
import type { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';
|
import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
|
||||||
import type { ShadowNodeWrapper } from '../reanimated2/commonTypes';
|
|
||||||
import type { ViewConfig } from '../ConfigHelper';
|
|
||||||
|
|
||||||
export interface AnimatedProps extends Record<string, unknown> {
|
export interface AnimatedProps extends Record<string, unknown> {
|
||||||
viewDescriptors?: ViewDescriptorsSet;
|
viewDescriptors?: ViewDescriptorsSet;
|
||||||
viewsRef?: ViewRefSet<unknown>;
|
|
||||||
initial?: SharedValue<StyleProps>;
|
initial?: SharedValue<StyleProps>;
|
||||||
|
styleUpdaterContainer?: StyleUpdaterContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ViewInfo {
|
export interface ViewInfo {
|
||||||
viewTag: number | HTMLElement | null;
|
viewTag: number | AnimatedComponentRef | HTMLElement | null;
|
||||||
viewName: string | null;
|
|
||||||
shadowNodeWrapper: ShadowNodeWrapper | 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 {
|
export interface IInlinePropManager {
|
||||||
@@ -37,31 +40,49 @@ export interface IInlinePropManager {
|
|||||||
detachInlineProps(): void;
|
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 {
|
export interface IPropsFilter {
|
||||||
filterNonAnimatedProps: (
|
filterNonAnimatedProps: (
|
||||||
component: React.Component<unknown, unknown> & IAnimatedComponentInternal
|
component: AnimatedComponentType
|
||||||
) => Record<string, unknown>;
|
) => Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type JSPropsOperation = {
|
||||||
|
tag: number;
|
||||||
|
updates: StyleProps;
|
||||||
|
};
|
||||||
|
|
||||||
export interface IJSPropsUpdater {
|
export interface IJSPropsUpdater {
|
||||||
addOnJSPropsChangeListener(
|
registerComponent(
|
||||||
animatedComponent: React.Component<unknown, unknown> &
|
animatedComponent: AnimatedComponentType,
|
||||||
IAnimatedComponentInternal
|
jsProps: string[]
|
||||||
): void;
|
|
||||||
removeOnJSPropsChangeListener(
|
|
||||||
animatedComponent: React.Component<unknown, unknown> &
|
|
||||||
IAnimatedComponentInternal
|
|
||||||
): void;
|
): void;
|
||||||
|
unregisterComponent(animatedComponent: AnimatedComponentType): void;
|
||||||
|
updateProps(operations: JSPropsOperation[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface INativeEventsManager {
|
||||||
|
attachEvents(): void;
|
||||||
|
detachEvents(): void;
|
||||||
|
updateEvents(prevProps: AnimatedComponentProps<InitialComponentProps>): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LayoutAnimationStaticContext = {
|
export type LayoutAnimationStaticContext = {
|
||||||
presetName: string;
|
presetName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
export type AnimatedComponentProps<
|
||||||
forwardedRef?: Ref<Component>;
|
P extends Record<string, unknown> = Record<string, unknown>,
|
||||||
|
> = P & {
|
||||||
|
ref?: Ref<Component>;
|
||||||
style?: NestedArray<StyleProps>;
|
style?: NestedArray<StyleProps>;
|
||||||
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
||||||
|
jestAnimatedValues?: RefObject<AnimatedProps>;
|
||||||
animatedStyle?: StyleProps;
|
animatedStyle?: StyleProps;
|
||||||
layout?: (
|
layout?: (
|
||||||
| BaseAnimationBuilder
|
| BaseAnimationBuilder
|
||||||
@@ -83,34 +104,67 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
|||||||
| Keyframe
|
| Keyframe
|
||||||
) &
|
) &
|
||||||
LayoutAnimationStaticContext;
|
LayoutAnimationStaticContext;
|
||||||
sharedTransitionTag?: string;
|
|
||||||
sharedTransitionStyle?: SharedTransition;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type LayoutAnimationOrBuilder = (
|
||||||
|
| BaseAnimationBuilder
|
||||||
|
| typeof BaseAnimationBuilder
|
||||||
|
| EntryExitAnimationFunction
|
||||||
|
| Keyframe
|
||||||
|
| ILayoutAnimationBuilder
|
||||||
|
) &
|
||||||
|
LayoutAnimationStaticContext;
|
||||||
|
|
||||||
export interface AnimatedComponentRef extends Component {
|
export interface AnimatedComponentRef extends Component {
|
||||||
setNativeProps?: (props: Record<string, unknown>) => void;
|
setNativeProps?: (props: Record<string, unknown>) => void;
|
||||||
getScrollableNode?: () => AnimatedComponentRef;
|
getScrollableNode?: () => AnimatedComponentRef;
|
||||||
getAnimatableRef?: () => AnimatedComponentRef;
|
getAnimatableRef?: () => AnimatedComponentRef;
|
||||||
|
// Case for SVG components on Web
|
||||||
|
elementRef?: React.RefObject<HTMLElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAnimatedComponentInternal {
|
export interface IAnimatedComponentInternalBase {
|
||||||
_styles: StyleProps[] | null;
|
ChildComponent: AnyComponent;
|
||||||
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
_componentRef: AnimatedComponentRef | HTMLElement | null;
|
||||||
_viewTag: number;
|
_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;
|
_isFirstRender: boolean;
|
||||||
animatedStyle: { value: StyleProps };
|
jestInlineStyle: NestedArray<StyleProps> | undefined;
|
||||||
_component: AnimatedComponentRef | HTMLElement | null;
|
jestAnimatedStyle: { value: StyleProps };
|
||||||
_sharedElementTransition: SharedTransition | null;
|
jestAnimatedProps: { value: AnimatedProps };
|
||||||
_jsPropsUpdater: IJSPropsUpdater;
|
|
||||||
_InlinePropManager: IInlinePropManager;
|
_InlinePropManager: IInlinePropManager;
|
||||||
_PropsFilter: IPropsFilter;
|
_PropsFilter: IPropsFilter;
|
||||||
_viewInfo?: ViewInfo;
|
/** Doesn't exist on web. */
|
||||||
|
_NativeEventsManager?: INativeEventsManager;
|
||||||
context: React.ContextType<typeof SkipEnteringContext>;
|
context: React.ContextType<typeof SkipEnteringContext>;
|
||||||
|
setNativeProps: (props: StyleProps) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NestedArray<T> = T | NestedArray<T>[];
|
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> {
|
export interface InitialComponentProps extends Record<string, unknown> {
|
||||||
ref?: Ref<Component>;
|
ref?: Ref<Component>;
|
||||||
collapsable?: boolean;
|
collapsable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ManagedAnimatedComponent = React.Component<
|
||||||
|
AnimatedComponentProps<InitialComponentProps>
|
||||||
|
> &
|
||||||
|
IAnimatedComponentInternal;
|
||||||
|
|||||||
Generated
Vendored
+59
-563
@@ -1,81 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import type {
|
import type {
|
||||||
Component,
|
|
||||||
ComponentClass,
|
ComponentClass,
|
||||||
ComponentType,
|
ComponentType,
|
||||||
FunctionComponent,
|
FunctionComponent,
|
||||||
MutableRefObject,
|
Ref,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import React 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';
|
import type { FlatList, FlatListProps } from 'react-native';
|
||||||
|
|
||||||
const IS_WEB = isWeb();
|
import type { AnimatedProps } from '../helperTypes';
|
||||||
const IS_FABRIC = isFabric();
|
import type { Options } from './AnimatedComponent';
|
||||||
|
import AnimatedComponentImpl from './AnimatedComponent';
|
||||||
|
import type {
|
||||||
|
AnimatedComponentProps,
|
||||||
|
InitialComponentProps,
|
||||||
|
} from './commonTypes';
|
||||||
|
|
||||||
function onlyAnimatedStyles(styles: StyleProps[]): StyleProps[] {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return styles.filter((style) => style?.viewDescriptors);
|
type AnimatableComponent<C extends ComponentType<any>> = C & {
|
||||||
}
|
jsProps?: string[];
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,517 +29,70 @@ type Options<P> = {
|
|||||||
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
* @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
|
// @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList
|
||||||
export function createAnimatedComponent(
|
export function createAnimatedComponent(
|
||||||
component: typeof FlatList<unknown>,
|
component: AnimatableComponent<typeof FlatList<unknown>>,
|
||||||
options?: Options<any>
|
options?: Options<typeof FlatList<unknown>>
|
||||||
): ComponentClass<AnimateProps<FlatListProps<unknown>>>;
|
): ComponentClass<AnimatedProps<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>>;
|
|
||||||
|
|
||||||
export function createAnimatedComponent(
|
export function createAnimatedComponent(
|
||||||
Component: ComponentType<InitialComponentProps>,
|
Component: AnimatableComponent<ComponentType<InitialComponentProps>>,
|
||||||
options?: Options<InitialComponentProps>
|
options?: Options<InitialComponentProps>
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
): any {
|
): any {
|
||||||
invariant(
|
class AnimatedComponent extends AnimatedComponentImpl {
|
||||||
typeof Component !== 'function' ||
|
static displayName = `AnimatedComponent(${
|
||||||
(Component.prototype && Component.prototype.isReactComponent),
|
Component.displayName || Component.name || 'Component'
|
||||||
`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>;
|
|
||||||
|
|
||||||
constructor(props: AnimatedComponentProps<InitialComponentProps>) {
|
constructor(props: AnimatedComponentProps<InitialComponentProps>) {
|
||||||
super(props);
|
// User can override component-defined jsProps via options
|
||||||
if (isJest()) {
|
const jsProps = options?.jsProps ?? Component.jsProps;
|
||||||
this.animatedStyle = { value: {} };
|
const modifiedOptions = jsProps?.length
|
||||||
}
|
? { ...options, jsProps }
|
||||||
}
|
: options;
|
||||||
|
super(Component, props, AnimatedComponent.displayName, modifiedOptions);
|
||||||
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}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatedComponent.displayName = `AnimatedComponent(${
|
const animatedComponent = (
|
||||||
Component.displayName || Component.name || 'Component'
|
props: AnimatedComponentProps & { ref: Ref<AnimatedComponent> }
|
||||||
})`;
|
) => {
|
||||||
|
|
||||||
return React.forwardRef<Component>((props, ref) => {
|
|
||||||
return (
|
return (
|
||||||
<AnimatedComponent
|
<AnimatedComponent
|
||||||
{...props}
|
{...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';
|
'use strict';
|
||||||
|
import type { StyleProps } from '../commonTypes';
|
||||||
|
import type { CSSStyle } from '../css';
|
||||||
import type { NestedArray } from './commonTypes';
|
import type { NestedArray } from './commonTypes';
|
||||||
|
|
||||||
export function flattenArray<T>(array: NestedArray<T>): T[] {
|
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>(
|
export const has = <K extends string>(
|
||||||
key: K,
|
key: K,
|
||||||
x: unknown
|
x: unknown
|
||||||
): x is typeof x & { [key in K]: unknown } => {
|
): x is { [key in K]: unknown } => {
|
||||||
if (typeof x === 'function' || typeof x === 'object') {
|
if (typeof x === 'function' || typeof x === 'object') {
|
||||||
if (x === null || x === undefined) {
|
if (x === null || x === undefined) {
|
||||||
return false;
|
return false;
|
||||||
@@ -33,3 +35,26 @@ export const has = <K extends string>(
|
|||||||
}
|
}
|
||||||
return false;
|
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';
|
'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';
|
import * as Animated from './Animated';
|
||||||
|
|
||||||
export * from './reanimated2';
|
|
||||||
export default Animated;
|
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": "0.81.5",
|
||||||
"react-native-gesture-handler": "~2.28.0",
|
"react-native-gesture-handler": "~2.28.0",
|
||||||
"react-native-maps": "1.20.1",
|
"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-safe-area-context": "~5.6.0",
|
||||||
"react-native-screens": "~4.16.0",
|
"react-native-screens": "~4.16.0",
|
||||||
"react-native-web": "^0.21.0",
|
"react-native-web": "^0.21.0",
|
||||||
@@ -475,41 +475,6 @@
|
|||||||
"@babel/core": "^7.0.0-0"
|
"@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": {
|
"node_modules/@babel/plugin-syntax-async-generators": {
|
||||||
"version": "7.8.4",
|
"version": "7.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",
|
"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"
|
"@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": {
|
"node_modules/@babel/plugin-transform-object-rest-spread": {
|
||||||
"version": "7.28.6",
|
"version": "7.28.6",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.28.6.tgz",
|
"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": {
|
"node_modules/react-native-reanimated": {
|
||||||
"version": "3.6.3",
|
"version": "4.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-4.1.6.tgz",
|
||||||
"integrity": "sha512-2KkkPozoIvDbJcHuf8qeyoLROXQxizSi+2CTCkuNVkVZOxxY4B0Omvgq61aOQhSZUh/649x1YHoAaTyGMGDJUw==",
|
"integrity": "sha512-F+ZJBYiok/6Jzp1re75F/9aLzkgoQCOh4yxrnwATa8392RvM3kx+fiXXFvwcgE59v48lMwd9q0nzF1oJLXpfxQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-object-assign": "^7.16.7",
|
"react-native-is-edge-to-edge": "^1.2.1",
|
||||||
"@babel/preset-typescript": "^7.16.7",
|
"semver": "7.7.2"
|
||||||
"convert-source-map": "^2.0.0",
|
|
||||||
"invariant": "^2.2.4"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0",
|
"@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": "*",
|
||||||
"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": {
|
"node_modules/react-native-safe-area-context": {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"react-native": "0.81.5",
|
"react-native": "0.81.5",
|
||||||
"react-native-gesture-handler": "~2.28.0",
|
"react-native-gesture-handler": "~2.28.0",
|
||||||
"react-native-maps": "1.20.1",
|
"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-safe-area-context": "~5.6.0",
|
||||||
"react-native-screens": "~4.16.0",
|
"react-native-screens": "~4.16.0",
|
||||||
"react-native-web": "^0.21.0",
|
"react-native-web": "^0.21.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user