diff --git a/.eslintrc.js b/.eslintrc.js index e3b2a73fd25..d1a7e47de16 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,9 +5,6 @@ module.exports = { 'standard', 'plugin:@typescript-eslint/recommended', 'prettier', - 'prettier/flowtype', - 'prettier/react', - 'prettier/standard', 'plugin:import/typescript', ], plugins: ['react', 'react-native', 'import', 'jest', '@typescript-eslint'], @@ -17,7 +14,9 @@ module.exports = { }, settings: { 'import/resolver': { - 'babel-module': {}, + 'babel-module': { + extensions: ['.js', '.jsx', '.ts', '.tsx'], + }, }, }, rules: { diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index bfe44b5c474..e34e14c4125 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -20,6 +20,15 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + - name: Install NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r21d - name: Set ANDROID_NDK run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV - name: Accept licenses diff --git a/.github/workflows/build-npm-package.yml b/.github/workflows/build-npm-package.yml index f167398bef3..26c2c5bbd25 100644 --- a/.github/workflows/build-npm-package.yml +++ b/.github/workflows/build-npm-package.yml @@ -12,10 +12,10 @@ jobs: - name: Check out uses: actions/checkout@v1 - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: '11' - name: Install NDK uses: nttld/setup-ndk@v1 @@ -38,7 +38,7 @@ jobs: path: '*.tgz' - name: Compress Android build output - run: zip -r android-build-output.zip android/build/ + run: zip -r android-build-output.zip build_output - name: Upload Android build folder uses: actions/upload-artifact@v2 diff --git a/.github/workflows/tv-os-build.yml b/.github/workflows/tv-os-build.yml new file mode 100644 index 00000000000..8b2a616ca0f --- /dev/null +++ b/.github/workflows/tv-os-build.yml @@ -0,0 +1,40 @@ +name: Test tvOS build +on: + pull_request: + branches: + - main + paths: + - 'ios/**' + - 'Common/**' + push: + branches: + - main + workflow_dispatch: +jobs: + build: + runs-on: macos-latest + env: + WORKING_DIRECTORY: TVOSExample + concurrency: + group: ios-tv-${{ github.ref }} + cancel-in-progress: true + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Use Node.js 14 + uses: actions/setup-node@v2 + with: + node-version: 14 + cache: 'yarn' + cache-dependency-path: 'TVOSExample/yarn.lock' + - name: Install Reanimated node dependencies + run: yarn + - name: Install node dependencies + working-directory: ${{ env.WORKING_DIRECTORY }} + run: yarn + - name: Install pods + working-directory: ${{ env.WORKING_DIRECTORY }}/ios + run: pod install + - name: Build app + working-directory: ${{ env.WORKING_DIRECTORY }} + run: yarn tv-os diff --git a/.github/workflows/validate-java.yml b/.github/workflows/validate-java.yml index 0716c7fa763..3d1f021cf5b 100644 --- a/.github/workflows/validate-java.yml +++ b/.github/workflows/validate-java.yml @@ -4,7 +4,7 @@ on: branches: - main paths: - - 'android/src/java**' + - 'android/src/main/java/**' push: branches: - main diff --git a/.gitignore b/.gitignore index 3300fe8b91d..55d92992e47 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,5 @@ lib/ react-native-reanimated-tests.js # eclipse -*.settings** \ No newline at end of file +*.settings** +FabricExample diff --git a/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp b/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp new file mode 100644 index 00000000000..89d212db8cd --- /dev/null +++ b/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp @@ -0,0 +1,72 @@ +#include "AnimatedSensorModule.h" +#include "MutableValue.h" +#include "ValueWrapper.h" + +namespace reanimated { + +AnimatedSensorModule::AnimatedSensorModule( + const PlatformDepMethodsHolder &platformDepMethodsHolder, + RuntimeManager *runtimeManager) + : platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor), + platformUnregisterSensorFunction_( + platformDepMethodsHolder.unregisterSensor), + runtimeManager_(runtimeManager) {} + +AnimatedSensorModule::~AnimatedSensorModule() { + // It is called during app reload because app reload doesn't call hooks + // unmounting + for (auto sensorId : sensorsIds_) { + platformUnregisterSensorFunction_(sensorId); + } +} + +jsi::Value AnimatedSensorModule::registerSensor( + jsi::Runtime &rt, + const jsi::Value &sensorType, + const jsi::Value &interval, + const jsi::Value &sensorDataContainer) { + std::shared_ptr sensorsData = ShareableValue::adapt( + rt, sensorDataContainer.getObject(rt), runtimeManager_); + auto &mutableObject = + ValueWrapper::asMutableValue(sensorsData->valueContainer); + + std::function setter; + if (sensorType.asNumber() == SensorType::ROTATION_VECTOR) { + setter = [&, mutableObject](double newValues[]) { + jsi::Runtime &runtime = *runtimeManager_->runtime.get(); + jsi::Object value(runtime); + value.setProperty(runtime, "qw", newValues[0]); + value.setProperty(runtime, "qx", newValues[1]); + value.setProperty(runtime, "qy", newValues[2]); + value.setProperty(runtime, "qz", newValues[3]); + value.setProperty(runtime, "yaw", newValues[4]); + value.setProperty(runtime, "pitch", newValues[5]); + value.setProperty(runtime, "roll", newValues[6]); + mutableObject->setValue(runtime, std::move(value)); + }; + } else { + setter = [&, mutableObject](double newValues[]) { + jsi::Runtime &runtime = *runtimeManager_->runtime.get(); + jsi::Object value(runtime); + value.setProperty(runtime, "x", newValues[0]); + value.setProperty(runtime, "y", newValues[1]); + value.setProperty(runtime, "z", newValues[2]); + mutableObject->setValue(runtime, std::move(value)); + }; + } + + int sensorId = platformRegisterSensorFunction_( + sensorType.asNumber(), interval.asNumber(), setter); + if (sensorId != -1) { + sensorsIds_.insert(sensorId); + } + return jsi::Value(sensorId); +} + +void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) { + // It is called during sensor hook unmounting + sensorsIds_.erase(sensorId.getNumber()); + platformUnregisterSensorFunction_(sensorId.asNumber()); +} + +} // namespace reanimated diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 506c037ae6e..50584dd7611 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -8,6 +8,7 @@ #include "JSIStoreValueUser.h" #include "Mapper.h" #include "MapperRegistry.h" +#include "MutableValue.h" #include "ReanimatedHiddenHeaders.h" #include "RuntimeDecorator.h" #include "ShareableValue.h" @@ -70,7 +71,10 @@ NativeReanimatedModule::NativeReanimatedModule( mapperRegistry(std::make_shared()), eventHandlerRegistry(std::make_shared()), requestRender(platformDepMethodsHolder.requestRender), - propObtainer(propObtainer) { + propObtainer(propObtainer), + animatedSensorModule(platformDepMethodsHolder, this), + configurePropsPlatformFunction( + platformDepMethodsHolder.configurePropsFunction) { auto requestAnimationFrame = [=](FrameCallback callback) { frameCallbacks.push_back(callback); maybeRequestRender(); @@ -85,6 +89,8 @@ NativeReanimatedModule::NativeReanimatedModule( platformDepMethodsHolder.scrollToFunction, platformDepMethodsHolder.measuringFunction, platformDepMethodsHolder.getCurrentTime, + platformDepMethodsHolder.registerSensor, + platformDepMethodsHolder.unregisterSensor, platformDepMethodsHolder.setGestureStateFunction, layoutAnimationsProxy); onRenderCallback = [this](double timestampMs) { @@ -243,6 +249,14 @@ jsi::Value NativeReanimatedModule::enableLayoutAnimations( return jsi::Value::undefined(); } +jsi::Value NativeReanimatedModule::configureProps( + jsi::Runtime &rt, + const jsi::Value &uiProps, + const jsi::Value &nativeProps) { + configurePropsPlatformFunction(rt, uiProps, nativeProps); + return jsi::Value::undefined(); +} + void NativeReanimatedModule::onEvent( std::string eventName, std::string eventAsString) { @@ -298,4 +312,19 @@ void NativeReanimatedModule::onRender(double timestampMs) { } } +jsi::Value NativeReanimatedModule::registerSensor( + jsi::Runtime &rt, + const jsi::Value &sensorType, + const jsi::Value &interval, + const jsi::Value &sensorDataContainer) { + return animatedSensorModule.registerSensor( + rt, sensorType, interval, sensorDataContainer); +} + +void NativeReanimatedModule::unregisterSensor( + jsi::Runtime &rt, + const jsi::Value &sensorId) { + animatedSensorModule.unregisterSensor(sensorId); +} + } // namespace reanimated diff --git a/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp b/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp index bf496064c0a..14819e06ff1 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp @@ -1,9 +1,10 @@ #include "NativeReanimatedModuleSpec.h" +#define SPEC_PREFIX(FN_NAME) __hostFunction_NativeReanimatedModuleSpec_##FN_NAME + namespace reanimated { -static jsi::Value -__hostFunction_NativeReanimatedModuleSpec_installCoreFunctions( +static jsi::Value SPEC_PREFIX(installCoreFunctions)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -15,7 +16,7 @@ __hostFunction_NativeReanimatedModuleSpec_installCoreFunctions( // SharedValue -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeShareable( +static jsi::Value SPEC_PREFIX(makeShareable)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -24,7 +25,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeShareable( ->makeShareable(rt, std::move(args[0])); } -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeMutable( +static jsi::Value SPEC_PREFIX(makeMutable)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -33,7 +34,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeMutable( ->makeMutable(rt, std::move(args[0])); } -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeRemote( +static jsi::Value SPEC_PREFIX(makeRemote)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -42,7 +43,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_makeRemote( ->makeRemote(rt, std::move(args[0])); } -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_startMapper( +static jsi::Value SPEC_PREFIX(startMapper)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -57,7 +58,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_startMapper( std::move(args[4])); } -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_stopMapper( +static jsi::Value SPEC_PREFIX(stopMapper)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -67,8 +68,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_stopMapper( return jsi::Value::undefined(); } -static jsi::Value -__hostFunction_NativeReanimatedModuleSpec_registerEventHandler( +static jsi::Value SPEC_PREFIX(registerEventHandler)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -77,8 +77,7 @@ __hostFunction_NativeReanimatedModuleSpec_registerEventHandler( ->registerEventHandler(rt, std::move(args[0]), std::move(args[1])); } -static jsi::Value -__hostFunction_NativeReanimatedModuleSpec_unregisterEventHandler( +static jsi::Value SPEC_PREFIX(unregisterEventHandler)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -88,7 +87,7 @@ __hostFunction_NativeReanimatedModuleSpec_unregisterEventHandler( return jsi::Value::undefined(); } -static jsi::Value __hostFunction_NativeReanimatedModuleSpec_getViewProp( +static jsi::Value SPEC_PREFIX(getViewProp)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -99,8 +98,7 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_getViewProp( return jsi::Value::undefined(); } -static jsi::Value -__hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations( +static jsi::Value SPEC_PREFIX(enableLayoutAnimations)( jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, @@ -110,33 +108,60 @@ __hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations( return jsi::Value::undefined(); } +static jsi::Value SPEC_PREFIX(registerSensor)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + return static_cast(&turboModule) + ->registerSensor( + rt, std::move(args[0]), std::move(args[1]), std::move(args[2])); +} + +static jsi::Value SPEC_PREFIX(unregisterSensor)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + static_cast(&turboModule) + ->unregisterSensor(rt, std::move(args[0])); + return jsi::Value::undefined(); +} + +static jsi::Value SPEC_PREFIX(configureProps)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + static_cast(&turboModule) + ->configureProps(rt, std::move(args[0]), std::move(args[1])); + return jsi::Value::undefined(); +} + NativeReanimatedModuleSpec::NativeReanimatedModuleSpec( std::shared_ptr jsInvoker) : TurboModule("NativeReanimated", jsInvoker) { - methodMap_["installCoreFunctions"] = MethodMetadata{ - 1, __hostFunction_NativeReanimatedModuleSpec_installCoreFunctions}; - - methodMap_["makeShareable"] = MethodMetadata{ - 1, __hostFunction_NativeReanimatedModuleSpec_makeShareable}; - methodMap_["makeMutable"] = - MethodMetadata{1, __hostFunction_NativeReanimatedModuleSpec_makeMutable}; - methodMap_["makeRemote"] = - MethodMetadata{1, __hostFunction_NativeReanimatedModuleSpec_makeRemote}; - - methodMap_["startMapper"] = - MethodMetadata{5, __hostFunction_NativeReanimatedModuleSpec_startMapper}; - methodMap_["stopMapper"] = - MethodMetadata{1, __hostFunction_NativeReanimatedModuleSpec_stopMapper}; - - methodMap_["registerEventHandler"] = MethodMetadata{ - 2, __hostFunction_NativeReanimatedModuleSpec_registerEventHandler}; - methodMap_["unregisterEventHandler"] = MethodMetadata{ - 1, __hostFunction_NativeReanimatedModuleSpec_unregisterEventHandler}; - - methodMap_["getViewProp"] = - MethodMetadata{3, __hostFunction_NativeReanimatedModuleSpec_getViewProp}; - methodMap_["enableLayoutAnimations"] = MethodMetadata{ - 2, __hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations}; + methodMap_["installCoreFunctions"] = + MethodMetadata{1, SPEC_PREFIX(installCoreFunctions)}; + + methodMap_["makeShareable"] = MethodMetadata{1, SPEC_PREFIX(makeShareable)}; + methodMap_["makeMutable"] = MethodMetadata{1, SPEC_PREFIX(makeMutable)}; + methodMap_["makeRemote"] = MethodMetadata{1, SPEC_PREFIX(makeRemote)}; + + methodMap_["startMapper"] = MethodMetadata{5, SPEC_PREFIX(startMapper)}; + methodMap_["stopMapper"] = MethodMetadata{1, SPEC_PREFIX(stopMapper)}; + + methodMap_["registerEventHandler"] = + MethodMetadata{2, SPEC_PREFIX(registerEventHandler)}; + methodMap_["unregisterEventHandler"] = + MethodMetadata{1, SPEC_PREFIX(unregisterEventHandler)}; + + methodMap_["getViewProp"] = MethodMetadata{3, SPEC_PREFIX(getViewProp)}; + methodMap_["enableLayoutAnimations"] = + MethodMetadata{2, SPEC_PREFIX(enableLayoutAnimations)}; + methodMap_["registerSensor"] = MethodMetadata{3, SPEC_PREFIX(registerSensor)}; + methodMap_["unregisterSensor"] = + MethodMetadata{1, SPEC_PREFIX(unregisterSensor)}; + methodMap_["configureProps"] = MethodMetadata{2, SPEC_PREFIX(configureProps)}; } - } // namespace reanimated diff --git a/Common/cpp/SharedItems/ShareableValue.cpp b/Common/cpp/SharedItems/ShareableValue.cpp index 57a515e201b..d65b2a16bc4 100644 --- a/Common/cpp/SharedItems/ShareableValue.cpp +++ b/Common/cpp/SharedItems/ShareableValue.cpp @@ -64,7 +64,7 @@ void ShareableValue::adapt( jsi::Object hiddenProperty = hiddenValue.asObject(rt); if (hiddenProperty.isHostObject(rt)) { type = ValueType::FrozenObjectType; - if (object.hasProperty(rt, "__worklet") && object.isFunction(rt)) { + if (object.hasProperty(rt, "__workletHash") && object.isFunction(rt)) { type = ValueType::WorkletFunctionType; } valueContainer = std::make_unique( @@ -99,7 +99,7 @@ void ShareableValue::adapt( } else if (value.isObject()) { auto object = value.asObject(rt); if (object.isFunction(rt)) { - if (object.getProperty(rt, "__worklet").isUndefined()) { + if (object.getProperty(rt, "__workletHash").isUndefined()) { // not a worklet, we treat this as a host function type = ValueType::HostFunctionType; containsHostFunction = true; diff --git a/Common/cpp/Tools/RuntimeDecorator.cpp b/Common/cpp/Tools/RuntimeDecorator.cpp index 6dc1fdcbf46..447a68c1102 100644 --- a/Common/cpp/Tools/RuntimeDecorator.cpp +++ b/Common/cpp/Tools/RuntimeDecorator.cpp @@ -31,20 +31,6 @@ void RuntimeDecorator::decorateRuntime( rt, "_LABEL", jsi::String::createFromAscii(rt, label)); jsi::Object dummyGlobal(rt); - auto dummyFunction = [](jsi::Runtime &rt, - const jsi::Value &thisValue, - const jsi::Value *args, - size_t count) -> jsi::Value { - return jsi::Value::undefined(); - }; - jsi::Function __reanimatedWorkletInit = jsi::Function::createFromHostFunction( - rt, - jsi::PropNameID::forAscii(rt, "__reanimatedWorkletInit"), - 1, - dummyFunction); - - dummyGlobal.setProperty( - rt, "__reanimatedWorkletInit", __reanimatedWorkletInit); rt.global().setProperty(rt, "global", dummyGlobal); rt.global().setProperty(rt, "jsThis", jsi::Value::undefined()); @@ -85,21 +71,27 @@ void RuntimeDecorator::decorateRuntime( 1, setGlobalConsole)); + auto chronoNow = [](jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count) -> jsi::Value { + double now = std::chrono::system_clock::now().time_since_epoch() / + std::chrono::milliseconds(1); + return jsi::Value(now); + }; + rt.global().setProperty( rt, "_chronoNow", jsi::Function::createFromHostFunction( - rt, - jsi::PropNameID::forAscii(rt, "_chronoNow"), - 0, - [](jsi::Runtime &rt, - const jsi::Value &thisValue, - const jsi::Value *args, - size_t count) -> jsi::Value { - double now = std::chrono::system_clock::now().time_since_epoch() / - std::chrono::milliseconds(1); - return jsi::Value(now); - })); + rt, jsi::PropNameID::forAscii(rt, "_chronoNow"), 0, chronoNow)); + jsi::Object performance(rt); + performance.setProperty( + rt, + "now", + jsi::Function::createFromHostFunction( + rt, jsi::PropNameID::forAscii(rt, "now"), 0, chronoNow)); + rt.global().setProperty(rt, "performance", performance); } void RuntimeDecorator::decorateUIRuntime( @@ -109,6 +101,8 @@ void RuntimeDecorator::decorateUIRuntime( const ScrollToFunction scrollTo, const MeasuringFunction measure, const TimeProviderFunction getCurrentTime, + const RegisterSensorFunction registerSensor, + const UnregisterSensorFunction unregisterSensor, const SetGestureStateFunction setGestureState, std::shared_ptr layoutAnimationsProxy) { RuntimeDecorator::decorateRuntime(rt, "UI"); diff --git a/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h b/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h new file mode 100644 index 00000000000..76b652bd636 --- /dev/null +++ b/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include + +#include "PlatformDepMethodsHolder.h" +#include "RuntimeManager.h" + +namespace reanimated { + +using namespace facebook; + +enum SensorType { + ACCELEROMETER = 1, + GYROSCOPE = 2, + GRAVITY = 3, + MAGNETIC_FIELD = 4, + ROTATION_VECTOR = 5, +}; + +class AnimatedSensorModule { + std::unordered_set sensorsIds_; + RegisterSensorFunction platformRegisterSensorFunction_; + UnregisterSensorFunction platformUnregisterSensorFunction_; + RuntimeManager *runtimeManager_; + + public: + AnimatedSensorModule( + const PlatformDepMethodsHolder &platformDepMethodsHolder, + RuntimeManager *runtimeManager); + ~AnimatedSensorModule(); + + jsi::Value registerSensor( + jsi::Runtime &rt, + const jsi::Value &sensorType, + const jsi::Value &interval, + const jsi::Value &sensorDataContainer); + void unregisterSensor(const jsi::Value &sensorId); +}; + +} // namespace reanimated diff --git a/Common/cpp/headers/NativeModules/NativeReanimatedModule.h b/Common/cpp/headers/NativeModules/NativeReanimatedModule.h index 3db1ad08944..fdcea13424d 100644 --- a/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +++ b/Common/cpp/headers/NativeModules/NativeReanimatedModule.h @@ -5,6 +5,7 @@ #include #include +#include "AnimatedSensorModule.h" #include "ErrorHandler.h" #include "LayoutAnimationsProxy.h" #include "NativeReanimatedModuleSpec.h" @@ -70,6 +71,10 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config) override; + jsi::Value configureProps( + jsi::Runtime &rt, + const jsi::Value &uiProps, + const jsi::Value &nativeProps) override; void onRender(double timestampMs); void onEvent(std::string eventName, std::string eventAsString); @@ -78,6 +83,13 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, void maybeRequestRender(); UpdaterFunction updaterFunction; + jsi::Value registerSensor( + jsi::Runtime &rt, + const jsi::Value &sensorType, + const jsi::Value &interval, + const jsi::Value &sensorDataContainer) override; + void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override; + private: std::shared_ptr mapperRegistry; std::shared_ptr eventHandlerRegistry; @@ -89,6 +101,8 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, propObtainer; std::function onRenderCallback; std::shared_ptr layoutAnimationsProxy; + AnimatedSensorModule animatedSensorModule; + ConfigurePropsFunction configurePropsPlatformFunction; }; } // namespace reanimated diff --git a/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h b/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h index d89e27430ba..eae4509f0eb 100644 --- a/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +++ b/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h @@ -59,10 +59,24 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule { const jsi::Value &propName, const jsi::Value &callback) = 0; + // sensors + virtual jsi::Value registerSensor( + jsi::Runtime &rt, + const jsi::Value &sensorType, + const jsi::Value &interval, + const jsi::Value &sensorDataContainer) = 0; + virtual void unregisterSensor( + jsi::Runtime &rt, + const jsi::Value &sensorId) = 0; + // other virtual jsi::Value enableLayoutAnimations( jsi::Runtime &rt, const jsi::Value &config) = 0; + virtual jsi::Value configureProps( + jsi::Runtime &rt, + const jsi::Value &uiProps, + const jsi::Value &nativeProps) = 0; }; } // namespace reanimated diff --git a/Common/cpp/headers/SharedItems/MutableValue.h b/Common/cpp/headers/SharedItems/MutableValue.h index c28b2ff010a..b00f4eed478 100644 --- a/Common/cpp/headers/SharedItems/MutableValue.h +++ b/Common/cpp/headers/SharedItems/MutableValue.h @@ -20,13 +20,16 @@ class MutableValue : public jsi::HostObject, public StoreUser { private: friend MutableValueSetterProxy; - RuntimeManager *runtimeManager; friend LayoutAnimationsProxy; + + private: + RuntimeManager *runtimeManager; std::mutex readWriteMutex; std::shared_ptr value; std::weak_ptr animation; std::map> listeners; + public: void setValue(jsi::Runtime &rt, const jsi::Value &newValue); jsi::Value getValue(jsi::Runtime &rt); diff --git a/Common/cpp/headers/SharedItems/ShareableValue.h b/Common/cpp/headers/SharedItems/ShareableValue.h index da6f76cae4b..9d54763051d 100644 --- a/Common/cpp/headers/SharedItems/ShareableValue.h +++ b/Common/cpp/headers/SharedItems/ShareableValue.h @@ -6,6 +6,7 @@ #include #include #include +#include "AnimatedSensorModule.h" #include "HostFunctionHandler.h" #include "JSIStoreValueUser.h" #include "LayoutAnimationsProxy.h" @@ -24,6 +25,8 @@ class ShareableValue : public std::enable_shared_from_this, friend WorkletsCache; friend FrozenObject; friend LayoutAnimationsProxy; + friend NativeReanimatedModule; + friend AnimatedSensorModule; friend void extractMutables( jsi::Runtime &rt, std::shared_ptr sv, diff --git a/Common/cpp/headers/SharedItems/ValueWrapper.h b/Common/cpp/headers/SharedItems/ValueWrapper.h index 2e1193c8b9b..beaf8034f5d 100644 --- a/Common/cpp/headers/SharedItems/ValueWrapper.h +++ b/Common/cpp/headers/SharedItems/ValueWrapper.h @@ -12,8 +12,11 @@ namespace reanimated { class HostFunctionWrapper; +class AnimatedSensorModule; class ValueWrapper { + friend AnimatedSensorModule; + public: ValueWrapper() {} explicit ValueWrapper(ValueType _type) : type(_type) {} diff --git a/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h b/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h index 16784c513a9..2c6558556eb 100644 --- a/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +++ b/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h @@ -21,7 +21,15 @@ using ScrollToFunction = std::function; using MeasuringFunction = std::function>(int)>; using TimeProviderFunction = std::function; + +using RegisterSensorFunction = + std::function)>; +using UnregisterSensorFunction = std::function; using SetGestureStateFunction = std::function; +using ConfigurePropsFunction = std::function; struct PlatformDepMethodsHolder { RequestRender requestRender; @@ -29,7 +37,10 @@ struct PlatformDepMethodsHolder { ScrollToFunction scrollToFunction; MeasuringFunction measuringFunction; TimeProviderFunction getCurrentTime; + RegisterSensorFunction registerSensor; + UnregisterSensorFunction unregisterSensor; SetGestureStateFunction setGestureStateFunction; + ConfigurePropsFunction configurePropsFunction; }; } // namespace reanimated diff --git a/Common/cpp/headers/Tools/RuntimeDecorator.h b/Common/cpp/headers/Tools/RuntimeDecorator.h index 704cc746527..f38719759cb 100644 --- a/Common/cpp/headers/Tools/RuntimeDecorator.h +++ b/Common/cpp/headers/Tools/RuntimeDecorator.h @@ -36,6 +36,8 @@ class RuntimeDecorator { const ScrollToFunction scrollTo, const MeasuringFunction measure, const TimeProviderFunction getCurrentTime, + const RegisterSensorFunction registerSensor, + const UnregisterSensorFunction unregisterSensor, const SetGestureStateFunction setGestureState, std::shared_ptr layoutAnimationsProxy); diff --git a/Example/android/app/src/main/AndroidManifest.xml b/Example/android/app/src/main/AndroidManifest.xml index 7ba01a0c179..daf2374218e 100644 --- a/Example/android/app/src/main/AndroidManifest.xml +++ b/Example/android/app/src/main/AndroidManifest.xml @@ -16,13 +16,14 @@ android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + android:exported="true"> - + diff --git a/Example/android/app/src/main/java/com/swmansion/reanimated/example/MainApplication.java b/Example/android/app/src/main/java/com/swmansion/reanimated/example/MainApplication.java index 12839731437..06828081ad5 100644 --- a/Example/android/app/src/main/java/com/swmansion/reanimated/example/MainApplication.java +++ b/Example/android/app/src/main/java/com/swmansion/reanimated/example/MainApplication.java @@ -3,23 +3,18 @@ import android.app.Application; import android.content.Context; -import androidx.annotation.Nullable; - import com.facebook.react.ReactApplication; -import com.facebook.react.uimanager.UIImplementationProvider; import com.reactnativecommunity.picker.RNCPickerPackage; import com.swmansion.rnscreens.RNScreensPackage; import com.th3rdwave.safeareacontext.SafeAreaContextPackage; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.JSIModulePackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.horcrux.svg.SvgPackage; import com.reactnativepagerview.PagerViewPackage; import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; -import com.swmansion.reanimated.ReanimatedJSIModulePackage; import com.swmansion.reanimated.ReanimatedPackage; import org.reactnative.maskedview.RNCMaskedViewPackage; @@ -56,12 +51,6 @@ protected List getPackages() { protected String getJSMainModuleName() { return "index"; } - - @Nullable - @Override - protected JSIModulePackage getJSIModulePackage() { - return new ReanimatedJSIModulePackage(); - } }; @Override diff --git a/Example/android/build.gradle b/Example/android/build.gradle index 2a953d09cde..606ba85bbe4 100644 --- a/Example/android/build.gradle +++ b/Example/android/build.gradle @@ -14,8 +14,8 @@ buildscript { } dependencies { - classpath('com.android.tools.build:gradle:4.2.2') - classpath 'de.undercouch:gradle-download-task:4.1.2' + classpath("com.android.tools.build:gradle:4.2.2") + classpath("de.undercouch:gradle-download-task:4.1.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/Example/android/gradle.properties b/Example/android/gradle.properties index cfed4fdaaf1..57d73e244ff 100644 --- a/Example/android/gradle.properties +++ b/Example/android/gradle.properties @@ -19,5 +19,6 @@ android.useAndroidX=true android.enableJetifier=true # Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.99.0 -org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +FLIPPER_VERSION=0.125.0 +# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m +org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m diff --git a/Example/babel.config.js b/Example/babel.config.js index 21d83dc4e5e..c89f9199ce6 100644 --- a/Example/babel.config.js +++ b/Example/babel.config.js @@ -23,7 +23,7 @@ module.exports = (api) => { 'module-resolver', { alias: { - 'react-native-reanimated': '../src/Animated', + 'react-native-reanimated': '../src/index', react: './node_modules/react', 'react-native': './node_modules/react-native', '@babel': './node_modules/@babel', diff --git a/Example/ios/Podfile b/Example/ios/Podfile index cf54afeebb9..6846c221536 100644 --- a/Example/ios/Podfile +++ b/Example/ios/Podfile @@ -2,12 +2,17 @@ require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '11.0' +install! 'cocoapods', :deterministic_uuids => false config = use_native_modules! +flags = get_default_flags() + use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods - :hermes_enabled => false + :hermes_enabled => flags[:hermes_enabled], + :fabric_enabled => flags[:fabric_enabled], + :app_path => "#{Dir.pwd}/.." ) def pods() diff --git a/Example/ios/Podfile.lock b/Example/ios/Podfile.lock index 90a47bdd60b..ac573a5ca2d 100644 --- a/Example/ios/Podfile.lock +++ b/Example/ios/Podfile.lock @@ -1,14 +1,14 @@ PODS: - boost (1.76.0) - DoubleConversion (1.1.6) - - FBLazyVector (0.67.2) - - FBReactNativeSpec (0.67.2): + - FBLazyVector (0.68.0) + - FBReactNativeSpec (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTRequired (= 0.67.2) - - RCTTypeSafety (= 0.67.2) - - React-Core (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) + - RCTRequired (= 0.68.0) + - RCTTypeSafety (= 0.68.0) + - React-Core (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) - fmt (6.2.1) - glog (0.3.5) - RCT-Folly (2021.06.28.00-v2): @@ -22,192 +22,201 @@ PODS: - DoubleConversion - fmt (~> 6.2.1) - glog - - RCTRequired (0.67.2) - - RCTTypeSafety (0.67.2): - - FBLazyVector (= 0.67.2) + - RCTRequired (0.68.0) + - RCTTypeSafety (0.68.0): + - FBLazyVector (= 0.68.0) - RCT-Folly (= 2021.06.28.00-v2) - - RCTRequired (= 0.67.2) - - React-Core (= 0.67.2) - - React (0.67.2): - - React-Core (= 0.67.2) - - React-Core/DevSupport (= 0.67.2) - - React-Core/RCTWebSocket (= 0.67.2) - - React-RCTActionSheet (= 0.67.2) - - React-RCTAnimation (= 0.67.2) - - React-RCTBlob (= 0.67.2) - - React-RCTImage (= 0.67.2) - - React-RCTLinking (= 0.67.2) - - React-RCTNetwork (= 0.67.2) - - React-RCTSettings (= 0.67.2) - - React-RCTText (= 0.67.2) - - React-RCTVibration (= 0.67.2) - - React-callinvoker (0.67.2) - - React-Core (0.67.2): + - RCTRequired (= 0.68.0) + - React-Core (= 0.68.0) + - React (0.68.0): + - React-Core (= 0.68.0) + - React-Core/DevSupport (= 0.68.0) + - React-Core/RCTWebSocket (= 0.68.0) + - React-RCTActionSheet (= 0.68.0) + - React-RCTAnimation (= 0.68.0) + - React-RCTBlob (= 0.68.0) + - React-RCTImage (= 0.68.0) + - React-RCTLinking (= 0.68.0) + - React-RCTNetwork (= 0.68.0) + - React-RCTSettings (= 0.68.0) + - React-RCTText (= 0.68.0) + - React-RCTVibration (= 0.68.0) + - React-callinvoker (0.68.0) + - React-Codegen (0.68.0): + - FBReactNativeSpec (= 0.68.0) + - RCT-Folly (= 2021.06.28.00-v2) + - RCTRequired (= 0.68.0) + - RCTTypeSafety (= 0.68.0) + - React-Core (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-Core (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-Core/Default (= 0.67.2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-Core/Default (= 0.68.0) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/CoreModulesHeaders (0.67.2): + - React-Core/CoreModulesHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/Default (0.67.2): + - React-Core/Default (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/DevSupport (0.67.2): + - React-Core/DevSupport (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-Core/Default (= 0.67.2) - - React-Core/RCTWebSocket (= 0.67.2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-jsinspector (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-Core/Default (= 0.68.0) + - React-Core/RCTWebSocket (= 0.68.0) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-jsinspector (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTActionSheetHeaders (0.67.2): + - React-Core/RCTActionSheetHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTAnimationHeaders (0.67.2): + - React-Core/RCTAnimationHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTBlobHeaders (0.67.2): + - React-Core/RCTBlobHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTImageHeaders (0.67.2): + - React-Core/RCTImageHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTLinkingHeaders (0.67.2): + - React-Core/RCTLinkingHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTNetworkHeaders (0.67.2): + - React-Core/RCTNetworkHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTSettingsHeaders (0.67.2): + - React-Core/RCTSettingsHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTTextHeaders (0.67.2): + - React-Core/RCTTextHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTVibrationHeaders (0.67.2): + - React-Core/RCTVibrationHeaders (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - React-Core/Default - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-Core/RCTWebSocket (0.67.2): + - React-Core/RCTWebSocket (0.68.0): - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-Core/Default (= 0.67.2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsiexecutor (= 0.67.2) - - React-perflogger (= 0.67.2) + - React-Core/Default (= 0.68.0) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsiexecutor (= 0.68.0) + - React-perflogger (= 0.68.0) - Yoga - - React-CoreModules (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - React-CoreModules (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTTypeSafety (= 0.67.2) - - React-Core/CoreModulesHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - React-RCTImage (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-cxxreact (0.67.2): + - RCTTypeSafety (= 0.68.0) + - React-Codegen (= 0.68.0) + - React-Core/CoreModulesHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - React-RCTImage (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-cxxreact (0.68.0): - boost (= 1.76.0) - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-callinvoker (= 0.67.2) - - React-jsi (= 0.67.2) - - React-jsinspector (= 0.67.2) - - React-logger (= 0.67.2) - - React-perflogger (= 0.67.2) - - React-runtimeexecutor (= 0.67.2) - - React-jsi (0.67.2): + - React-callinvoker (= 0.68.0) + - React-jsi (= 0.68.0) + - React-jsinspector (= 0.68.0) + - React-logger (= 0.68.0) + - React-perflogger (= 0.68.0) + - React-runtimeexecutor (= 0.68.0) + - React-jsi (0.68.0): - boost (= 1.76.0) - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-jsi/Default (= 0.67.2) - - React-jsi/Default (0.67.2): + - React-jsi/Default (= 0.68.0) + - React-jsi/Default (0.68.0): - boost (= 1.76.0) - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-jsiexecutor (0.67.2): + - React-jsiexecutor (0.68.0): - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-perflogger (= 0.67.2) - - React-jsinspector (0.67.2) - - React-logger (0.67.2): + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-perflogger (= 0.68.0) + - React-jsinspector (0.68.0) + - React-logger (0.68.0): - glog - react-native-pager-view (5.4.1): - React-Core @@ -215,89 +224,89 @@ PODS: - React-Core - react-native-slider (4.1.7): - React-Core - - React-perflogger (0.67.2) - - React-RCTActionSheet (0.67.2): - - React-Core/RCTActionSheetHeaders (= 0.67.2) - - React-RCTAnimation (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - React-perflogger (0.68.0) + - React-RCTActionSheet (0.68.0): + - React-Core/RCTActionSheetHeaders (= 0.68.0) + - React-RCTAnimation (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTTypeSafety (= 0.67.2) - - React-Core/RCTAnimationHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTBlob (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - RCTTypeSafety (= 0.68.0) + - React-Codegen (= 0.68.0) + - React-Core/RCTAnimationHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTBlob (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - React-Core/RCTBlobHeaders (= 0.67.2) - - React-Core/RCTWebSocket (= 0.67.2) - - React-jsi (= 0.67.2) - - React-RCTNetwork (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTImage (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - React-Codegen (= 0.68.0) + - React-Core/RCTBlobHeaders (= 0.68.0) + - React-Core/RCTWebSocket (= 0.68.0) + - React-jsi (= 0.68.0) + - React-RCTNetwork (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTImage (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTTypeSafety (= 0.67.2) - - React-Core/RCTImageHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - React-RCTNetwork (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTLinking (0.67.2): - - FBReactNativeSpec (= 0.67.2) - - React-Core/RCTLinkingHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTNetwork (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - RCTTypeSafety (= 0.68.0) + - React-Codegen (= 0.68.0) + - React-Core/RCTImageHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - React-RCTNetwork (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTLinking (0.68.0): + - React-Codegen (= 0.68.0) + - React-Core/RCTLinkingHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTNetwork (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTTypeSafety (= 0.67.2) - - React-Core/RCTNetworkHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTSettings (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - RCTTypeSafety (= 0.68.0) + - React-Codegen (= 0.68.0) + - React-Core/RCTNetworkHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTSettings (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - RCTTypeSafety (= 0.67.2) - - React-Core/RCTSettingsHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-RCTText (0.67.2): - - React-Core/RCTTextHeaders (= 0.67.2) - - React-RCTVibration (0.67.2): - - FBReactNativeSpec (= 0.67.2) + - RCTTypeSafety (= 0.68.0) + - React-Codegen (= 0.68.0) + - React-Core/RCTSettingsHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-RCTText (0.68.0): + - React-Core/RCTTextHeaders (= 0.68.0) + - React-RCTVibration (0.68.0): - RCT-Folly (= 2021.06.28.00-v2) - - React-Core/RCTVibrationHeaders (= 0.67.2) - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) - - React-runtimeexecutor (0.67.2): - - React-jsi (= 0.67.2) - - ReactCommon/turbomodule/core (0.67.2): + - React-Codegen (= 0.68.0) + - React-Core/RCTVibrationHeaders (= 0.68.0) + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) + - React-runtimeexecutor (0.68.0): + - React-jsi (= 0.68.0) + - ReactCommon/turbomodule/core (0.68.0): - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-callinvoker (= 0.67.2) - - React-Core (= 0.67.2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-logger (= 0.67.2) - - React-perflogger (= 0.67.2) - - ReactCommon/turbomodule/samples (0.67.2): + - React-callinvoker (= 0.68.0) + - React-Core (= 0.68.0) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-logger (= 0.68.0) + - React-perflogger (= 0.68.0) + - ReactCommon/turbomodule/samples (0.68.0): - DoubleConversion - glog - RCT-Folly (= 2021.06.28.00-v2) - - React-callinvoker (= 0.67.2) - - React-Core (= 0.67.2) - - React-cxxreact (= 0.67.2) - - React-jsi (= 0.67.2) - - React-logger (= 0.67.2) - - React-perflogger (= 0.67.2) - - ReactCommon/turbomodule/core (= 0.67.2) + - React-callinvoker (= 0.68.0) + - React-Core (= 0.68.0) + - React-cxxreact (= 0.68.0) + - React-jsi (= 0.68.0) + - React-logger (= 0.68.0) + - React-perflogger (= 0.68.0) + - ReactCommon/turbomodule/core (= 0.68.0) - RNCMaskedView (0.1.10): - React - RNCPicker (1.8.1): - React-Core - RNGestureHandler (1.10.1): - React-Core - - RNReanimated (2.4.1): + - RNReanimated (2.8.0): - DoubleConversion - FBLazyVector - FBReactNativeSpec @@ -305,7 +314,6 @@ PODS: - RCT-Folly - RCTRequired - RCTTypeSafety - - React - React-callinvoker - React-Core - React-Core/DevSupport @@ -343,6 +351,7 @@ DEPENDENCIES: - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) - React (from `../node_modules/react-native/`) - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) + - React-Codegen (from `build/generated/ios`) - React-Core (from `../node_modules/react-native/`) - React-Core/DevSupport (from `../node_modules/react-native/`) - React-Core/RCTWebSocket (from `../node_modules/react-native/`) @@ -401,6 +410,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/" React-callinvoker: :path: "../node_modules/react-native/ReactCommon/callinvoker" + React-Codegen: + :path: build/generated/ios React-Core: :path: "../node_modules/react-native/" React-CoreModules: @@ -463,45 +474,46 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 - FBLazyVector: 244195e30d63d7f564c55da4410b9a24e8fbceaa - FBReactNativeSpec: c94002c1d93da3658f4d5119c6994d19961e3d52 + FBLazyVector: d2fd875e2b24bbc350722df0df9d383cb891b9f2 + FBReactNativeSpec: 7493e074a31512df3253160059295264a84b8149 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85 - RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685 - RCTRequired: cd47794163052d2b8318c891a7a14fcfaccc75ab - RCTTypeSafety: 393bb40b3e357b224cde53d3fec26813c52428b1 - React: dec6476bc27155b250eeadfc11ea779265f53ebf - React-callinvoker: e5047929e80aea942e6fdd96482504ef0189ca63 - React-Core: e382655566b2b9a6e3b4f641d777b7bfdbe52358 - React-CoreModules: cf262e82fa101c0aee022b6f90d1a5b612038b64 - React-cxxreact: 69d53de3b30c7c161ba087ca1ecdffed9ccb1039 - React-jsi: ce9a2d804adf75809ce2fe2374ba3fbbf5d59b03 - React-jsiexecutor: 52beb652bbc61201bd70cbe4f0b8edb607e8da4f - React-jsinspector: 595f76eba2176ebd8817a1fffd47b84fbdab9383 - React-logger: 23de8ea0f44fa00ee77e96060273225607fd4d78 + glog: 476ee3e89abb49e07f822b48323c51c57124b572 + RCT-Folly: 4d8508a426467c48885f1151029bc15fa5d7b3b8 + RCTRequired: bab4a7c3d7eb9553b13773ee190f279712efd1fc + RCTTypeSafety: efbeb6e450ff6cef8e19c2cb5314c6d8bfeeef77 + React: 28e4d45839b7d0fd9512af899e0379a17a5172ec + React-callinvoker: 5585d1ef6795786f288690b19e08bed253c33155 + React-Codegen: 80ce98fda08a8ddb6f47116375ae2c1670bf8cda + React-Core: 122639d111d791eb00c2bc8d678cfeec46671744 + React-CoreModules: 4dee89a87599055ca172e73924e27531eb4dd570 + React-cxxreact: 15728f254c7e3b94ac9d53c626bff554a7c42b10 + React-jsi: 4d135a7813ea815981b434ec37c6cfd8280b127b + React-jsiexecutor: 010a66edf644339f6da72b34208b070089680415 + React-jsinspector: 90f0bfd5d04e0b066c29216a110ffb9a6c34f23f + React-logger: 8474fefa09d05f573a13c044cb0dfd751d4e52e3 react-native-pager-view: 43f51f45f37ec9715f6c188e4af46ccdf79872e8 react-native-safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94 react-native-slider: 269d81247e2a87358ee03241da55b00c919e4d7a - React-perflogger: 3c9bb7372493e49036f07a82c44c8cf65cbe88db - React-RCTActionSheet: 052606483045a408693aa7e864410b4a052f541a - React-RCTAnimation: 08d4cac13222bb1348c687a0158dfd3b577cdb63 - React-RCTBlob: 928ad1df65219c3d9e2ac80983b943a75b5c3629 - React-RCTImage: 524d7313b142a39ee0e20fa312b67277917fe076 - React-RCTLinking: 44036ea6f13a2e46238be07a67566247fee35244 - React-RCTNetwork: 9b6faacf1e0789253e319ca53b1f8d92c2ac5455 - React-RCTSettings: ecd8094f831130a49581d5112a8607220e5d12a5 - React-RCTText: 14ba976fb48ed283cfdb1a754a5d4276471e0152 - React-RCTVibration: 99c7f67fba7a5ade46e98e870c6ff2444484f995 - React-runtimeexecutor: 2450b43df7ffe8e805a0b3dcb2abd4282f1f1836 - ReactCommon: d98c6c96b567f9b3a15f9fd4cc302c1eda8e3cf2 + React-perflogger: 15cb741d6c2379f4d3fc8f9e4d4e1110ef3020cb + React-RCTActionSheet: ea9099db0597bd769430db1e2d011fd5fdb7fc5e + React-RCTAnimation: 252df4749866f2654f37612f839522cac91c1165 + React-RCTBlob: ae9ea73c6f84685ad9cd8ba2275cce6eaa26699d + React-RCTImage: 99ae69c73d31e7937cb250a4f470ae6a3f5d16e4 + React-RCTLinking: cff4ca5547612607ae29a5859b466410a58a920d + React-RCTNetwork: 2783868d750a000d33a63bc3c3a140e6f812a735 + React-RCTSettings: 12fc409d5e337cda891058fe2fd1427fa23ab5e1 + React-RCTText: 6db924036c02a9fd98f30d9038756fafac17201c + React-RCTVibration: 82fc52d3d96549b8c59a6c8c017d5a1a11457049 + React-runtimeexecutor: 9b1304f48e344c55bb3c36e13bf11461cb4da5d8 + ReactCommon: fab89a13b52f1ac42b59a0e4b4f76f21aea9eebe RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f RNCPicker: 914b557e20b3b8317b084aca9ff4b4edb95f61e4 RNGestureHandler: 5e58135436aacc1c5d29b75547d3d2b9430d052c - RNReanimated: 32c91e28f5780937b8efc07ddde1bab8d373fe0b + RNReanimated: 64573e25e078ae6bec03b891586d50b9ec284393 RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e RNSVG: ce9d996113475209013317e48b05c21ee988d42e - Yoga: 9b6696970c3289e8dea34b3eda93f23e61fb8121 + Yoga: 6671cf077f614314c22fd09ddf87d7abeee64e96 -PODFILE CHECKSUM: 25fd0672c3ba04ab3b75893e5e63265b45d70e0b +PODFILE CHECKSUM: fa0d7532df10069310b893ce22140d558ba12fdc -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj b/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj index a0ec9cfc904..0067b8b1664 100644 --- a/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj +++ b/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj @@ -236,7 +236,7 @@ ORGANIZATIONNAME = Facebook; TargetAttributes = { 13B07F861A680F5B00A75B9A = { - DevelopmentTeam = J5FM626PE2; + DevelopmentTeam = H623Z5ALYX; }; 715B4D02242364A80073FC2F = { CreatedOnToolsVersion = 11.3.1; @@ -432,7 +432,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = NO; - DEVELOPMENT_TEAM = J5FM626PE2; + DEVELOPMENT_TEAM = H623Z5ALYX; HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", @@ -451,7 +451,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.cokolwiek.ReanimatedExample; + PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.mleko.ReanimatedExample; PRODUCT_NAME = ReanimatedExample; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; @@ -467,7 +467,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = J5FM626PE2; + DEVELOPMENT_TEAM = H623Z5ALYX; HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", @@ -480,7 +480,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.cokolwiek.ReanimatedExample; + PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.mleko.ReanimatedExample; PRODUCT_NAME = ReanimatedExample; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; diff --git a/Example/ios/ReanimatedExample/AppDelegate.m b/Example/ios/ReanimatedExample/AppDelegate.m index 9a0d8d6a87f..6592fc4281a 100644 --- a/Example/ios/ReanimatedExample/AppDelegate.m +++ b/Example/ios/ReanimatedExample/AppDelegate.m @@ -1,54 +1,41 @@ #import "AppDelegate.h" - #import #import #import - -#import -#import -#import -#import -#import -#import -#import +#import #import "MBFingerTipWindow.h" -@interface AppDelegate() -@end - @implementation AppDelegate - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + RCTAppSetupPrepareApp(application); RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge - moduleName:@"ReanimatedExample" - initialProperties:nil]; + UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"ReanimatedExample", nil); if (@available(iOS 13.0, *)) { - rootView.backgroundColor = [UIColor systemBackgroundColor]; + rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { - rootView.backgroundColor = [UIColor whiteColor]; + rootView.backgroundColor = [UIColor whiteColor]; } - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + const bool showTaps = true; if (showTaps) { MBFingerTipWindow *window = [[MBFingerTipWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; window.alwaysShowTouches = YES; self.window = window; } + UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; } - - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif diff --git a/Example/ios/ReanimatedExample/Info.plist b/Example/ios/ReanimatedExample/Info.plist index 29b80223901..9ed38dd98b4 100644 --- a/Example/ios/ReanimatedExample/Info.plist +++ b/Example/ios/ReanimatedExample/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion en CFBundleDisplayName @@ -51,7 +53,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - diff --git a/Example/package.json b/Example/package.json index 75f07062ca8..12e14706311 100644 --- a/Example/package.json +++ b/Example/package.json @@ -21,6 +21,7 @@ "e2e:tests": "yarn e2e:android && yarn e2e:ios" }, "dependencies": { + "@babel/plugin-proposal-export-namespace-from": "^7.17.12", "@fortawesome/fontawesome-svg-core": "^1.2.28", "@fortawesome/free-solid-svg-icons": "^5.13.0", "@fortawesome/react-native-fontawesome": "^0.2.3", @@ -35,7 +36,7 @@ "expo-asset": "^8.2.0", "react": "17.0.2", "react-dom": "^16.13.1", - "react-native": "0.67.2", + "react-native": "0.68.0", "react-native-gesture-handler": "^1.10.1", "react-native-pager-view": "^5.4.1", "react-native-safe-area-context": "^3.1.9", @@ -56,7 +57,7 @@ "babel-jest": "^26.6.3", "babel-plugin-module-resolver": "^3.2.0", "detox": "^18.20.3", - "eslint": "^7.14.0", + "eslint": "^7.32.0", "expo": "^41.0.1", "getenv": "^1.0.0", "glob-to-regexp": "^0.4.0", @@ -64,7 +65,8 @@ "jasmine-core": "^3.5.0", "jest": "^26.6.3", "jest-circus": "^27.1.0", - "metro-react-native-babel-preset": "^0.66.2", + "metro-react-native-babel-preset": "^0.67.0", + "react-native-gradle-plugin": "^0.0.4", "postinstall-postinstall": "^2.1.0", "react-test-renderer": "17.0.2" }, diff --git a/Example/src/AnimatedSensorExample.tsx b/Example/src/AnimatedSensorExample.tsx new file mode 100644 index 00000000000..da67bf52997 --- /dev/null +++ b/Example/src/AnimatedSensorExample.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import Animated, { + withTiming, + useAnimatedStyle, + useAnimatedSensor, + SensorType, +} from 'react-native-reanimated'; +import { View, Button, StyleSheet } from 'react-native'; + +export default function AnimatedStyleUpdateExample() { + const animatedSensor = useAnimatedSensor(SensorType.ROTATION, { + interval: 10, + }); + const style = useAnimatedStyle(() => { + const pitch = Math.abs(animatedSensor.sensor.value.pitch); + const roll = Math.abs(animatedSensor.sensor.value.roll); + return { + height: withTiming(pitch * 200 + 20, { duration: 100 }), + width: withTiming(roll * 200 + 20, { duration: 100 }), + }; + }); + + return ( + +