From 682ac25b6df5622e37bb46ef8fd3262699bcab8b Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 24 Oct 2024 14:25:29 +0200 Subject: [PATCH 1/8] migrate npx react-native init command to npx @react-native-community/cli init --- .github/workflows/V8-reanimated-build-check-nightly.yml | 2 +- .../static-framework-reanimated-build-check-nightly.yml | 2 +- .../windows-hosted-app-reanimated-build-check-nightly.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/V8-reanimated-build-check-nightly.yml b/.github/workflows/V8-reanimated-build-check-nightly.yml index 8731f252110..8742611f2e3 100644 --- a/.github/workflows/V8-reanimated-build-check-nightly.yml +++ b/.github/workflows/V8-reanimated-build-check-nightly.yml @@ -29,7 +29,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: Create React Native app - run: npx react-native init app + run: npx @react-native-community/cli init app - name: Install dependencies working-directory: app run: yarn install diff --git a/.github/workflows/static-framework-reanimated-build-check-nightly.yml b/.github/workflows/static-framework-reanimated-build-check-nightly.yml index 12edb57b0fd..16a07122fed 100644 --- a/.github/workflows/static-framework-reanimated-build-check-nightly.yml +++ b/.github/workflows/static-framework-reanimated-build-check-nightly.yml @@ -22,7 +22,7 @@ jobs: cancel-in-progress: true steps: - name: Create React Native app - run: npx react-native init app + run: npx @react-native-community/cli init app - name: Install Reanimated working-directory: app run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} diff --git a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml index c37406c4a00..95036d55581 100644 --- a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml +++ b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml @@ -23,7 +23,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: Create React Native App - run: npx react-native init app + run: npx @react-native-community/cli init app - name: Install dependencies working-directory: app run: yarn From a62da0fe1712a74c65af8071a7f3ca31c30d2f45 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 24 Oct 2024 14:43:43 +0200 Subject: [PATCH 2/8] remove spaces --- .github/workflows/V8-reanimated-build-check-nightly.yml | 2 +- .../static-framework-reanimated-build-check-nightly.yml | 2 +- .../windows-hosted-app-reanimated-build-check-nightly.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/V8-reanimated-build-check-nightly.yml b/.github/workflows/V8-reanimated-build-check-nightly.yml index 8742611f2e3..be0bd96efe9 100644 --- a/.github/workflows/V8-reanimated-build-check-nightly.yml +++ b/.github/workflows/V8-reanimated-build-check-nightly.yml @@ -29,7 +29,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: Create React Native app - run: npx @react-native-community/cli init app + run: npx @react-native-community/cli init app - name: Install dependencies working-directory: app run: yarn install diff --git a/.github/workflows/static-framework-reanimated-build-check-nightly.yml b/.github/workflows/static-framework-reanimated-build-check-nightly.yml index 16a07122fed..93a776d7049 100644 --- a/.github/workflows/static-framework-reanimated-build-check-nightly.yml +++ b/.github/workflows/static-framework-reanimated-build-check-nightly.yml @@ -22,7 +22,7 @@ jobs: cancel-in-progress: true steps: - name: Create React Native app - run: npx @react-native-community/cli init app + run: npx @react-native-community/cli init app - name: Install Reanimated working-directory: app run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} diff --git a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml index 95036d55581..0c321c97bdc 100644 --- a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml +++ b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml @@ -23,7 +23,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: Create React Native App - run: npx @react-native-community/cli init app + run: npx @react-native-community/cli init app - name: Install dependencies working-directory: app run: yarn From e16135f35b535cf19d6d6e38adbd7927733db776 Mon Sep 17 00:00:00 2001 From: Dawid Date: Fri, 25 Oct 2024 10:33:15 +0200 Subject: [PATCH 3/8] changed commit notation --- .github/workflows/V8-reanimated-build-check-nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/V8-reanimated-build-check-nightly.yml b/.github/workflows/V8-reanimated-build-check-nightly.yml index 4095cddfd9c..436e02c4c56 100644 --- a/.github/workflows/V8-reanimated-build-check-nightly.yml +++ b/.github/workflows/V8-reanimated-build-check-nightly.yml @@ -35,7 +35,7 @@ jobs: run: yarn install - name: Install Reanimated working-directory: app - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} + run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#${{ github.sha }} - name: Install test dependencies working-directory: app run: yarn add react-native-v8 v8-android-jit From 97054e6130faa1a5c2c297f789b103a1e1083334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBelawski?= Date: Thu, 21 Nov 2024 16:26:38 +0100 Subject: [PATCH 4/8] chore: merge main --- .../V8-reanimated-build-check-nightly.yml | 30 +- .../workflows/example-macos-build-check.yml | 2 +- .../workflows/example-tvos-build-check.yml | 4 +- ...nightly-reanimated-build-check-nightly.yml | 12 +- ...reanimated-compatibility-check-nightly.yml | 12 +- ...-typescript-compatibility-test-nightly.yml | 5 +- ...amework-reanimated-build-check-nightly.yml | 2 +- ...ted-app-reanimated-build-check-nightly.yml | 23 +- ...ommunity-slider-npm-4.5.3-6fedb47a11.patch | 32 - ...e-picker-picker-npm-2.8.0-9d55144b66.patch | 30 - ...tive-pager-view-npm-6.4.1-2322ade6e0.patch | 35 - ...e-area-context-npm-4.11.0-f8b3b898df.patch | 30 - ...native-screens-npm-3.34.0-3babbb1374.patch | Bin 4300 -> 0 bytes apps/common-app/package.json | 24 +- apps/common-app/src/App.tsx | 147 +- .../LayoutTransitionExample.tsx | 19 +- .../LayoutAnimations/NativeModals.tsx | 2 +- .../RuntimeTests/RuntimeTestsExample.tsx | 2 + .../animations/withTiming/basic.test.tsx | 88 +- .../tests/core/useDerivedValue/basic.test.tsx | 162 +- .../animationsCompilerApi.test.tsx | 153 + .../tests/plugin/fileWorkletization.ts | 11 +- .../tests/plugin/recursion.test.tsx | 18 +- .../tests/plugin/workletClasses.test.tsx | 43 + .../src/examples/ScreenStackExample.tsx | 20 +- .../SharedElementTransitions/BorderRadii.tsx | 2 +- .../SharedElementTransitions/ChangeTheme.tsx | 6 +- .../CustomTransition.tsx | 2 +- .../SharedElementTransitions/FlatList.tsx | 2 +- .../LayoutAnimation.tsx | 5 +- .../SharedElementTransitions/ManyScreens.tsx | 6 +- .../SharedElementTransitions/ManyTags.tsx | 2 +- .../SharedElementTransitions/Modals.tsx | 2 +- .../NestedRotation.tsx | 2 +- .../SharedElementTransitions/NestedStacks.tsx | 6 +- .../ReducedMotionSharedExample.tsx | 2 +- .../SharedElementTransitions/RestoreState.tsx | 4 +- .../TransitionRestart.tsx | 6 +- apps/fabric-example/Gemfile | 1 + apps/fabric-example/Gemfile.lock | 5 +- apps/fabric-example/android/app/build.gradle | 2 +- apps/fabric-example/android/build.gradle | 8 - apps/fabric-example/android/settings.gradle | 12 +- apps/fabric-example/common-app | 1 + apps/fabric-example/ios/Podfile.lock | 596 +-- apps/fabric-example/metro.config.js | 3 +- apps/fabric-example/package.json | 38 +- apps/macos-example/Gemfile | 7 +- apps/macos-example/Gemfile.lock | 59 +- .../MacOSExample.xcodeproj/project.pbxproj | 29 +- apps/macos-example/macos/Podfile | 7 +- apps/macos-example/macos/Podfile.lock | 1287 ++++-- apps/macos-example/metro.config.js | 1 - apps/macos-example/package.json | 35 +- apps/next-example/pages/_app.js | 1 + apps/next-example/pages/index.js | 1 + apps/next-example/pages/noreanimated.js | 1 + apps/next-example/pages/reanimated.js | 1 + apps/next-example/pages/ssg.js | 1 + apps/next-example/pages/ssr.js | 1 + apps/next-example/pages/test.js | 1 + apps/paper-example/Gemfile | 1 + apps/paper-example/Gemfile.lock | 5 +- apps/paper-example/android/app/build.gradle | 2 +- apps/paper-example/android/build.gradle | 8 - apps/paper-example/android/settings.gradle | 12 +- apps/paper-example/common-app | 1 + apps/paper-example/ios/Podfile.lock | 576 +-- apps/paper-example/metro.config.js | 3 +- apps/paper-example/package.json | 38 +- apps/tvos-example/.gitignore | 13 +- apps/tvos-example/Gemfile | 7 +- apps/tvos-example/Gemfile.lock | 59 +- apps/tvos-example/android/app/build.gradle | 119 + apps/tvos-example/android/app/debug.keystore | Bin 0 -> 2257 bytes .../android/app/proguard-rules.pro | 10 + .../android/app/src/debug/AndroidManifest.xml | 9 + .../android/app/src/main/AndroidManifest.xml | 32 + .../main/java/com/tvosexample/MainActivity.kt | 22 + .../java/com/tvosexample/MainApplication.kt | 44 + .../res/drawable/rn_edit_text_material.xml | 37 + .../app/src/main/res/drawable/tv_banner.png | Bin 0 -> 38229 bytes .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/styles.xml | 9 + apps/tvos-example/android/build.gradle | 21 + apps/tvos-example/android/gradle.properties | 39 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43583 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + apps/tvos-example/android/gradlew | 252 + apps/tvos-example/android/gradlew.bat | 94 + apps/tvos-example/android/settings.gradle | 6 + apps/tvos-example/ios/Podfile | 61 +- apps/tvos-example/ios/Podfile.lock | 1429 ++++-- .../ios/TVOSExample-tvOS/Info.plist | 53 - .../ios/TVOSExample-tvOSTests/Info.plist | 24 - .../ios/TVOSExample.xcodeproj/project.pbxproj | 513 +-- .../xcschemes/TVOSExample-tvOS.xcscheme | 88 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../ios/TVOSExample/AppDelegate.mm | 4 +- .../ios/TVOSExample/LaunchScreen.storyboard | 7 +- .../ios/TVOSExample/PrivacyInfo.xcprivacy | 37 + apps/tvos-example/jest.config.js | 1 - apps/tvos-example/metro.config.js | 3 +- apps/tvos-example/package.json | 29 +- apps/tvos-example/react-native.config.js | 13 - apps/web-example/package.json | 6 +- package.json | 8 +- .../docs/guides/compatibility.mdx | 4 +- .../docs-reanimated/docs/guides/worklets.mdx | 70 +- .../list-layout-animations.mdx | 2 +- .../docs/reanimated-babel-plugin/about.md | 1 + .../docs/threading/runOnUI.mdx | 2 + packages/docs-reanimated/docusaurus.config.js | 3 + .../src/components/Hero/StartScreen/index.tsx | 5 +- .../Hero/StartScreen/styles.module.css | 1 + packages/docs-reanimated/yarn.lock | 6 +- .../.yarn/releases/yarn-4.1.1.cjs | 893 ---- packages/react-native-reanimated/.yarnrc.yml | 7 - .../reanimated/Fabric/ReanimatedCommitHook.h | 12 - .../LayoutAnimationsProxy.cpp | 10 +- .../NativeModules/NativeReanimatedModule.cpp | 92 +- .../NativeModules/NativeReanimatedModule.h | 21 +- .../NativeModules/NativeWorkletsModule.cpp | 25 + .../NativeModules/NativeWorkletsModule.h | 23 + .../NativeWorkletsModuleSpec.cpp | 9 + .../NativeModules/NativeWorkletsModuleSpec.h | 18 + .../cpp/worklets/SharedItems/Shareables.cpp | 24 +- .../cpp/worklets/SharedItems/Shareables.h | 22 +- .../Common/cpp/worklets/Tools/JSScheduler.cpp | 4 +- .../Common/cpp/worklets/Tools/JSScheduler.h | 8 +- .../RNRuntimeWorkletDecorator.cpp | 14 + .../RNRuntimeWorkletDecorator.h | 19 + .../ReanimatedHermesRuntime.cpp | 4 - .../WorkletRuntime/ReanimatedHermesRuntime.h | 9 - .../RNReanimated.podspec | 33 +- .../__tests__/hooks.useSharedValue.test.tsx | 10 +- .../__typetests__/72plus/index.tsx | 54 - .../__typetests__/common/inlineStylesTest.tsx | 4 +- .../common/useAnimatedStyleTest.tsx | 4 +- .../__typetests__/legacy/legacy.tsx | 354 -- .../android/CMakeLists.txt | 6 +- .../android/build.gradle | 61 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../cpp/reanimated/android/NativeProxy.cpp | 80 +- .../main/cpp/reanimated/android/NativeProxy.h | 37 +- .../src/main/cpp/worklets/CMakeLists.txt | 6 + .../cpp/worklets/android/WorkletsModule.cpp | 42 + .../cpp/worklets/android/WorkletsModule.h | 54 + .../cpp/worklets/android/WorkletsOnLoad.cpp | 8 + .../swmansion/reanimated/DevMenuUtils.java | 0 .../swmansion/reanimated/NodesManager.java | 10 +- .../ReanimatedMessageQueueThread.java | 0 .../reanimated/ReanimatedPackage.java | 25 +- .../nativeProxy/NativeProxyCommon.java | 4 + .../swmansion/worklets/WorkletsModule.java | 51 + .../NativeReanimatedModuleSpec.java | 2 +- .../worklets/NativeWorkletsModuleSpec.java | 28 + .../com/swmansion/reanimated/NativeProxy.java | 121 - .../com/swmansion/reanimated/NativeProxy.java | 19 +- .../com/swmansion/reanimated/NativeProxy.java | 19 +- .../com/swmansion/reanimated/NativeProxy.java | 11 +- .../com/swmansion/reanimated/NativeProxy.java | 11 +- .../reanimated/ReactFeatureFlagsWrapper.java | 8 - .../swmansion/reanimated/DevMenuUtils.java | 22 - .../73/com/swmansion/ReanimatedModule.java | 127 - .../ReanimatedUIManager.java | 271 -- .../reanimated/ReanimatedModule.java | 13 +- .../reanimated/ReanimatedModule.java | 13 +- .../ReanimatedMessageQueueThread.java | 11 - .../LayoutReanimation/REASwizzledUIManager.mm | 4 - .../apple/reanimated/apple/REAModule.h | 4 - .../apple/reanimated/apple/REAModule.mm | 23 +- .../reanimated/apple/native/NativeProxy.h | 10 +- .../reanimated/apple/native/NativeProxy.mm | 18 +- .../native/PlatformDepMethodsHolderImpl.h | 4 +- .../native/PlatformDepMethodsHolderImpl.mm | 8 +- .../apple/worklets/apple/WorkletsModule.h | 9 + .../apple/worklets/apple/WorkletsModule.mm | 40 + .../createNPMPackage.sh | 4 +- .../metro-config/index.d.ts | 6 +- .../metro-config/index.js | 4 +- .../metro-config/tsconfig.json | 2 +- packages/react-native-reanimated/package.json | 21 +- .../react-native-reanimated/plugin/index.js | 4 +- .../plugin/package.json | 2 +- .../plugin/src/class.ts | 52 +- .../plugin/src/file.ts | 39 +- .../plugin/src/globals.ts | 29 + .../plugin/src/plugin.ts | 16 +- .../plugin/src/transform.ts | 28 + .../plugin/src/types.ts | 4 +- .../plugin/src/utils.ts | 22 - .../plugin/src/workletFactory.ts | 34 +- .../plugin/src/workletStringCode.ts | 13 +- .../scripts/reanimated_utils.rb | 18 +- .../scripts/set-reanimated-version.js | 5 +- .../scripts/validate-android.sh | 18 +- .../scripts/validate-apple.sh | 26 +- .../scripts/validate-common.sh | 18 +- .../src/NativeReanimated/index.ts | 6 - .../src/NativeReanimated/index.web.ts | 3 - .../NativeReanimated.ts | 108 +- .../src/ReanimatedModule/index.ts | 4 + .../src/ReanimatedModule/index.web.ts | 4 + .../js-reanimated/JSReanimated.ts | 37 +- .../js-reanimated/WebSensor.ts | 0 .../js-reanimated/index.ts | 27 +- .../js-reanimated/react-native-web.d.ts | 0 .../js-reanimated/webUtils.ts | 0 .../js-reanimated/webUtils.web.ts | 0 .../reanimatedModuleInstance.ts | 9 + .../reanimatedModuleInstance.web.ts | 5 + .../ReanimatedModule/reanimatedModuleProxy.ts | 74 + .../react-native-reanimated/src/Sensor.ts | 6 +- .../src/UpdateProps.ts | 9 +- .../src/animation/util.ts | 4 +- .../src/commonTypes.ts | 77 +- packages/react-native-reanimated/src/core.ts | 22 +- .../createAnimatedComponent.tsx | 2 +- .../createAnimatedComponent/getViewInfo.ts | 1 + .../src/fabricUtils.ts | 1 + .../src/hook/commonTypes.ts | 2 +- .../src/hook/useDerivedValue.ts | 6 - .../web/animationsManager.ts | 2 +- .../layoutReanimation/web/componentStyle.ts | 4 +- .../layoutReanimation/web/componentUtils.ts | 4 +- .../src/layoutReanimation/web/domUtils.ts | 4 +- .../web/transition/Curved.web.ts | 2 +- .../src/logger/logger.ts | 4 +- .../react-native-reanimated/src/mutables.ts | 8 +- .../platformFunctions/setNativeProps.web.ts | 4 +- .../src/privateGlobals.d.ts | 6 +- .../react-native-reanimated/src/runtimes.ts | 6 +- .../react-native-reanimated/src/shareables.ts | 6 +- .../src/specs/NativeReanimatedModule.ts | 2 +- .../src/specs/NativeWorkletsModule.ts | 12 + .../src/specs/index.ts | 6 + .../react-native-reanimated/src/threads.ts | 10 +- .../src/worklets/WorkletsModule/JSWorklets.ts | 9 + .../worklets/WorkletsModule/NativeWorklets.ts | 28 + .../src/worklets/WorkletsModule/index.ts | 4 + .../WorkletsModule/workletsModuleInstance.ts | 9 + .../workletsModuleInstance.web.ts | 5 + .../WorkletsModule/workletsModuleProxy.ts | 4 + .../src/worklets/index.ts | 4 + .../src/{ => worklets}/valueUnpacker.ts | 6 +- yarn.lock | 4038 ++++++++--------- 257 files changed, 7480 insertions(+), 7192 deletions(-) delete mode 100644 .yarn/patches/@react-native-community-slider-npm-4.5.3-6fedb47a11.patch delete mode 100644 .yarn/patches/@react-native-picker-picker-npm-2.8.0-9d55144b66.patch delete mode 100644 .yarn/patches/react-native-pager-view-npm-6.4.1-2322ade6e0.patch delete mode 100644 .yarn/patches/react-native-safe-area-context-npm-4.11.0-f8b3b898df.patch delete mode 100644 .yarn/patches/react-native-screens-npm-3.34.0-3babbb1374.patch create mode 100644 apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/animationsCompilerApi.test.tsx create mode 120000 apps/fabric-example/common-app create mode 120000 apps/paper-example/common-app create mode 100644 apps/tvos-example/android/app/build.gradle create mode 100644 apps/tvos-example/android/app/debug.keystore create mode 100644 apps/tvos-example/android/app/proguard-rules.pro create mode 100644 apps/tvos-example/android/app/src/debug/AndroidManifest.xml create mode 100644 apps/tvos-example/android/app/src/main/AndroidManifest.xml create mode 100644 apps/tvos-example/android/app/src/main/java/com/tvosexample/MainActivity.kt create mode 100644 apps/tvos-example/android/app/src/main/java/com/tvosexample/MainApplication.kt create mode 100644 apps/tvos-example/android/app/src/main/res/drawable/rn_edit_text_material.xml create mode 100644 apps/tvos-example/android/app/src/main/res/drawable/tv_banner.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 apps/tvos-example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 apps/tvos-example/android/app/src/main/res/values/strings.xml create mode 100644 apps/tvos-example/android/app/src/main/res/values/styles.xml create mode 100644 apps/tvos-example/android/build.gradle create mode 100644 apps/tvos-example/android/gradle.properties create mode 100644 apps/tvos-example/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 apps/tvos-example/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 apps/tvos-example/android/gradlew create mode 100644 apps/tvos-example/android/gradlew.bat create mode 100644 apps/tvos-example/android/settings.gradle delete mode 100644 apps/tvos-example/ios/TVOSExample-tvOS/Info.plist delete mode 100644 apps/tvos-example/ios/TVOSExample-tvOSTests/Info.plist delete mode 100644 apps/tvos-example/ios/TVOSExample.xcodeproj/xcshareddata/xcschemes/TVOSExample-tvOS.xcscheme delete mode 100644 apps/tvos-example/ios/TVOSExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 apps/tvos-example/ios/TVOSExample/PrivacyInfo.xcprivacy delete mode 100644 apps/tvos-example/react-native.config.js delete mode 100755 packages/react-native-reanimated/.yarn/releases/yarn-4.1.1.cjs delete mode 100644 packages/react-native-reanimated/.yarnrc.yml create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.cpp create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.h create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.cpp create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.h create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp create mode 100644 packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h delete mode 100644 packages/react-native-reanimated/__typetests__/72plus/index.tsx delete mode 100644 packages/react-native-reanimated/__typetests__/legacy/legacy.tsx create mode 100644 packages/react-native-reanimated/android/src/main/cpp/worklets/android/WorkletsModule.cpp create mode 100644 packages/react-native-reanimated/android/src/main/cpp/worklets/android/WorkletsModule.h create mode 100644 packages/react-native-reanimated/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp rename packages/react-native-reanimated/android/src/{reactNativeVersionPatch/ReactHost/latest => main/java}/com/swmansion/reanimated/DevMenuUtils.java (100%) rename packages/react-native-reanimated/android/src/{reactNativeVersionPatch/messageQueueThread/latest => main/java}/com/swmansion/reanimated/ReanimatedMessageQueueThread.java (100%) create mode 100644 packages/react-native-reanimated/android/src/main/java/com/swmansion/worklets/WorkletsModule.java create mode 100644 packages/react-native-reanimated/android/src/paper/java/com/swmansion/worklets/NativeWorkletsModuleSpec.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/NativeProxyFabric/73/com/swmansion/reanimated/NativeProxy.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/ReactFeatureFlagsWrapper/72/com/swmansion/reanimated/ReactFeatureFlagsWrapper.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion/ReanimatedModule.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java delete mode 100644 packages/react-native-reanimated/android/src/reactNativeVersionPatch/messageQueueThread/72/com/swmansion/reanimated/ReanimatedMessageQueueThread.java create mode 100644 packages/react-native-reanimated/apple/worklets/apple/WorkletsModule.h create mode 100644 packages/react-native-reanimated/apple/worklets/apple/WorkletsModule.mm create mode 100644 packages/react-native-reanimated/plugin/src/transform.ts delete mode 100644 packages/react-native-reanimated/src/NativeReanimated/index.ts delete mode 100644 packages/react-native-reanimated/src/NativeReanimated/index.web.ts rename packages/react-native-reanimated/src/{NativeReanimated => ReanimatedModule}/NativeReanimated.ts (54%) create mode 100644 packages/react-native-reanimated/src/ReanimatedModule/index.ts create mode 100644 packages/react-native-reanimated/src/ReanimatedModule/index.web.ts rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/JSReanimated.ts (90%) rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/WebSensor.ts (100%) rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/index.ts (88%) rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/react-native-web.d.ts (100%) rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/webUtils.ts (100%) rename packages/react-native-reanimated/src/{ => ReanimatedModule}/js-reanimated/webUtils.web.ts (100%) create mode 100644 packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleInstance.ts create mode 100644 packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleInstance.web.ts create mode 100644 packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleProxy.ts create mode 100644 packages/react-native-reanimated/src/specs/NativeWorkletsModule.ts create mode 100644 packages/react-native-reanimated/src/specs/index.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/JSWorklets.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/NativeWorklets.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/index.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/workletsModuleInstance.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/workletsModuleInstance.web.ts create mode 100644 packages/react-native-reanimated/src/worklets/WorkletsModule/workletsModuleProxy.ts create mode 100644 packages/react-native-reanimated/src/worklets/index.ts rename packages/react-native-reanimated/src/{ => worklets}/valueUnpacker.ts (96%) diff --git a/.github/workflows/V8-reanimated-build-check-nightly.yml b/.github/workflows/V8-reanimated-build-check-nightly.yml index 436e02c4c56..d38a9f8e0be 100644 --- a/.github/workflows/V8-reanimated-build-check-nightly.yml +++ b/.github/workflows/V8-reanimated-build-check-nightly.yml @@ -18,6 +18,9 @@ jobs: concurrency: group: build-v8-${{ github.ref }} cancel-in-progress: true + env: + APP_NAME: app + LATEST_SUPPORTED_RN_VERSION_IN_V8: 0.75 steps: - name: Check out uses: actions/checkout@v4 @@ -28,19 +31,30 @@ jobs: with: distribution: 'zulu' java-version: '17' - - name: Create React Native app - run: npx @react-native-community/cli init app + - name: + Setup Yarn + # Sometimes `npx react-native init` fails due to dependency mismatches or other + # rather vague errors. This is a workaround for that. + run: corepack enable && yarn init + - name: Install React Native + run: yarn add @react-native-community/cli + - name: Create app + run: | + yarn rnc-cli init ${{ env.APP_NAME }} --version ${{env.LATEST_SUPPORTED_RN_VERSION_IN_V8}} --skip-install --pm yarn --skip-install --install-pods false --skip-git-init + - name: Setup Yarn Modern + working-directory: ${{ env.APP_NAME }} + run: touch yarn.lock && yarn set version berry && yarn config set nodeLinker node-modules - name: Install dependencies - working-directory: app + working-directory: ${{ env.APP_NAME }} run: yarn install - name: Install Reanimated - working-directory: app - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#${{ github.sha }} + working-directory: ${{ env.APP_NAME }} + run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}" - name: Install test dependencies - working-directory: app + working-directory: ${{ env.APP_NAME }} run: yarn add react-native-v8 v8-android-jit - name: Configure V8 run: node reanimated_repo/.github/workflows/helper/configureV8.js - - name: Build Android app - working-directory: app/android + - name: Build Android + working-directory: ${{ env.APP_NAME }}/android run: ./gradlew assembleDebug --console=plain diff --git a/.github/workflows/example-macos-build-check.yml b/.github/workflows/example-macos-build-check.yml index f2873a8ed83..c714a884532 100644 --- a/.github/workflows/example-macos-build-check.yml +++ b/.github/workflows/example-macos-build-check.yml @@ -48,7 +48,7 @@ jobs: - name: Install Pods working-directory: ${{ env.WORKING_DIRECTORY }}/macos - run: bundle install && bundle exec pod install + run: bundle install && bundle exec pod update # There's some bug on the macOS runners for pod installation and this is the workaround. - name: Build app working-directory: ${{ env.WORKING_DIRECTORY }} diff --git a/.github/workflows/example-tvos-build-check.yml b/.github/workflows/example-tvos-build-check.yml index d708cf83770..67a548fcc9f 100644 --- a/.github/workflows/example-tvos-build-check.yml +++ b/.github/workflows/example-tvos-build-check.yml @@ -59,5 +59,5 @@ jobs: bundle exec pod install - name: Build app - working-directory: ${{ env.WORKING_DIRECTORY }} - run: yarn react-native-tvos run-ios --no-packager --scheme TVOSExample-tvOS --simulator "Apple TV" + working-directory: ${{ env.WORKING_DIRECTORY }}/ios + run: xcodebuild -workspace TVOSExample.xcworkspace -configuration Debug -scheme TVOSExample -destination "generic/platform=tvOS Simulator" -quiet diff --git a/.github/workflows/react-native-nightly-reanimated-build-check-nightly.yml b/.github/workflows/react-native-nightly-reanimated-build-check-nightly.yml index 9b7f2d33291..2491f8177cd 100644 --- a/.github/workflows/react-native-nightly-reanimated-build-check-nightly.yml +++ b/.github/workflows/react-native-nightly-reanimated-build-check-nightly.yml @@ -1,6 +1,6 @@ name: React Native nightly Reanimated build check [Nightly] env: - YARN_ENABLE_HARDENED_MODE: 0 + YARN_ENABLE_IMMUTABLE_INSTALLS: 0 on: pull_request: paths: @@ -46,19 +46,19 @@ jobs: - name: Create app run: | yarn react-native init ${{ env.APP_NAME }} --version ${{ env.REACT_NATIVE_TAG }} --pm yarn --skip-install --install-pods false --skip-git-init - - name: Add yarn.lock in app + - name: Setup Yarn Modern working-directory: ${{ env.APP_NAME }} - run: touch yarn.lock + run: touch yarn.lock && yarn set version berry - name: Install Reanimated working-directory: ${{ env.APP_NAME }} - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} + run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}" - name: Install Paper Pods (iOS) if: ${{ matrix.react-native-architecture == 'Paper' && matrix.platform == 'iOS' }} - working-directory: app/ios + working-directory: ${{ env.APP_NAME }}/ios run: bundle install && bundle exec pod install - name: Install Fabric Pods (iOS) if: ${{ matrix.react-native-architecture == 'Fabric' && matrix.platform == 'iOS' }} - working-directory: app/ios + working-directory: ${{ env.APP_NAME }}/ios run: RCT_NEW_ARCH_ENABLED=1 bundle install && bundle exec pod install - name: Setup Fabric (Android) if: ${{ matrix.react-native-architecture == 'Fabric' && matrix.platform == 'Android' }} diff --git a/.github/workflows/reanimated-compatibility-check-nightly.yml b/.github/workflows/reanimated-compatibility-check-nightly.yml index 0a7008f05b2..8bde71c666e 100644 --- a/.github/workflows/reanimated-compatibility-check-nightly.yml +++ b/.github/workflows/reanimated-compatibility-check-nightly.yml @@ -19,12 +19,12 @@ jobs: # Update it when dropping support for RN versions. react-native: [ - { version: '0.72', architecture: 'Paper' }, - { version: '0.73', architecture: 'Paper' }, { version: '0.74', architecture: 'Paper' }, { version: '0.74', architecture: 'Fabric' }, { version: '0.75', architecture: 'Paper' }, { version: '0.75', architecture: 'Fabric' }, + { version: '0.76', architecture: 'Paper' }, + { version: '0.76', architecture: 'Fabric' }, ] fail-fast: false env: @@ -53,19 +53,19 @@ jobs: run: corepack enable && yarn set version berry - name: Install Reanimated working-directory: ${{ env.APP_NAME }} - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} + run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}" - name: Install Pods if: ${{ matrix.platform == 'iOS' }} working-directory: ${{ env.APP_NAME }}/ios - run: bundle install && bundle exec pod install + run: bundle install && bundle exec pod update - name: Setup Fabric (Android) if: ${{ matrix.platform == 'Android' && matrix.react-native.architecture == 'Fabric' }} working-directory: ${{ env.APP_NAME }}/android run: sed -i 's/newArchEnabled=false/newArchEnabled=true/' gradle.properties - name: Build app (iOS) if: ${{ matrix.platform == 'iOS' }} - working-directory: ${{ env.APP_NAME }} - run: yarn react-native run-ios --simulator='iPhone 14' --terminal='Terminal'--mode=${{ matrix.mode }} + working-directory: ${{ env.APP_NAME }}/ios + run: xcodebuild -workspace ${{env.APP_NAME}}.xcworkspace -configuration ${{matrix.mode}} -scheme ${{env.APP_NAME}} -destination "generic/platform=iOS Simulator" -quiet - name: Build app (Android) if: ${{ matrix.platform == 'Android' }} working-directory: ${{ env.APP_NAME }}/android diff --git a/.github/workflows/reanimated-typescript-compatibility-test-nightly.yml b/.github/workflows/reanimated-typescript-compatibility-test-nightly.yml index 2cbeb838eee..0cc1a54bcbf 100644 --- a/.github/workflows/reanimated-typescript-compatibility-test-nightly.yml +++ b/.github/workflows/reanimated-typescript-compatibility-test-nightly.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: # TODO: Fetch versions from common source. - react-native-version: ['0.72', '0.73', '0.74', '0.75', nightly] + react-native-version: ['0.74', '0.75', '0.76', nightly] fail-fast: false concurrency: group: TS-react-native-nightly-${{ matrix.react-native-version }}-${{ github.ref }} @@ -52,6 +52,3 @@ jobs: - name: Run common type tests working-directory: packages/react-native-reanimated run: yarn type:check:tests:common - - name: Run 0.72+ type tests - working-directory: packages/react-native-reanimated - run: yarn type:check:tests:0.72+ diff --git a/.github/workflows/static-framework-reanimated-build-check-nightly.yml b/.github/workflows/static-framework-reanimated-build-check-nightly.yml index 2b76fecf0ea..2f561274370 100644 --- a/.github/workflows/static-framework-reanimated-build-check-nightly.yml +++ b/.github/workflows/static-framework-reanimated-build-check-nightly.yml @@ -26,7 +26,7 @@ jobs: run: npx @react-native-community/cli init app - name: Install Reanimated working-directory: app - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} + run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}" - name: Install Paper Pods if: ${{ matrix.react-native-architecture == 'Paper' }} working-directory: app/ios diff --git a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml index 8c2aac35b6a..dc188fe19b4 100644 --- a/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml +++ b/.github/workflows/windows-hosted-app-reanimated-build-check-nightly.yml @@ -17,20 +17,31 @@ jobs: concurrency: group: build-on-windows-${{ github.ref }} cancel-in-progress: true + env: + APP_NAME: app steps: - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' - - name: Create React Native App - run: npx @react-native-community/cli init app + - name: Setup Yarn + # Sometimes `npx react-native init` fails due to dependency mismatches or other + # rather vague errors. This is a workaround for that. + run: corepack enable && yarn init --yes + - name: Install React Native + run: yarn add @react-native-community/cli + - name: Create app + run: yarn rnc-cli init ${{ env.APP_NAME }} --pm yarn --skip-install --install-pods false --skip-git-init + - name: Setup Yarn Modern + working-directory: ${{ env.APP_NAME }} + run: touch yarn.lock && yarn set version berry - name: Install dependencies - working-directory: app + working-directory: ${{ env.APP_NAME }} run: yarn - name: Install Reanimated - working-directory: app - run: yarn add react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#commit=${{ github.sha }} + working-directory: ${{ env.APP_NAME }} + run: yarn add "react-native-reanimated@https://github.com/software-mansion/react-native-reanimated.git#workspace=react-native-reanimated&commit=${{ github.sha }}" - name: Build Android App - working-directory: app/android + working-directory: ${{ env.APP_NAME }}/android run: ./gradlew assembleDebug --console=plain diff --git a/.yarn/patches/@react-native-community-slider-npm-4.5.3-6fedb47a11.patch b/.yarn/patches/@react-native-community-slider-npm-4.5.3-6fedb47a11.patch deleted file mode 100644 index 950a9b98196..00000000000 --- a/.yarn/patches/@react-native-community-slider-npm-4.5.3-6fedb47a11.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt -index d338ae02ed7c95ef00c64195531e2a6b13bccc94..63c3ddc54bf71564e0685bd069ba4f9c59345856 100644 ---- a/android/src/main/jni/CMakeLists.txt -+++ b/android/src/main/jni/CMakeLists.txt -@@ -39,24 +39,9 @@ target_include_directories( - - target_link_libraries( - ${LIB_TARGET_NAME} -- fbjni -- folly_runtime -- glog -- jsi -- react_codegen_rncore -- react_debug -- react_render_componentregistry -- react_render_core -- react_render_debug -- react_render_graphics -- react_render_imagemanager -- react_render_mapbuffer -- react_utils -- react_nativemodule_core -- rrc_image -- turbomodulejsijni -- rrc_view -- yoga -+ fbjni::fbjni -+ ReactAndroid::jsi -+ ReactAndroid::reactnative - ) - - target_compile_options( diff --git a/.yarn/patches/@react-native-picker-picker-npm-2.8.0-9d55144b66.patch b/.yarn/patches/@react-native-picker-picker-npm-2.8.0-9d55144b66.patch deleted file mode 100644 index b18830272f8..00000000000 --- a/.yarn/patches/@react-native-picker-picker-npm-2.8.0-9d55144b66.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt -index db67583f747279edc23dcf4e0da52485a6b52eb6..c69831a0d8780bc6f4497b9afc97a2f766361547 100644 ---- a/android/src/main/jni/CMakeLists.txt -+++ b/android/src/main/jni/CMakeLists.txt -@@ -37,22 +37,9 @@ target_include_directories( - - target_link_libraries( - ${LIB_TARGET_NAME} -- fbjni -- folly_runtime -- glog -- jsi -- react_codegen_rncore -- react_debug -- react_nativemodule_core -- react_render_componentregistry -- react_utils -- react_render_core -- react_render_debug -- react_render_graphics -- react_render_mapbuffer -- rrc_view -- turbomodulejsijni -- yoga -+ fbjni::fbjni -+ ReactAndroid::jsi -+ ReactAndroid::reactnative - ) - - target_compile_options( diff --git a/.yarn/patches/react-native-pager-view-npm-6.4.1-2322ade6e0.patch b/.yarn/patches/react-native-pager-view-npm-6.4.1-2322ade6e0.patch deleted file mode 100644 index 95da953fa1a..00000000000 --- a/.yarn/patches/react-native-pager-view-npm-6.4.1-2322ade6e0.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt b/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt -index e9c4a52d4b98550b4c8f326ccf9b9bbf66cb615b..f946583453eff7d17a464df127a992952d706127 100644 ---- a/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt -+++ b/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt -@@ -37,7 +37,7 @@ class PagerViewViewManager : ViewGroupManager(), RNCViewPa - return PagerViewViewManagerImpl.NAME - } - -- override fun receiveCommand(root: NestedScrollableHost, commandId: String?, args: ReadableArray?) { -+ override fun receiveCommand(root: NestedScrollableHost, commandId: String, args: ReadableArray?) { - mDelegate.receiveCommand(root, commandId, args) - } - -diff --git a/android/src/paper/java/com/reactnativepagerview/PagerViewViewManager.kt b/android/src/paper/java/com/reactnativepagerview/PagerViewViewManager.kt -index 959362c62af06f791088c416e2db8f1629ab63ce..6c1e385dbc4e78af2d0449498fcd77acda57482f 100644 ---- a/android/src/paper/java/com/reactnativepagerview/PagerViewViewManager.kt -+++ b/android/src/paper/java/com/reactnativepagerview/PagerViewViewManager.kt -@@ -34,7 +34,7 @@ class PagerViewViewManager : ViewGroupManager() { - vp.adapter = ViewPagerAdapter() - //https://github.com/callstack/react-native-viewpager/issues/183 - vp.isSaveEnabled = false -- eventDispatcher = reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher -+ eventDispatcher = reactContext.getNativeModule(UIManagerModule::class.java)!!.getEventDispatcher() - - vp.post { - vp.registerOnPageChangeCallback(object : OnPageChangeCallback() { -@@ -132,7 +132,7 @@ class PagerViewViewManager : ViewGroupManager() { - PageSelectedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageSelected")) - } - -- override fun receiveCommand(root: NestedScrollableHost, commandId: String?, args: ReadableArray?) { -+ override fun receiveCommand(root: NestedScrollableHost, commandId: String, args: ReadableArray?) { - super.receiveCommand(root, commandId, args) - val view = PagerViewViewManagerImpl.getViewPager(root) - Assertions.assertNotNull(view) diff --git a/.yarn/patches/react-native-safe-area-context-npm-4.11.0-f8b3b898df.patch b/.yarn/patches/react-native-safe-area-context-npm-4.11.0-f8b3b898df.patch deleted file mode 100644 index 7e07dba7c67..00000000000 --- a/.yarn/patches/react-native-safe-area-context-npm-4.11.0-f8b3b898df.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt -index 4ee1c8fc858c1402a3e58426ed468dad950c404a..3f63637ebbb121344caed99f63909055d947e22b 100644 ---- a/android/src/main/jni/CMakeLists.txt -+++ b/android/src/main/jni/CMakeLists.txt -@@ -39,22 +39,9 @@ target_include_directories( - - target_link_libraries( - ${LIB_TARGET_NAME} -- fbjni -- folly_runtime -- glog -- jsi -- react_codegen_rncore -- react_debug -- react_nativemodule_core -- react_render_core -- react_render_debug -- react_render_graphics -- react_render_mapbuffer -- react_render_componentregistry -- react_utils -- rrc_view -- turbomodulejsijni -- yoga -+ fbjni::fbjni -+ ReactAndroid::jsi -+ ReactAndroid::reactnative - ) - - target_compile_options( diff --git a/.yarn/patches/react-native-screens-npm-3.34.0-3babbb1374.patch b/.yarn/patches/react-native-screens-npm-3.34.0-3babbb1374.patch deleted file mode 100644 index c34dd5f21415313954ff43f3c6987e7df2052840..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4300 zcmb_fZExE)5bn_Ji@y!n4-l|^XyI5UsTY#L1|-dbbwis0X|R16An@hrsF5X?lJbJ0 zKW*4g+FuxD*-7L$veR0yEtz+u?vD37chspd-e@#QD^H9?u5FR(u|KgwXE0_yAFFdv z7iB#y@1FduP#2zjlKLQrE6=1Ec+*0IhY^ayaFFI2u06En<@=1A2nF02CWHzZC`lt` zKvK#H)hv=mpa2jWj7B4Gtl@H;*I70g4u?-Q_u#-Ap*`dcv3GDV7(V~+-+zApP`Tgl z-S^LDi)-+=cT#xHwJgoS6O{+K_6jq1bf7ndR>REcL#|RNM?xtm%fgo9iSlQ*n1QX_ z_#<|2Gj%s1hnQ<1TuP#`j>907OcE}D(nx5g2!u>U0mqx&ZFc|YT;vld$C)Urk*w29 z`!dZRaq{sAyK&9XSZfk6p#d?DDZ~^L8ixYMf)Iov5uu0%dh2ZJF?c1Po_$^BG%tE1 z%5xXVyT?9Q-f68)*i9&1*borI1&auYY0PoN1!XY}6xKn=I0W{jb)zwi3BCluTheMBL%R|k_Chx{&5jDA? zV`C&l6i3QLpaqtKMpVZLGs-XrF1E^?Cm6q)MeNEY&rj9Ww|6=8&6k68jUh_7Qrge# zTg=)`(4zoTVxquRPM|^t26L&EWCk-~xC$YNv^E;PH0Z0o-oxx3nHSU_&(3S_JAb_I)e3DYn#GNQ2z0xgV|5ECjO6byx75CxKIEhWRg@5&mEwLpMl0L=lj z5F?>Us9hCDL`ca)ATe3CV@=m|*9ES;yxT;r2pcqo;T|F0(A}upVlOo>Uwk?}d7qpd z|CJn`9=%D9PYz$dJ^tnMtAW>Cm9P`264yFixF2bSb^XrER@TUEUMdTamv=+W@F@sY z9k!k7{{DwD9gLdc<<%A2Mmfnvm0p5tJnIY+RalqTOZDcyZc1IHS-DZIUHC)ZYl9Ke zrfP#yYp4cUPd2_au}#}(H+xd&RXPQ@231#u-FjVzz1exH`rWrGxlG}zZ_%4#;%K`k z(r%3kuB$$sNme{1Ak$fqLta^!I5gRtzLndE--a?T-3-@@Z!yQU=BBVykt;}=05{G5 z)^93g3AUlN1TLMWn9nYQaEhuCiJ~qEidX0i~s(!BV`2pk91> z``hc}?C|v0U!Z l>7B%N|4$!~`GdjvtCk>erQ>#A8pGT)._IS_FABRIC; } -function noop() { - // do nothing -} - type RootStackParamList = { [P in keyof typeof EXAMPLES]: undefined } & { Home: undefined; }; @@ -65,27 +57,24 @@ function findExamples(search: string) { } function HomeScreen({ navigation }: HomeScreenProps) { - // TODO: Currently it breaks on @react-navigation - // eslint-disable-next-line @typescript-eslint/no-unused-vars const [search, setSearch] = React.useState(''); const [wasClicked, setWasClicked] = React.useState([]); React.useLayoutEffect(() => { - // TODO: Currently it breaks on @react-navigation - // navigation.setOptions({ - // headerSearchBarOptions: { - // onChangeText: (event) => { - // setSearch(event.nativeEvent.text); - // }, - // onSearchButtonPress: (event) => { - // const results = findExamples(event.nativeEvent.text); - // if (results.length >= 1) { - // navigation.navigate(results[0]); - // } - // }, - // }, - // headerTransparent: false, - // }); + navigation.setOptions({ + headerSearchBarOptions: { + onChangeText: (event) => { + setSearch(event.nativeEvent.text); + }, + onSearchButtonPress: (event) => { + const results = findExamples(event.nativeEvent.text); + if (results.length >= 1) { + navigation.navigate(results[0]); + } + }, + }, + headerTransparent: false, + }); }, [navigation]); return ( @@ -168,53 +157,19 @@ const linking = { }; function BackButton(props: HeaderBackButtonProps) { - const navigation = useNavigation>(); + const navigation = useNavigation< + | StackNavigationProp + | NativeStackNavigationProp + >(); return ( - navigation.navigate('Home')} /> + navigation.popTo('Home')} /> ); } -// copied from https://reactnavigation.org/docs/state-persistence/ -const PERSISTENCE_KEY = 'NAVIGATION_STATE_V1'; - export default function App() { - const [isReady, setIsReady] = React.useState(!__DEV__); - const [initialState, setInitialState] = React.useState(); - - React.useEffect(() => { - const restoreState = async () => { - try { - const initialUrl = await Linking.getInitialURL(); - - if ( - Platform.OS !== 'web' && - Platform.OS !== 'macos' && - initialUrl == null - ) { - // Only restore state if there's no deep link and we're not on web - const savedStateString = await AsyncStorage.getItem(PERSISTENCE_KEY); - const state = savedStateString - ? JSON.parse(savedStateString) - : undefined; - - if (state !== undefined) { - setInitialState(state); - } - } - } finally { - setIsReady(true); - } - }; - - if (!isReady) { - restoreState().catch(noop); - } - }, [isReady]); - - const persistNavigationState = useCallback((state?: NavigationState) => { - AsyncStorage.setItem(PERSISTENCE_KEY, JSON.stringify(state)).catch(noop); - }, []); + const { isReady, navigationState, updateNavigationState } = + useNavigationState(); const shouldReduceMotion = useReducedMotion(); @@ -230,8 +185,8 @@ export default function App() { + initialState={navigationState} + onStateChange={updateNavigationState}> (); + + const updateNavigationState = useCallback((state?: NavigationState) => { + AsyncStorage.setItem(PERSISTENCE_KEY, JSON.stringify(state)).catch(noop); + }, []); + + React.useEffect(() => { + const restoreState = async () => { + try { + const initialUrl = await Linking.getInitialURL(); + + if ( + Platform.OS !== 'web' && + Platform.OS !== 'macos' && + initialUrl == null + ) { + // Only restore state if there's no deep link and we're not on web + const savedStateString = await AsyncStorage.getItem(PERSISTENCE_KEY); + // Erase the state immediately after fetching it. + // This prevents the app to boot on the screen that previously crashed. + updateNavigationState(); + const state = savedStateString + ? JSON.parse(savedStateString) + : undefined; + + if (state !== undefined) { + setNavigationState(state); + } + } + } finally { + setIsReady(true); + } + }; + + if (!isReady) { + restoreState().catch(noop); + } + }, [isReady, updateNavigationState]); + + return { isReady, navigationState, updateNavigationState }; +} + const styles = StyleSheet.create({ container: { flex: 1, diff --git a/apps/common-app/src/examples/LayoutAnimations/LayoutTransitionExample.tsx b/apps/common-app/src/examples/LayoutAnimations/LayoutTransitionExample.tsx index 35959ae67f9..eb36fb162f3 100644 --- a/apps/common-app/src/examples/LayoutAnimations/LayoutTransitionExample.tsx +++ b/apps/common-app/src/examples/LayoutAnimations/LayoutTransitionExample.tsx @@ -19,7 +19,10 @@ import Animated, { FlipOutYRight, } from 'react-native-reanimated'; import { createStackNavigator } from '@react-navigation/stack'; -import { NavigationContainer } from '@react-navigation/native'; +import { + NavigationContainer, + NavigationIndependentTree, +} from '@react-navigation/native'; import type { StackScreenProps } from '@react-navigation/stack'; interface Item { @@ -92,12 +95,14 @@ const Stack = createStackNavigator(); export default function Layout() { return ( - - - - - - + + + + + + + + ); } diff --git a/apps/common-app/src/examples/LayoutAnimations/NativeModals.tsx b/apps/common-app/src/examples/LayoutAnimations/NativeModals.tsx index 3c92240044a..9f2503ce476 100644 --- a/apps/common-app/src/examples/LayoutAnimations/NativeModals.tsx +++ b/apps/common-app/src/examples/LayoutAnimations/NativeModals.tsx @@ -66,7 +66,7 @@ const App = ({ navigation.navigate('Home')}> + onPress={() => navigation.popTo('Home')}> Go back diff --git a/apps/common-app/src/examples/RuntimeTests/RuntimeTestsExample.tsx b/apps/common-app/src/examples/RuntimeTests/RuntimeTestsExample.tsx index 59da4a81f0d..6a460dbf4ef 100644 --- a/apps/common-app/src/examples/RuntimeTests/RuntimeTestsExample.tsx +++ b/apps/common-app/src/examples/RuntimeTests/RuntimeTestsExample.tsx @@ -49,6 +49,8 @@ export default function RuntimeTestsExample() { require('./tests/core/useAnimatedStyle/reuseAnimatedStyle.test'); require('./tests/core/useDerivedValue/basic.test'); require('./tests/core/useDerivedValue/chain.test'); + + require('./tests/core/useSharedValue/animationsCompilerApi.test'); }, }, { diff --git a/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/basic.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/basic.test.tsx index d1192fdc43c..f7cd63ceb50 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/basic.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/animations/withTiming/basic.test.tsx @@ -27,7 +27,15 @@ const WIDTH_COMPONENT_PASSIVE_REF = 'WidthComponentPassive'; type Width = number | `${number}%` | 'auto'; describe('withTiming animation of WIDTH', () => { - const WidthComponent = ({ startWidth, finalWidth }: { startWidth: Width; finalWidth: Width }) => { + const WidthComponent = ({ + startWidth, + finalWidth, + compilerApi, + }: { + startWidth: Width; + finalWidth: Width; + compilerApi: boolean; + }) => { const widthActiveSV = useSharedValue(startWidth); const widthPassiveSV = useSharedValue(startWidth); @@ -36,22 +44,30 @@ describe('withTiming animation of WIDTH', () => { const styleActive = useAnimatedStyle(() => { return { - width: withTiming(widthActiveSV.value, { duration: 500 }), + width: withTiming(compilerApi ? widthActiveSV.get() : widthActiveSV.value, { duration: 500 }), }; }); const stylePassive = useAnimatedStyle(() => { return { - width: widthPassiveSV.value, + width: compilerApi ? widthPassiveSV.get() : widthPassiveSV.value, }; }); useEffect(() => { - widthActiveSV.value = finalWidth; - }, [widthActiveSV, finalWidth]); + if (compilerApi) { + widthActiveSV.set(finalWidth); + } else { + widthActiveSV.value = finalWidth; + } + }, [widthActiveSV, finalWidth, compilerApi]); useEffect(() => { - widthPassiveSV.value = withTiming(finalWidth, { duration: 500 }); - }, [widthPassiveSV, finalWidth]); + if (compilerApi) { + widthPassiveSV.set(withTiming(finalWidth, { duration: 500 })); + } else { + widthPassiveSV.value = withTiming(finalWidth, { duration: 500 }); + } + }, [widthPassiveSV, finalWidth, compilerApi]); return ( @@ -69,31 +85,41 @@ describe('withTiming animation of WIDTH', () => { finalWidth: Width; finalWidthInPixels: number; description: string; + compilerApi: boolean; } - test.each([ - { startWidth: 0, finalWidth: 100, finalWidthInPixels: 100, description: 'width in pixels' }, - { - startWidth: '0%', - finalWidth: '100%', - finalWidthInPixels: Dimensions.get('window').width, - description: 'width in percents', - }, - { - startWidth: '0%', - finalWidth: '75%', - finalWidthInPixels: Dimensions.get('window').width * 0.75, - description: 'width in percents', - }, - { - startWidth: 20, - finalWidth: '40%', - finalWidthInPixels: Dimensions.get('window').width * 0.4, - description: 'width from pixels to percents (not supported)', - }, - ] as Array)( + test.each( + [ + { startWidth: 0, finalWidth: 100, finalWidthInPixels: 100, description: 'width in pixels' }, + { + startWidth: '0%', + finalWidth: '100%', + finalWidthInPixels: Dimensions.get('window').width, + description: 'width in percents', + }, + { + startWidth: '0%', + finalWidth: '75%', + finalWidthInPixels: Dimensions.get('window').width * 0.75, + description: 'width in percents', + }, + { + startWidth: 20, + finalWidth: '40%', + finalWidthInPixels: Dimensions.get('window').width * 0.4, + description: 'width from pixels to percents (not supported)', + }, + ].reduce( + (acc, element) => [ + ...acc, + { ...element, compilerApi: false }, + { ...element, compilerApi: true, description: `${element.description} (compiler API)` }, + ], + [] as Record[], + ) as unknown as Array, + )( '${description}, from ${startWidth} to ${finalWidth}', - async ({ startWidth, finalWidth, finalWidthInPixels }: TestCase) => { - await render(); + async ({ startWidth, finalWidth, finalWidthInPixels, compilerApi }: TestCase) => { + await render(); const componentActive = getTestComponent(WIDTH_COMPONENT_ACTIVE_REF); const WidthComponentPassive = getTestComponent(WIDTH_COMPONENT_PASSIVE_REF); await wait(1000); @@ -103,7 +129,7 @@ describe('withTiming animation of WIDTH', () => { ); test('Width from percent to pixels is NOT handled correctly', async () => { - await render(); + await render(); const componentActive = getTestComponent(WIDTH_COMPONENT_ACTIVE_REF); const WidthComponentPassive = getTestComponent(WIDTH_COMPONENT_PASSIVE_REF); await wait(1000); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx index 71e7a247cab..fb4cbdce871 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/core/useDerivedValue/basic.test.tsx @@ -43,12 +43,14 @@ describe('Test useDerivedValue changing width', () => { animate, animationType, deriveFunction, + compilerApi, }: { startWidth: number; finalWidth: number; animate: AnimationLocation; animationType: AnimationType; deriveFunction: (a: number) => number; + compilerApi: boolean; }) => { const basicValue = useSharedValue(startWidth); const componentRef = useTestRef(WIDTH_COMPONENT); @@ -60,20 +62,30 @@ describe('Test useDerivedValue changing width', () => { if (animate === AnimationLocation.ANIMATED_STYLE) { return { width: - animationType === AnimationType.TIMING ? withTiming(derivedValue.value) : withSpring(derivedValue.value), + animationType === AnimationType.TIMING + ? withTiming(compilerApi ? derivedValue.get() : derivedValue.value) + : withSpring(compilerApi ? derivedValue.get() : derivedValue.value), }; } else { - return { width: derivedValue.value }; + return { width: compilerApi ? derivedValue.get() : derivedValue.value }; } }); useEffect(() => { if (animate === AnimationLocation.USE_EFFECT) { - basicValue.value = animationType === AnimationType.TIMING ? withTiming(finalWidth) : withSpring(finalWidth); + if (compilerApi) { + basicValue.set(animationType === AnimationType.TIMING ? withTiming(finalWidth) : withSpring(finalWidth)); + } else { + basicValue.value = animationType === AnimationType.TIMING ? withTiming(finalWidth) : withSpring(finalWidth); + } } else { - basicValue.value = finalWidth; + if (compilerApi) { + basicValue.set(finalWidth); + } else { + basicValue.value = finalWidth; + } } - }, [basicValue, finalWidth, animate, animationType]); + }, [basicValue, finalWidth, animate, animationType, compilerApi]); return ( @@ -108,6 +120,7 @@ describe('Test useDerivedValue changing width', () => { finalWidth: number, animate: AnimationLocation, animationType: AnimationType, + compilerApi: boolean, ) { await mockAnimationTimer(); const updatesContainerActive = await recordAnimationUpdates(); @@ -118,6 +131,7 @@ describe('Test useDerivedValue changing width', () => { animate={animate} animationType={animationType} deriveFunction={derivedFun} + compilerApi={compilerApi} />, ); const testComponent = getTestComponent(WIDTH_COMPONENT); @@ -129,68 +143,81 @@ describe('Test useDerivedValue changing width', () => { return [updates, naiveUpdates]; } - test.each([ - { - startWidth: 0, - finalWidth: 100, - animate: AnimationLocation.USE_EFFECT, - animationType: AnimationType.TIMING, - }, - { - startWidth: 0, - finalWidth: 100, - animate: AnimationLocation.ANIMATED_STYLE, - animationType: AnimationType.TIMING, - }, - { - startWidth: 0, - finalWidth: 100, - animate: AnimationLocation.ANIMATED_STYLE, - animationType: AnimationType.SPRING, - }, - { - startWidth: 0, - finalWidth: 100, - animate: AnimationLocation.USE_EFFECT, - animationType: AnimationType.SPRING, - }, - { - startWidth: 0, - finalWidth: 100, - animate: AnimationLocation.NONE, - animationType: AnimationType.NONE, - }, - { - startWidth: 100, - finalWidth: 20, - animate: AnimationLocation.USE_EFFECT, - animationType: AnimationType.TIMING, - }, - { - startWidth: 400, - finalWidth: 300, - animate: AnimationLocation.ANIMATED_STYLE, - animationType: AnimationType.TIMING, - }, - { - startWidth: 20, - finalWidth: 100, - animate: AnimationLocation.ANIMATED_STYLE, - animationType: AnimationType.SPRING, - }, - { - startWidth: 55.5, - finalWidth: 155.5, - animate: AnimationLocation.USE_EFFECT, - animationType: AnimationType.SPRING, - }, - { - startWidth: 300, - finalWidth: 33, - animate: AnimationLocation.NONE, - animationType: AnimationType.NONE, - }, - ])( + test.each( + [ + { + startWidth: 0, + finalWidth: 100, + animate: AnimationLocation.USE_EFFECT, + animationType: AnimationType.TIMING, + }, + { + startWidth: 0, + finalWidth: 100, + animate: AnimationLocation.ANIMATED_STYLE, + animationType: AnimationType.TIMING, + }, + { + startWidth: 0, + finalWidth: 100, + animate: AnimationLocation.ANIMATED_STYLE, + animationType: AnimationType.SPRING, + }, + { + startWidth: 0, + finalWidth: 100, + animate: AnimationLocation.USE_EFFECT, + animationType: AnimationType.SPRING, + }, + { + startWidth: 0, + finalWidth: 100, + animate: AnimationLocation.NONE, + animationType: AnimationType.NONE, + }, + { + startWidth: 100, + finalWidth: 20, + animate: AnimationLocation.USE_EFFECT, + animationType: AnimationType.TIMING, + }, + { + startWidth: 400, + finalWidth: 300, + animate: AnimationLocation.ANIMATED_STYLE, + animationType: AnimationType.TIMING, + }, + { + startWidth: 20, + finalWidth: 100, + animate: AnimationLocation.ANIMATED_STYLE, + animationType: AnimationType.SPRING, + }, + { + startWidth: 55.5, + finalWidth: 155.5, + animate: AnimationLocation.USE_EFFECT, + animationType: AnimationType.SPRING, + }, + { + startWidth: 300, + finalWidth: 33, + animate: AnimationLocation.NONE, + animationType: AnimationType.NONE, + }, + ].reduce( + (acc, element) => { + return [...acc, { ...element, compilerApi: false }, { ...element, compilerApi: true }]; + }, + [] as { + startWidth: number; + finalWidth: number; + animate: AnimationLocation; + animationType: AnimationType; + compilerApi: boolean; + }[], + ), + )( 'Animate from ${startWidth} to ${finalWidth}, ${animationType} ${animate}', async ({ startWidth, finalWidth, animate, animationType }) => { const snapshotIdPerType = { @@ -212,6 +239,7 @@ describe('Test useDerivedValue changing width', () => { finalWidth, animate, animationType, + false, ); expect(updates).toMatchSnapshots(snapshot[snapshotName]); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/animationsCompilerApi.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/animationsCompilerApi.test.tsx new file mode 100644 index 00000000000..59ed30b4673 --- /dev/null +++ b/apps/common-app/src/examples/RuntimeTests/tests/core/useSharedValue/animationsCompilerApi.test.tsx @@ -0,0 +1,153 @@ +import React, { useEffect } from 'react'; +import type { SharedValue } from 'react-native-reanimated'; +import { + useSharedValue, + withClamp, + withDecay, + withDelay, + withRepeat, + withSequence, + withSpring, + withTiming, +} from 'react-native-reanimated'; +import { + describe, + test, + expect, + render, + registerValue, + getRegisteredValue, + wait, +} from '../../../ReJest/RuntimeTestsApi'; +import { ComparisonMode } from '../../../ReJest/types'; +import { ProgressBar } from './components'; + +const SHARED_VALUE_REF = 'SHARED_VALUE_REF'; + +describe(`Test animation assignments on Shared Value using compiler API`, () => { + const WithTiming = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withTiming(100)); + }); + return ; + }; + + const WithClamp = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withClamp({ min: 0, max: 100 }, withTiming(200))); + }); + return ; + }; + + const WithDecay = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withDecay({})); + }); + return ; + }; + + const WithDelay = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withDelay(100, withTiming(100))); + }); + return ; + }; + + const WithSpring = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withSpring(100, { duration: 250 })); + }); + return ; + }; + + const WithRepeat = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withRepeat(withTiming(100), 2, true)); + }); + return ; + }; + + const WithSequence = ({ progress }: { progress: number }) => { + const sharedValue = useSharedValue(0); + registerValue(SHARED_VALUE_REF, sharedValue as SharedValue); + + useEffect(() => { + sharedValue.set(withSequence(withTiming(100), withTiming(200))); + }); + return ; + }; + + test('WithTiming', async () => { + await render(); + await wait(300); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(100, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(100, ComparisonMode.NUMBER); + }); + + test('WithClamp', async () => { + await render(); + await wait(300); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(100, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(100, ComparisonMode.NUMBER); + }); + + test('WithDecay', async () => { + await render(); + await wait(300); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(0, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(0, ComparisonMode.NUMBER); + }); + + test('WithDelay', async () => { + await render(); + await wait(400); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(100, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(100, ComparisonMode.NUMBER); + }); + + test('WithSpring', async () => { + await render(); + await wait(300); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(100, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(100, ComparisonMode.NUMBER); + }); + + test('WithRepeat', async () => { + await render(); + await wait(600); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(0, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(0, ComparisonMode.NUMBER); + }); + + test('WithSequence', async () => { + await render(); + await wait(600); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onJS).toBe(200, ComparisonMode.NUMBER); + expect(sharedValue.onUI).toBe(200, ComparisonMode.NUMBER); + }); +}); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts b/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts index a65545a8f98..03c3f00ce0a 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts +++ b/apps/common-app/src/examples/RuntimeTests/tests/plugin/fileWorkletization.ts @@ -23,12 +23,17 @@ export const implicitContextObject = { }, }; -export class ImplicitWorkletClass { - getSix() { +interface IWorkletClass { + getSix(): number; + getSeven(): number; +} + +export class ImplicitWorkletClass implements IWorkletClass { + getSix(): number { return 6; } - getSeven() { + getSeven(): number { return this.getSix() + 1; } } diff --git a/apps/common-app/src/examples/RuntimeTests/tests/plugin/recursion.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/plugin/recursion.test.tsx index d9ec95bbc8f..9ab0a39408d 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/plugin/recursion.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/plugin/recursion.test.tsx @@ -1,6 +1,6 @@ import React, { useEffect } from 'react'; import { View } from 'react-native'; -import { useSharedValue, runOnUI, runOnJS } from 'react-native-reanimated'; +import { useSharedValue, runOnUI } from 'react-native-reanimated'; import { render, wait, describe, getRegisteredValue, registerValue, test, expect } from '../../ReJest/RuntimeTestsApi'; const SHARED_VALUE_REF = 'SHARED_VALUE_REF'; @@ -85,15 +85,13 @@ describe('Test recursion in worklets', () => { const output = useSharedValue(null); registerValue(SHARED_VALUE_REF, output); function recursiveWorklet(a: number) { - if (a === 2) { + if (a === 1) { output.value = a; - } else if (a === 1) { - try { - // TODO: Such case isn't supported at the moment - - // a function can't be a Worklet and a Remote function at the same time. - // Consider supporting it in the future. - runOnJS(recursiveWorklet)(a + 1); - } catch {} + } else if (a === 2) { + // TODO: Such case isn't supported at the moment - + // a function can't be a Worklet and a Remote function at the same time. + // Consider supporting it in the future. + // runOnJS(recursiveWorklet)(a + 1); } else { recursiveWorklet(a + 1); } @@ -108,6 +106,6 @@ describe('Test recursion in worklets', () => { await render(); await wait(100); const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); - expect(sharedValue.onJS).toBe(null); + expect(sharedValue.onJS).toBe(1); }); }); diff --git a/apps/common-app/src/examples/RuntimeTests/tests/plugin/workletClasses.test.tsx b/apps/common-app/src/examples/RuntimeTests/tests/plugin/workletClasses.test.tsx index bd4d0244ecb..838e8e1f9db 100644 --- a/apps/common-app/src/examples/RuntimeTests/tests/plugin/workletClasses.test.tsx +++ b/apps/common-app/src/examples/RuntimeTests/tests/plugin/workletClasses.test.tsx @@ -21,6 +21,28 @@ class WorkletClass { } } +interface ITypeScriptClass { + getOne(): number; + getTwo(): number; + getIncremented(): number; +} + +class TypeScriptClass implements ITypeScriptClass { + __workletClass: boolean = true; + value: number = 0; + getOne(): number { + return 1; + } + + getTwo(): number { + return this.getOne() + 1; + } + + getIncremented(): number { + return ++this.value; + } +} + describe('Test worklet classes', () => { test('class works on React runtime', async () => { const ExampleComponent = () => { @@ -134,5 +156,26 @@ describe('Test worklet classes', () => { expect(sharedValue.onUI).toBe(true); }); + test('TypeScript classes work on Worklet runtime', async () => { + const ExampleComponent = () => { + const output = useSharedValue(null); + registerValue(SHARED_VALUE_REF, output); + + useEffect(() => { + runOnUI(() => { + const clazz = new TypeScriptClass(); + output.value = clazz.getOne(); + })(); + }); + + return ; + }; + await render(); + await wait(100); + const sharedValue = await getRegisteredValue(SHARED_VALUE_REF); + expect(sharedValue.onUI).toBe(1); + }); + // TODO: Add a test that throws when class is sent from React to Worklet runtime. + // TODO: Add a test that throws when trying to use Worklet Class with inheritance. }); diff --git a/apps/common-app/src/examples/ScreenStackExample.tsx b/apps/common-app/src/examples/ScreenStackExample.tsx index f2910b59b32..7ae31d41c96 100644 --- a/apps/common-app/src/examples/ScreenStackExample.tsx +++ b/apps/common-app/src/examples/ScreenStackExample.tsx @@ -1,6 +1,10 @@ import * as React from 'react'; import { Button, StyleSheet, View } from 'react-native'; -import { NavigationContainer, useNavigation } from '@react-navigation/native'; +import { + NavigationContainer, + NavigationIndependentTree, + useNavigation, +} from '@react-navigation/native'; import type { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import Animated, { @@ -60,12 +64,14 @@ function SecondScreen() { export default function ScreenStackExample() { return ( - - - - - - + + + + + + + + ); } diff --git a/apps/common-app/src/examples/SharedElementTransitions/BorderRadii.tsx b/apps/common-app/src/examples/SharedElementTransitions/BorderRadii.tsx index b190bc53646..1f7a36aa7cb 100644 --- a/apps/common-app/src/examples/SharedElementTransitions/BorderRadii.tsx +++ b/apps/common-app/src/examples/SharedElementTransitions/BorderRadii.tsx @@ -42,7 +42,7 @@ function Screen1({ navigation }: NativeStackScreenProps) { function Screen2({ navigation }: NativeStackScreenProps) { return ( -