From 0bed7c8bdd557657247da419bbd58c15aafc1b50 Mon Sep 17 00:00:00 2001 From: Tatiana Kapos Date: Thu, 26 Dec 2024 11:21:31 -0800 Subject: [PATCH 1/3] integrate rn 0.77.0-rc.4 --- .../react-native-win32-tester/overrides.json | 2 +- .../react-native-win32-tester/package.json | 4 +- .../react-native-win32/overrides.json | 2 +- .../react-native-win32/package.json | 18 +-- .../automation-channel/package.json | 2 +- .../tester/overrides.json | 2 +- .../@react-native-windows/tester/package.json | 4 +- .../@react-native/monorepo/overrides.json | 4 +- packages/@react-native/monorepo/package.json | 4 +- packages/@react-native/tester/overrides.json | 4 +- packages/@react-native/tester/package.json | 2 +- packages/e2e-test-app-fabric/package.json | 2 +- packages/e2e-test-app/package.json | 2 +- packages/integration-test-app/package.json | 2 +- packages/playground/package.json | 2 +- packages/sample-app-fabric/package.json | 2 +- packages/sample-apps/package.json | 2 +- packages/sample-custom-component/package.json | 2 +- .../react/runtime/ReactInstance.cpp | 74 +++++---- vnext/overrides.json | 12 +- vnext/package.json | 18 +-- yarn.lock | 151 +++++++++--------- 22 files changed, 160 insertions(+), 157 deletions(-) diff --git a/packages/@office-iss/react-native-win32-tester/overrides.json b/packages/@office-iss/react-native-win32-tester/overrides.json index 523ed037a1b..93f2e305fa4 100644 --- a/packages/@office-iss/react-native-win32-tester/overrides.json +++ b/packages/@office-iss/react-native-win32-tester/overrides.json @@ -5,7 +5,7 @@ "excludePatterns": [ "src/js/examples-win32/**" ], - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "patch", diff --git a/packages/@office-iss/react-native-win32-tester/package.json b/packages/@office-iss/react-native-win32-tester/package.json index 92e34c276b4..fbae0baa3a4 100644 --- a/packages/@office-iss/react-native-win32-tester/package.json +++ b/packages/@office-iss/react-native-win32-tester/package.json @@ -19,7 +19,7 @@ "peerDependencies": { "@office-iss/react-native-win32": "0.77.0-preview.1", "react": "18.0.0", - "react-native": "0.77.0-rc.0" + "react-native": "0.77.0-rc.4" }, "devDependencies": { "@office-iss/react-native-win32": "0.77.0-preview.1", @@ -30,7 +30,7 @@ "@types/node": "^18.0.0", "eslint": "^8.19.0", "just-scripts": "^1.3.3", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-platform-override": "^1.9.49", "typescript": "5.0.4" }, diff --git a/packages/@office-iss/react-native-win32/overrides.json b/packages/@office-iss/react-native-win32/overrides.json index 56e2db31873..64838894adb 100644 --- a/packages/@office-iss/react-native-win32/overrides.json +++ b/packages/@office-iss/react-native-win32/overrides.json @@ -7,7 +7,7 @@ "**/__snapshots__/**", "src-win/rntypes/**" ], - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "derived", diff --git a/packages/@office-iss/react-native-win32/package.json b/packages/@office-iss/react-native-win32/package.json index 629193632f7..92c7decf42f 100644 --- a/packages/@office-iss/react-native-win32/package.json +++ b/packages/@office-iss/react-native-win32/package.json @@ -30,13 +30,13 @@ "@react-native-community/cli-platform-android": "15.0.0-alpha.2", "@react-native-community/cli-platform-ios": "15.0.0-alpha.2", "@react-native/assets": "1.0.0", - "@react-native/assets-registry": "0.77.0-rc.0", - "@react-native/codegen": "0.77.0-rc.0", - "@react-native/community-cli-plugin": "0.77.0-rc.0", - "@react-native/gradle-plugin": "0.77.0-rc.0", - "@react-native/js-polyfills": "0.77.0-rc.0", - "@react-native/normalize-colors": "0.77.0-rc.0", - "@react-native/virtualized-lists": "0.77.0-rc.0", + "@react-native/assets-registry": "0.77.0-rc.4", + "@react-native/codegen": "0.77.0-rc.4", + "@react-native/community-cli-plugin": "0.77.0-rc.4", + "@react-native/gradle-plugin": "0.77.0-rc.4", + "@react-native/js-polyfills": "0.77.0-rc.4", + "@react-native/normalize-colors": "0.77.0-rc.4", + "@react-native/virtualized-lists": "0.77.0-rc.4", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", @@ -90,14 +90,14 @@ "just-scripts": "^1.3.3", "prettier": "2.8.8", "react": "18.3.1", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-platform-override": "^1.9.49", "typescript": "5.0.4" }, "peerDependencies": { "@types/react": "^18.2.6", "react": "^18.2.0", - "react-native": "0.77.0-rc.0" + "react-native": "0.77.0-rc.4" }, "beachball": { "defaultNpmTag": "preview", diff --git a/packages/@react-native-windows/automation-channel/package.json b/packages/@react-native-windows/automation-channel/package.json index 6b93de2f7ba..2cf4b38a6eb 100644 --- a/packages/@react-native-windows/automation-channel/package.json +++ b/packages/@react-native-windows/automation-channel/package.json @@ -32,7 +32,7 @@ "just-scripts": "^1.3.2", "prettier": "2.8.8", "react": "18.3.1", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1", "typescript": "5.0.4" }, diff --git a/packages/@react-native-windows/tester/overrides.json b/packages/@react-native-windows/tester/overrides.json index 14b82770e2a..73badeede10 100644 --- a/packages/@react-native-windows/tester/overrides.json +++ b/packages/@react-native-windows/tester/overrides.json @@ -5,7 +5,7 @@ "excludePatterns": [ "src/js/examples-win/**" ], - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "derived", diff --git a/packages/@react-native-windows/tester/package.json b/packages/@react-native-windows/tester/package.json index 7b78e57379b..0d3dd51de47 100644 --- a/packages/@react-native-windows/tester/package.json +++ b/packages/@react-native-windows/tester/package.json @@ -19,7 +19,7 @@ "peerDependencies": { "@react-native-picker/picker": "2.4.10", "react": "18.0.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1", "react-native-xaml": "^0.0.78" }, @@ -32,7 +32,7 @@ "@types/node": "^18.0.0", "eslint": "^8.19.0", "just-scripts": "^1.3.3", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-platform-override": "^1.9.49", "react-native-windows": "0.77.0-preview.1", "typescript": "5.0.4" diff --git a/packages/@react-native/monorepo/overrides.json b/packages/@react-native/monorepo/overrides.json index e21b22f34a5..3ef5948ec20 100644 --- a/packages/@react-native/monorepo/overrides.json +++ b/packages/@react-native/monorepo/overrides.json @@ -1,11 +1,11 @@ { - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "patch", "file": "package.json", "baseFile": "package.json", - "baseHash": "a2df0199b474665c8ff426fc712615c798c67a62" + "baseHash": "68d841d7be590262b6a02c7bd15ce57eb3a7be21" } ] } \ No newline at end of file diff --git a/packages/@react-native/monorepo/package.json b/packages/@react-native/monorepo/package.json index ba642495811..1a787a94c6c 100644 --- a/packages/@react-native/monorepo/package.json +++ b/packages/@react-native/monorepo/package.json @@ -47,8 +47,8 @@ "@definitelytyped/dtslint": "^0.0.127", "@jest/create-cache-key-function": "^29.6.3", "@pkgjs/parseargs": "^0.11.0", - "@react-native/metro-babel-transformer": "0.77.0-rc.0", - "@react-native/metro-config": "0.77.0-rc.0", + "@react-native/metro-babel-transformer": "0.77.0-rc.4", + "@react-native/metro-config": "0.77.0-rc.4", "@tsconfig/node18": "1.0.1", "@types/react": "^18.2.6", "@typescript-eslint/parser": "^7.1.1", diff --git a/packages/@react-native/tester/overrides.json b/packages/@react-native/tester/overrides.json index 5632d4b3485..36555936742 100644 --- a/packages/@react-native/tester/overrides.json +++ b/packages/@react-native/tester/overrides.json @@ -1,5 +1,5 @@ { - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "copy", @@ -621,7 +621,7 @@ "type": "patch", "file": "package.json", "baseFile": "packages/rn-tester/package.json", - "baseHash": "428a339cc04f619ec6c00f2037332440d6d97326", + "baseHash": "468a273cb010ad1ab893a95fe4fb33cd1dc5affc", "issue": 13228 } ] diff --git a/packages/@react-native/tester/package.json b/packages/@react-native/tester/package.json index ca0911f2be4..2f8cfb2bcde 100644 --- a/packages/@react-native/tester/package.json +++ b/packages/@react-native/tester/package.json @@ -27,7 +27,7 @@ "e2e-test-ios": "./scripts/maestro-test-ios.sh" }, "dependencies": { - "@react-native/popup-menu-android": "0.77.0-rc.0", + "@react-native/popup-menu-android": "0.77.0-rc.4", "flow-enums-runtime": "^0.0.6", "invariant": "^2.2.4", "nullthrows": "^1.1.1" diff --git a/packages/e2e-test-app-fabric/package.json b/packages/e2e-test-app-fabric/package.json index ea7c0897668..62aa92d8951 100644 --- a/packages/e2e-test-app-fabric/package.json +++ b/packages/e2e-test-app-fabric/package.json @@ -20,7 +20,7 @@ "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/packages/e2e-test-app/package.json b/packages/e2e-test-app/package.json index 4b377750224..82c65924670 100644 --- a/packages/e2e-test-app/package.json +++ b/packages/e2e-test-app/package.json @@ -20,7 +20,7 @@ "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1", "react-native-xaml": "^0.0.78" }, diff --git a/packages/integration-test-app/package.json b/packages/integration-test-app/package.json index 3f794a2055f..e2ae421b3e8 100644 --- a/packages/integration-test-app/package.json +++ b/packages/integration-test-app/package.json @@ -17,7 +17,7 @@ "@typescript-eslint/parser": "^7.1.1", "chai": "^4.2.0", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/packages/playground/package.json b/packages/playground/package.json index 7ad8c133ba4..635094a3166 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/packages/sample-app-fabric/package.json b/packages/sample-app-fabric/package.json index d17e0d92691..ed7b52167c6 100644 --- a/packages/sample-app-fabric/package.json +++ b/packages/sample-app-fabric/package.json @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/packages/sample-apps/package.json b/packages/sample-apps/package.json index 324ff246ff6..f46c22d1f1e 100644 --- a/packages/sample-apps/package.json +++ b/packages/sample-apps/package.json @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/packages/sample-custom-component/package.json b/packages/sample-custom-component/package.json index c17b946a347..ac6d3a7d10c 100644 --- a/packages/sample-custom-component/package.json +++ b/packages/sample-custom-component/package.json @@ -22,7 +22,7 @@ "dependencies": { "@types/react": "^18.2.6", "react": "^18.2.0", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-windows": "0.77.0-preview.1" }, "devDependencies": { diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp index cab2a5e1dbf..f142ecc0360 100644 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +++ b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp @@ -235,47 +235,51 @@ std::string simpleBasename(const std::string& path) { */ void ReactInstance::loadScript( std::unique_ptr script, - const std::string& sourceURL) { + const std::string& sourceURL, + std::function&& completion) { auto buffer = std::make_shared(std::move(script)); std::string scriptName = simpleBasename(sourceURL); - runtimeScheduler_->scheduleWork( - [this, - scriptName, - sourceURL, - buffer = std::move(buffer), - weakBufferedRuntimeExecuter = std::weak_ptr( - bufferedRuntimeExecutor_)](jsi::Runtime& runtime) { - SystraceSection s("ReactInstance::loadScript"); - bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl); - if (hasLogger) { - ReactMarker::logTaggedMarkerBridgeless( - ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); - } + runtimeScheduler_->scheduleWork([this, + scriptName, + sourceURL, + buffer = std::move(buffer), + weakBufferedRuntimeExecuter = + std::weak_ptr( + bufferedRuntimeExecutor_), + completion](jsi::Runtime& runtime) { + SystraceSection s("ReactInstance::loadScript"); + bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl); + if (hasLogger) { + ReactMarker::logTaggedMarkerBridgeless( + ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); + } - runtime.evaluateJavaScript(buffer, sourceURL); + runtime.evaluateJavaScript(buffer, sourceURL); - /** - * TODO(T183610671): We need a safe/reliable way to enable the js - * pipeline from javascript. Remove this after we figure that out, or - * after we just remove the js pipeline. - */ - if (!jsErrorHandler_->hasHandledFatalError()) { - jsErrorHandler_->setRuntimeReady(); - } + /** + * TODO(T183610671): We need a safe/reliable way to enable the js + * pipeline from javascript. Remove this after we figure that out, or + * after we just remove the js pipeline. + */ + if (!jsErrorHandler_->hasHandledFatalError()) { + jsErrorHandler_->setRuntimeReady(); + } - if (hasLogger) { - ReactMarker::logTaggedMarkerBridgeless( - ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); - ReactMarker::logMarkerBridgeless( - ReactMarker::INIT_REACT_RUNTIME_STOP); - ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP); - } - if (auto strongBufferedRuntimeExecuter = - weakBufferedRuntimeExecuter.lock()) { - strongBufferedRuntimeExecuter->flush(); - } - }); + if (hasLogger) { + ReactMarker::logTaggedMarkerBridgeless( + ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); + ReactMarker::logMarkerBridgeless(ReactMarker::INIT_REACT_RUNTIME_STOP); + ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP); + } + if (auto strongBufferedRuntimeExecuter = + weakBufferedRuntimeExecuter.lock()) { + strongBufferedRuntimeExecuter->flush(); + } + if (completion) { + completion(runtime); + } + }); } /* diff --git a/vnext/overrides.json b/vnext/overrides.json index a989b566fc6..c99758d5da4 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -8,7 +8,7 @@ "**/__snapshots__/**", "src-win/rntypes/**" ], - "baseVersion": "0.77.0-rc.0", + "baseVersion": "0.77.0-rc.4", "overrides": [ { "type": "derived", @@ -190,7 +190,7 @@ "type": "patch", "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp", "baseFile": "packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp", - "baseHash": "240a49c5f5bd67f35e79dcbe9a9c6e7f6e6e2a32", + "baseHash": "9bfade3d6a2e2df231bae88267cf1d9e59451533", "issue": 13172 }, { @@ -262,19 +262,19 @@ "type": "derived", "file": "src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js", "baseFile": "packages/react-native/Libraries/Animated/NativeAnimatedAllowlist.js", - "baseHash": "337dfc9001bc8967ca8c5da7f09ddde463d29b54" + "baseHash": "0d731685ff1ce7e4fc85000e341329387c603512" }, { "type": "derived", "file": "src-win/Libraries/Animated/nodes/AnimatedProps.windows.js", "baseFile": "packages/react-native/Libraries/Animated/nodes/AnimatedProps.js", - "baseHash": "9157901b6382c2a936010d0d34ec4f33a8baf70b" + "baseHash": "210b39d5e3ba0a0e338d6cdbffa9402b8ad52a6e" }, { "type": "derived", "file": "src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js", "baseFile": "packages/react-native/Libraries/Animated/nodes/AnimatedStyle.js", - "baseHash": "477711c8194a5ea843ec907c2d97fbed83b94028" + "baseHash": "8d506f2b8d8b2d9d0efdad1162314f884b9ab631" }, { "type": "platform", @@ -634,7 +634,7 @@ "type": "derived", "file": "src-win/src/private/animated/useAnimatedPropsMemo.windows.js", "baseFile": "packages/react-native/src/private/animated/useAnimatedPropsMemo.js", - "baseHash": "b1c052ae3653d5771b75aa96afc49cddd794f1bd" + "baseHash": "c983a4da2ddd6ffcb37d39241c77149a24b68dbb" }, { "type": "copy", diff --git a/vnext/package.json b/vnext/package.json index 66bee61b137..1e9b2ec775d 100644 --- a/vnext/package.json +++ b/vnext/package.json @@ -28,13 +28,13 @@ "@react-native-community/cli-platform-ios": "15.0.0-alpha.2", "@react-native-windows/cli": "0.77.0-preview.1", "@react-native/assets": "1.0.0", - "@react-native/assets-registry": "0.77.0-rc.0", - "@react-native/codegen": "0.77.0-rc.0", - "@react-native/community-cli-plugin": "0.77.0-rc.0", - "@react-native/gradle-plugin": "0.77.0-rc.0", - "@react-native/js-polyfills": "0.77.0-rc.0", - "@react-native/normalize-colors": "0.77.0-rc.0", - "@react-native/virtualized-lists": "0.77.0-rc.0", + "@react-native/assets-registry": "0.77.0-rc.4", + "@react-native/codegen": "0.77.0-rc.4", + "@react-native/community-cli-plugin": "0.77.0-rc.4", + "@react-native/gradle-plugin": "0.77.0-rc.4", + "@react-native/js-polyfills": "0.77.0-rc.4", + "@react-native/normalize-colors": "0.77.0-rc.4", + "@react-native/virtualized-lists": "0.77.0-rc.4", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", @@ -85,7 +85,7 @@ "just-scripts": "^1.3.3", "prettier": "2.8.8", "react": "18.3.1", - "react-native": "0.77.0-rc.0", + "react-native": "0.77.0-rc.4", "react-native-platform-override": "^1.9.49", "react-refresh": "^0.14.0", "typescript": "5.0.4" @@ -93,7 +93,7 @@ "peerDependencies": { "@types/react": "^18.2.6", "react": "^18.2.0", - "react-native": "0.77.0-rc.0" + "react-native": "0.77.0-rc.4" }, "beachball": { "defaultNpmTag": "preview", diff --git a/yarn.lock b/yarn.lock index 28a5f1052b3..b3a2d04a44b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2090,10 +2090,10 @@ resolved "https://registry.yarnpkg.com/@react-native-picker/picker/-/picker-2.10.2.tgz#92870eaefdde5cf06a0bb18dde593b9675c0bcab" integrity sha512-kr3OvCRwTYjR/OKlb52k4xmQVU7dPRIALqpyiihexdJxEgvc1smnepgqCeM9oXmNSG4YaV5/RSxFlLC5Z/T/Eg== -"@react-native/assets-registry@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.77.0-rc.0.tgz#0787bae0a50639025f192e1bd2b59d8bce6073f6" - integrity sha512-Q4d29wpFiDpoqSbL7XK0zCndPAkWPZ4W7Jy3fNSIHvLtBm1gSSjh9Vj8TTWdAvIXp7QHgG9CUX5NXmeGoRDS2w== +"@react-native/assets-registry@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.77.0-rc.4.tgz#35a942eab922c165a53243012eb530d76abeaa74" + integrity sha512-K8RLksThNphZS5UJinRoLOHH5zyREl6QudwChkUZfzIx50udc6baLO+ETDdFA1vJcAk25mfJUlpCebt7jastpw== "@react-native/assets@1.0.0": version "1.0.0" @@ -2116,13 +2116,13 @@ "@babel/traverse" "^7.25.3" "@react-native/codegen" "0.77.0-nightly-20241020-e7a3f479f" -"@react-native/babel-plugin-codegen@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.77.0-rc.0.tgz#c40ec76de603d517c8aaa3aebeb6b0aa00e2c58e" - integrity sha512-TsEE9oWf8fCcFh+R30AxLVGDN6UVb9uRBfo+G1CfH8BpC9zoieejVMClCLiKOzeJrBCnE/kX9TE0IQOjOThA6Q== +"@react-native/babel-plugin-codegen@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.77.0-rc.4.tgz#3ae49dff2afc18e12e0b1a8925bd7282d26ad0a0" + integrity sha512-dTcakFVGIyXdUgU8YXZ0eDcOZOle01Vzi1qwKGirT7kmgqcodXJzZaRAoF9dbuFQhD4Ge0su1Cp58hVM3DnXlA== dependencies: "@babel/traverse" "^7.25.3" - "@react-native/codegen" "0.77.0-rc.0" + "@react-native/codegen" "0.77.0-rc.4" "@react-native/babel-preset@0.77.0-nightly-20241001-223e98cc4": version "0.77.0-nightly-20241001-223e98cc4" @@ -2226,10 +2226,10 @@ babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" -"@react-native/babel-preset@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.77.0-rc.0.tgz#6b587de06dbddb25dc67d55c5b13e252797e4395" - integrity sha512-X4ayTy7rnJmliwN4I2XXHtp1QPl+gP9AJdF77MPfEQ1ZAmPD3JO3u8ZKCP90CGnu1WObAo1o7jNIVgQUa77U4Q== +"@react-native/babel-preset@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/babel-preset/-/babel-preset-0.77.0-rc.4.tgz#e8049c0638b0091324b2e23485453ebdf156af57" + integrity sha512-+coTDbuNgPfgin/SwMgORfpc65y4n3+AjgFq8P3Nzxb+4ZemoCvdm4tRJgDv3TGKMmUIY3M6f+hvm+7Fb3fKtQ== dependencies: "@babel/core" "^7.25.2" "@babel/plugin-proposal-export-default-from" "^7.24.7" @@ -2272,7 +2272,7 @@ "@babel/plugin-transform-typescript" "^7.25.2" "@babel/plugin-transform-unicode-regex" "^7.24.7" "@babel/template" "^7.25.0" - "@react-native/babel-plugin-codegen" "0.77.0-rc.0" + "@react-native/babel-plugin-codegen" "0.77.0-rc.4" babel-plugin-syntax-hermes-parser "0.25.1" babel-plugin-transform-flow-enums "^0.0.2" react-refresh "^0.14.0" @@ -2303,10 +2303,10 @@ nullthrows "^1.1.1" yargs "^17.6.2" -"@react-native/codegen@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.77.0-rc.0.tgz#806da528a50f9c56cef44e322df71592aa8fbba0" - integrity sha512-CdtW92gvTK/bx5ujEuw8FjF6GSQhlBbdodQBhPXqmRuI434GcrgNGcXyOLDK9rQ0gzKzv+QQEhir2P+hPBS2tA== +"@react-native/codegen@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.77.0-rc.4.tgz#5b6ea0d5163c3aca518cff3b98feb3645f6820b9" + integrity sha512-ssU66J5d2mpsuVq6T/TFS1NqrWw7CcSn0CS5CChoTwSkSH8uvy3Yg97KD9jgh1iLuvPMzYW9dcoAdlcGfV/8CQ== dependencies: "@babel/parser" "^7.25.3" glob "^7.1.1" @@ -2316,35 +2316,34 @@ nullthrows "^1.1.1" yargs "^17.6.2" -"@react-native/community-cli-plugin@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.77.0-rc.0.tgz#4e4adf96763a7dd2453f4826f638194eb7bc700b" - integrity sha512-Y0DcqQmkZCxLkS8e00L5l3as1y5upFWNz8LfbU3gmeCv+E4bi8W3Jx2HPA64SizF3ggTZiS8ZEohR5bKYEU77w== +"@react-native/community-cli-plugin@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/community-cli-plugin/-/community-cli-plugin-0.77.0-rc.4.tgz#54d78fae8092efd917f0d6ca101de3453279bdb4" + integrity sha512-/335i3IXNxEbWAKjym/DcR6FL0PqKMOLSeYOodCYyntnDOlOrR/+jleCIfAmfUt+DORAMb6z9tbJrk58ofo5IQ== dependencies: - "@react-native/dev-middleware" "0.77.0-rc.0" - "@react-native/metro-babel-transformer" "0.77.0-rc.0" + "@react-native/dev-middleware" "0.77.0-rc.4" + "@react-native/metro-babel-transformer" "0.77.0-rc.4" chalk "^4.0.0" debug "^2.2.0" invariant "^2.2.4" metro "^0.81.0" metro-config "^0.81.0" metro-core "^0.81.0" - node-fetch "^2.2.0" readline "^1.3.0" semver "^7.1.3" -"@react-native/debugger-frontend@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.77.0-rc.0.tgz#c3f3c01d128c94a6959705a805a50ce439c651f9" - integrity sha512-5mj5ArHc/5c8u6BkO0m7ZsxmNW49xgJR6fofWdsGNvkMa7gjc38qTZEKgGBYbch5i1BO5zzQKprANIOWfyt3SA== +"@react-native/debugger-frontend@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/debugger-frontend/-/debugger-frontend-0.77.0-rc.4.tgz#7542c7671c42e1942367b1fd07dea4236a1160ed" + integrity sha512-5yH0ox4wnWlp8yGu5w5EzO6yx0HFGM4mMTG9H8M75PnaK+koxLkYaLBIHXACFl6COWXN23ML1jtBjSVG7Zclfw== -"@react-native/dev-middleware@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.77.0-rc.0.tgz#98ed79b639924b8ae3d60b2b995eb075be278857" - integrity sha512-9c1j4M05qC8t9UGt9QBwBp+cVCTIn28G+N1M/Ovgz1ouUrOvfrcuQ+3ai9TVYksWkuAi1SXXZgAqIv6U7rrugQ== +"@react-native/dev-middleware@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/dev-middleware/-/dev-middleware-0.77.0-rc.4.tgz#bbad395b80f822e1c18e7523d06537c3a41a5584" + integrity sha512-XH50tty11OdMi9itHcSiWgJ7KAcWjt8oCTmTub/4BpVa9OIFEzlhrrKGVfJD53gTv7sjeWeu1SVVHa4BM8HgRA== dependencies: "@isaacs/ttlcache" "^1.4.1" - "@react-native/debugger-frontend" "0.77.0-rc.0" + "@react-native/debugger-frontend" "0.77.0-rc.4" chrome-launcher "^0.15.2" chromium-edge-launcher "^0.2.0" connect "^3.6.5" @@ -2378,10 +2377,10 @@ resolved "https://registry.yarnpkg.com/@react-native/eslint-plugin/-/eslint-plugin-0.77.0-nightly-20241001-223e98cc4.tgz#33aa61842c0933b4276ae340911484f2ad7900ed" integrity sha512-IMv29Jyh4z2sh6n2QB2XjgxHAJuGFfKVqvrxLSwzuOgJIbN7xCVIClIHVe2nX+6LxW5Wl4Zu+lgJpOjTN/vu+g== -"@react-native/gradle-plugin@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.77.0-rc.0.tgz#ec2f1d569d9e1666f54b72ddd6d72f385606d4b8" - integrity sha512-d/gMWb1dX/2XqkPNeAPPR/YqhQxjuUfc7ES5Iuuwd8R8XE0mgeESFu+7GLDLLmzSF3d2zWIclRBBmYF1iHlg9w== +"@react-native/gradle-plugin@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/gradle-plugin/-/gradle-plugin-0.77.0-rc.4.tgz#d2a19ece2e43c49eb7deeee4285ed60248e5c88e" + integrity sha512-fOMidVArXsvJClOyFNA8m5I8ZbEMw1kThbxIoB2SsOoOkVw+BDvfmZm7Cz40+Er7VCCnrrcFqQNiISQggzIZhw== "@react-native/js-polyfills@0.77.0-nightly-20241001-223e98cc4": version "0.77.0-nightly-20241001-223e98cc4" @@ -2393,10 +2392,10 @@ resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.77.0-nightly-20241020-e7a3f479f.tgz#ebebed85d3791041699f10d40c00beb676b960ce" integrity sha512-Zj3LOOrrrfzZW8OnAcHGtEBGLkKc1gvhlMz/zSzDzhWlHH+EDCfTP6QcA/z8roTIKq1QkubDLEAiMOLe+koGsg== -"@react-native/js-polyfills@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.77.0-rc.0.tgz#5ab570a1c1efe9698d151840df2c6481d9e4c939" - integrity sha512-+H3o2X8z8tJRvekmjFbdRuNUcln6SprGI8TdmBP9rEsNFDgiZzo81IbHBXL0umvYCvzLkshoJaraloE3ilDW4Q== +"@react-native/js-polyfills@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/js-polyfills/-/js-polyfills-0.77.0-rc.4.tgz#a8526afe1775515e6b0a6ab41901b2b03a587f11" + integrity sha512-A+QYU7MSQF8I8x0CHHJiZDC7cMBCn3tEVlRR5WXBLpXDlgnOTLeOv5NYLBFznfDeTyTUqjsvV/SU2MDgjkyFCA== "@react-native/metro-babel-transformer@0.77.0-nightly-20241001-223e98cc4": version "0.77.0-nightly-20241001-223e98cc4" @@ -2418,13 +2417,13 @@ hermes-parser "0.24.0" nullthrows "^1.1.1" -"@react-native/metro-babel-transformer@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.77.0-rc.0.tgz#b51692aa6a02e745f51acbee11a8bffd67b29e60" - integrity sha512-mmdDc95asbru7dBl1KQRDkiLh6WWju3cZbCaLpAOvsGfltiX4ECqwDUTy4oUg3U92yHiWttjDkNNSXHIIqySQw== +"@react-native/metro-babel-transformer@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/metro-babel-transformer/-/metro-babel-transformer-0.77.0-rc.4.tgz#8a353f9ec02bf5092cdcce6146d206fc80ebbe25" + integrity sha512-O8VCiWfnqdUrGUKx80NQdpQgVD2ee79TLPG7xAG9Sqs7+xO/WPmoqQvCoNlgPI4vILc0/KO+AqRFzPuHonUUnA== dependencies: "@babel/core" "^7.25.2" - "@react-native/babel-preset" "0.77.0-rc.0" + "@react-native/babel-preset" "0.77.0-rc.4" hermes-parser "0.25.1" nullthrows "^1.1.1" @@ -2448,32 +2447,32 @@ metro-config "^0.81.0" metro-runtime "^0.81.0" -"@react-native/metro-config@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/metro-config/-/metro-config-0.77.0-rc.0.tgz#1007503b334476ddb8dcad71c1a1945e8c67f6b2" - integrity sha512-91RtIH03zcyrw7xgf2lsVtUdyI9yvQwwoj51Z1TS/obLUa2be8ovCQFO7jnhqoshNQcOzY7VDQvXjFtuSaGWTw== +"@react-native/metro-config@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/metro-config/-/metro-config-0.77.0-rc.4.tgz#24f8bb47aa2788636dec27896fd869793ee1a72f" + integrity sha512-uRjk4nXJEU0WtKn31S1I+1sBi8nuGbx/+w03qnwHWOn2rnYqab+ChTaeNC5DfkVCdFZyxYEWOwOAjYcwI/+45w== dependencies: - "@react-native/js-polyfills" "0.77.0-rc.0" - "@react-native/metro-babel-transformer" "0.77.0-rc.0" + "@react-native/js-polyfills" "0.77.0-rc.4" + "@react-native/metro-babel-transformer" "0.77.0-rc.4" metro-config "^0.81.0" metro-runtime "^0.81.0" -"@react-native/normalize-colors@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.77.0-rc.0.tgz#0281e7d51b36a5c2ba718b8edac033683baf1a1e" - integrity sha512-XGdqKpHn6xvNXpL2x6415lY722LF9NvAUiWK7mdy9vzhLfckcG9Oc8YbY6yWBmulRg41eTFvWFzbD8UO5DgvCw== +"@react-native/normalize-colors@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/normalize-colors/-/normalize-colors-0.77.0-rc.4.tgz#7e6cbf0d18f31c970786d80b124a0f8be81f3cc4" + integrity sha512-HgczU7D8TW+WeOj/wUBCybqItMI5mF7HGUuGZVM6f7DzRLP5UO9MLgbtMZXUILFYO+ViOAZt6Wb/bmGGPHS7ag== -"@react-native/popup-menu-android@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/popup-menu-android/-/popup-menu-android-0.77.0-rc.0.tgz#164b33f3738a5dc2d2adb7dc9c8d98761a5bf3c1" - integrity sha512-W1vwV+4qVFROMQmbvUUkKDOxGaoT4XV/HfXmeGS28L8NmdiF16/e4Gx69wI2uQh9+yLvTB5ww11EtlVJGhiPog== +"@react-native/popup-menu-android@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/popup-menu-android/-/popup-menu-android-0.77.0-rc.4.tgz#357290356154dab83b18af4cf61b7a6c4a4413bd" + integrity sha512-GcXQRIFZQpibyTADH3xe32zSheyJTk+BzD+6IWmPO1fhPNKcxZEgda4L4fT424sfm001zMdNVoOUDR1VkTWfDg== dependencies: nullthrows "^1.1.1" -"@react-native/virtualized-lists@0.77.0-rc.0": - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.77.0-rc.0.tgz#58dd6590c0d88e1039a7537e2a4799f520ebb883" - integrity sha512-36A+HW6qsN+WZlf2WAhjvrXF9wtxN7k/FbIgIARm9fsRkYr1ofU8eFX3CK3LA1NOkYXBDgjMBQhGngY1jvE6Pg== +"@react-native/virtualized-lists@0.77.0-rc.4": + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/@react-native/virtualized-lists/-/virtualized-lists-0.77.0-rc.4.tgz#b70fa07d59a177fb6a10ab7b57d0b085acc02ac6" + integrity sha512-Pi+L5QjMnnVWQi2oOThVQ/azgaRGu/69aZa8+kbJoo1eNzBOSnPEjLx3h92Lq5RMvbFKwBBpBACW2aO/qOMJWQ== dependencies: invariant "^2.2.4" nullthrows "^1.1.1" @@ -10089,19 +10088,19 @@ react-native-xaml@^0.0.78: dependencies: "@types/react" "*" -react-native@0.77.0-rc.0: - version "0.77.0-rc.0" - resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.77.0-rc.0.tgz#5b8d02c189287957e5477c5510715446bdaaf8b1" - integrity sha512-zEW2/uWad2GGVo1GR9r8x8wHWAheXkd6fgnmUowgNMsvdU2IA26Z7apa2E+SZFZVjGYn8cyduxvXbaOVkJ28Pg== +react-native@0.77.0-rc.4: + version "0.77.0-rc.4" + resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.77.0-rc.4.tgz#7c7e6517e3ebada67553bd0a49e2da74f0a3ddea" + integrity sha512-Gf+SSiCJowglV1QBrWLT9Q2nEW0tNPabREA3JGeqZnFPKmrIHYh6kpnIC8pMspNQ5s4JsrqF1T0vGYNVZmk5mQ== dependencies: "@jest/create-cache-key-function" "^29.6.3" - "@react-native/assets-registry" "0.77.0-rc.0" - "@react-native/codegen" "0.77.0-rc.0" - "@react-native/community-cli-plugin" "0.77.0-rc.0" - "@react-native/gradle-plugin" "0.77.0-rc.0" - "@react-native/js-polyfills" "0.77.0-rc.0" - "@react-native/normalize-colors" "0.77.0-rc.0" - "@react-native/virtualized-lists" "0.77.0-rc.0" + "@react-native/assets-registry" "0.77.0-rc.4" + "@react-native/codegen" "0.77.0-rc.4" + "@react-native/community-cli-plugin" "0.77.0-rc.4" + "@react-native/gradle-plugin" "0.77.0-rc.4" + "@react-native/js-polyfills" "0.77.0-rc.4" + "@react-native/normalize-colors" "0.77.0-rc.4" + "@react-native/virtualized-lists" "0.77.0-rc.4" abort-controller "^3.0.0" anser "^1.4.9" ansi-regex "^5.0.0" From a7663fd30e5e23945ea8192cdb3d33d3abe6249f Mon Sep 17 00:00:00 2001 From: Tatiana Kapos Date: Thu, 26 Dec 2024 11:21:47 -0800 Subject: [PATCH 2/3] Change files --- ...-native-win32-54518aeb-1856-43ab-8f0a-27ebc3785768.json | 7 +++++++ ...ative-windows-03c284bd-e659-4d5e-b32b-9759cb464330.json | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 change/@office-iss-react-native-win32-54518aeb-1856-43ab-8f0a-27ebc3785768.json create mode 100644 change/react-native-windows-03c284bd-e659-4d5e-b32b-9759cb464330.json diff --git a/change/@office-iss-react-native-win32-54518aeb-1856-43ab-8f0a-27ebc3785768.json b/change/@office-iss-react-native-win32-54518aeb-1856-43ab-8f0a-27ebc3785768.json new file mode 100644 index 00000000000..9f0eaed37e2 --- /dev/null +++ b/change/@office-iss-react-native-win32-54518aeb-1856-43ab-8f0a-27ebc3785768.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "integrate rn 0.77.0-rc.4", + "packageName": "@office-iss/react-native-win32", + "email": "email not defined", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-03c284bd-e659-4d5e-b32b-9759cb464330.json b/change/react-native-windows-03c284bd-e659-4d5e-b32b-9759cb464330.json new file mode 100644 index 00000000000..a72c491375b --- /dev/null +++ b/change/react-native-windows-03c284bd-e659-4d5e-b32b-9759cb464330.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "integrate rn 0.77.0-rc.4", + "packageName": "react-native-windows", + "email": "email not defined", + "dependentChangeType": "patch" +} From e689cf5accd7c15d6119b7d019e925410a4c57af Mon Sep 17 00:00:00 2001 From: Tatiana Kapos Date: Thu, 26 Dec 2024 11:44:21 -0800 Subject: [PATCH 3/3] remove overrides --- vnext/overrides.json | 24 -- .../NativeAnimatedAllowlist.windows.js | 122 ------ .../Animated/nodes/AnimatedProps.windows.js | 281 -------------- .../Animated/nodes/AnimatedStyle.windows.js | 251 ------------ .../animated/useAnimatedPropsMemo.windows.js | 356 ------------------ 5 files changed, 1034 deletions(-) delete mode 100644 vnext/src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js delete mode 100644 vnext/src-win/Libraries/Animated/nodes/AnimatedProps.windows.js delete mode 100644 vnext/src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js delete mode 100644 vnext/src-win/src/private/animated/useAnimatedPropsMemo.windows.js diff --git a/vnext/overrides.json b/vnext/overrides.json index c99758d5da4..7fb9d3439fb 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -258,24 +258,6 @@ "baseFile": "packages/react-native/Libraries/Alert/Alert.js", "baseHash": "173b99e6ae120f14176cf3425877728787d3feed" }, - { - "type": "derived", - "file": "src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js", - "baseFile": "packages/react-native/Libraries/Animated/NativeAnimatedAllowlist.js", - "baseHash": "0d731685ff1ce7e4fc85000e341329387c603512" - }, - { - "type": "derived", - "file": "src-win/Libraries/Animated/nodes/AnimatedProps.windows.js", - "baseFile": "packages/react-native/Libraries/Animated/nodes/AnimatedProps.js", - "baseHash": "210b39d5e3ba0a0e338d6cdbffa9402b8ad52a6e" - }, - { - "type": "derived", - "file": "src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js", - "baseFile": "packages/react-native/Libraries/Animated/nodes/AnimatedStyle.js", - "baseHash": "8d506f2b8d8b2d9d0efdad1162314f884b9ab631" - }, { "type": "platform", "file": "src-win/Libraries/AppTheme/AppTheme.js" @@ -630,12 +612,6 @@ "baseFile": "packages/react-native/Libraries/Utilities/Platform.android.js", "baseHash": "33f07d6fddb5290d05c8d4cc490312e3af88c70b" }, - { - "type": "derived", - "file": "src-win/src/private/animated/useAnimatedPropsMemo.windows.js", - "baseFile": "packages/react-native/src/private/animated/useAnimatedPropsMemo.js", - "baseHash": "c983a4da2ddd6ffcb37d39241c77149a24b68dbb" - }, { "type": "copy", "file": "src-win/src/private/debugging/ReactDevToolsSettingsManager.windows.js", diff --git a/vnext/src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js b/vnext/src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js deleted file mode 100644 index ac41c77621e..00000000000 --- a/vnext/src-win/Libraries/Animated/NativeAnimatedAllowlist.windows.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -import type {AnimatedPropsAllowlist} from './nodes/AnimatedProps'; - -import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags'; - -/** - * Styles allowed by the native animated implementation. - * - * In general native animated implementation should support any numeric or color property that - * doesn't need to be updated through the shadow view hierarchy (all non-layout properties). - */ -const SUPPORTED_COLOR_STYLES: {[string]: true} = { - backgroundColor: true, - borderBottomColor: true, - borderColor: true, - borderEndColor: true, - borderLeftColor: true, - borderRightColor: true, - borderStartColor: true, - borderTopColor: true, - color: true, - tintColor: true, -}; - -const SUPPORTED_STYLES: {[string]: true} = { - ...SUPPORTED_COLOR_STYLES, - borderBottomEndRadius: true, - borderBottomLeftRadius: true, - borderBottomRightRadius: true, - borderBottomStartRadius: true, - borderEndEndRadius: true, - borderEndStartRadius: true, - borderRadius: true, - borderTopEndRadius: true, - borderTopLeftRadius: true, - borderTopRightRadius: true, - borderTopStartRadius: true, - borderStartEndRadius: true, - borderStartStartRadius: true, - elevation: true, - opacity: true, - transform: true, - zIndex: true, - /* ios styles */ - shadowOpacity: true, - shadowRadius: true, - /* legacy android transform properties */ - scaleX: true, - scaleY: true, - translateX: true, - translateY: true, -}; - -const SUPPORTED_TRANSFORMS: {[string]: true} = { - translateX: true, - translateY: true, - scale: true, - scaleX: true, - scaleY: true, - rotate: true, - rotateX: true, - rotateY: true, - rotateZ: true, - perspective: true, - skewX: true, - skewY: true, - ...(ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform() - ? {matrix: true} - : {}), -}; - -const SUPPORTED_INTERPOLATION_PARAMS: {[string]: true} = { - inputRange: true, - outputRange: true, - extrapolate: true, - extrapolateRight: true, - extrapolateLeft: true, -}; - -/** - * Default allowlist for component props that support native animated values. - */ -export default { - style: SUPPORTED_STYLES, -} as AnimatedPropsAllowlist; - -export function allowInterpolationParam(param: string): void { - SUPPORTED_INTERPOLATION_PARAMS[param] = true; -} - -export function allowStyleProp(prop: string): void { - SUPPORTED_STYLES[prop] = true; -} - -export function allowTransformProp(prop: string): void { - SUPPORTED_TRANSFORMS[prop] = true; -} - -export function isSupportedColorStyleProp(prop: string): boolean { - return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop); -} - -export function isSupportedInterpolationParam(param: string): boolean { - return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param); -} - -export function isSupportedStyleProp(prop: string): boolean { - return SUPPORTED_STYLES.hasOwnProperty(prop); -} - -export function isSupportedTransformProp(prop: string): boolean { - return SUPPORTED_TRANSFORMS.hasOwnProperty(prop); -} diff --git a/vnext/src-win/Libraries/Animated/nodes/AnimatedProps.windows.js b/vnext/src-win/Libraries/Animated/nodes/AnimatedProps.windows.js deleted file mode 100644 index feeaa195550..00000000000 --- a/vnext/src-win/Libraries/Animated/nodes/AnimatedProps.windows.js +++ /dev/null @@ -1,281 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -import type {PlatformConfig} from '../AnimatedPlatformConfig'; -import type {AnimatedStyleAllowlist} from './AnimatedStyle'; - -import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper'; -import {findNodeHandle} from '../../ReactNative/RendererProxy'; -import {AnimatedEvent} from '../AnimatedEvent'; -import AnimatedNode from './AnimatedNode'; -import AnimatedObject from './AnimatedObject'; -import AnimatedStyle from './AnimatedStyle'; -import invariant from 'invariant'; - -export type AnimatedPropsAllowlist = $ReadOnly<{ - style?: ?AnimatedStyleAllowlist, - [string]: true, -}>; - -function createAnimatedProps( - inputProps: {[string]: mixed}, - allowlist: ?AnimatedPropsAllowlist, -): [$ReadOnlyArray, $ReadOnlyArray, {[string]: mixed}] { - const nodeKeys: Array = []; - const nodes: Array = []; - const props: {[string]: mixed} = {}; - - const keys = Object.keys(inputProps); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const value = inputProps[key]; - - if (allowlist == null || hasOwn(allowlist, key)) { - let node; - if (key === 'style') { - node = AnimatedStyle.from(value, allowlist?.style); - } else if (value instanceof AnimatedNode) { - node = value; - } else { - node = AnimatedObject.from(value); - } - if (node == null) { - props[key] = value; - } else { - nodeKeys.push(key); - nodes.push(node); - props[key] = node; - } - } else { - if (__DEV__) { - // WARNING: This is a potentially expensive check that we should only - // do in development. Without this check in development, it might be - // difficult to identify which props need to be allowlisted. - if (AnimatedObject.from(inputProps[key]) != null) { - console.error( - `AnimatedProps: ${key} is not allowlisted for animation, but it ` + - 'contains AnimatedNode values; props allowing animation: ', - allowlist, - ); - } - } - props[key] = value; - } - } - - return [nodeKeys, nodes, props]; -} - -export default class AnimatedProps extends AnimatedNode { - #animatedView: any = null; - #callback: () => void; - #nodeKeys: $ReadOnlyArray; - #nodes: $ReadOnlyArray; - #props: {[string]: mixed}; - - constructor( - inputProps: {[string]: mixed}, - callback: () => void, - allowlist?: ?AnimatedPropsAllowlist, - ) { - super(); - const [nodeKeys, nodes, props] = createAnimatedProps(inputProps, allowlist); - this.#nodeKeys = nodeKeys; - this.#nodes = nodes; - this.#props = props; - this.#callback = callback; - } - - __getValue(): Object { - const props: {[string]: mixed} = {}; - - const keys = Object.keys(this.#props); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const value = this.#props[key]; - - if (value instanceof AnimatedNode) { - props[key] = value.__getValue(); - } else if (value instanceof AnimatedEvent) { - props[key] = value.__getHandler(); - } else { - props[key] = value; - } - } - - return props; - } - - /** - * Creates a new `props` object that contains the same props as the supplied - * `staticProps` object, except with animated nodes for any props that were - * created by this `AnimatedProps` instance. - */ - __getValueWithStaticProps(staticProps: Object): Object { - const props: {[string]: mixed} = {...staticProps}; - - const keys = Object.keys(staticProps); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const maybeNode = this.#props[key]; - - if (key === 'style' && maybeNode instanceof AnimatedStyle) { - props[key] = maybeNode.__getValueWithStaticStyle(staticProps.style); - } else if (maybeNode instanceof AnimatedNode) { - props[key] = maybeNode.__getValue(); - } else if (maybeNode instanceof AnimatedEvent) { - props[key] = maybeNode.__getHandler(); - } - } - - return props; - } - - __getAnimatedValue(): Object { - const props: {[string]: mixed} = {}; - - const nodeKeys = this.#nodeKeys; - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const key = nodeKeys[ii]; - const node = nodes[ii]; - props[key] = node.__getAnimatedValue(); - } - - return props; - } - - __attach(): void { - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__addChild(this); - } - } - - __detach(): void { - if (this.__isNative && this.#animatedView) { - this.__disconnectAnimatedView(); - } - this.#animatedView = null; - - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__removeChild(this); - } - - super.__detach(); - } - - update(): void { - this.#callback(); - } - - __makeNative(platformConfig: ?PlatformConfig): void { - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__makeNative(platformConfig); - } - - if (!this.__isNative) { - this.__isNative = true; - - // Since this does not call the super.__makeNative, we need to store the - // supplied platformConfig here, before calling __connectAnimatedView - // where it will be needed to traverse the graph of attached values. - super.__setPlatformConfig(platformConfig); - - if (this.#animatedView) { - this.__connectAnimatedView(); - } - } - } - - setNativeView(animatedView: any): void { - if (this.#animatedView === animatedView) { - return; - } - this.#animatedView = animatedView; - if (this.__isNative) { - this.__connectAnimatedView(); - } - } - - __connectAnimatedView(): void { - invariant(this.__isNative, 'Expected node to be marked as "native"'); - let nativeViewTag: ?number = findNodeHandle(this.#animatedView); - if (nativeViewTag == null) { - if (process.env.NODE_ENV === 'test') { - nativeViewTag = -1; - } else { - throw new Error('Unable to locate attached view in the native tree'); - } - } - NativeAnimatedHelper.API.connectAnimatedNodeToView( - this.__getNativeTag(), - nativeViewTag, - ); - } - - __disconnectAnimatedView(): void { - invariant(this.__isNative, 'Expected node to be marked as "native"'); - let nativeViewTag: ?number = findNodeHandle(this.#animatedView); - if (nativeViewTag == null) { - if (process.env.NODE_ENV === 'test') { - nativeViewTag = -1; - } else { - throw new Error('Unable to locate attached view in the native tree'); - } - } - NativeAnimatedHelper.API.disconnectAnimatedNodeFromView( - this.__getNativeTag(), - nativeViewTag, - ); - } - - __restoreDefaultValues(): void { - // When using the native driver, view properties need to be restored to - // their default values manually since react no longer tracks them. This - // is needed to handle cases where a prop driven by native animated is removed - // after having been changed natively by an animation. - if (this.__isNative) { - NativeAnimatedHelper.API.restoreDefaultValues(this.__getNativeTag()); - } - } - - __getNativeConfig(): Object { - const platformConfig = this.__getPlatformConfig(); - const propsConfig: {[string]: number} = {}; - - const nodeKeys = this.#nodeKeys; - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const key = nodeKeys[ii]; - const node = nodes[ii]; - node.__makeNative(platformConfig); - propsConfig[key] = node.__getNativeTag(); - } - - return { - type: 'props', - props: propsConfig, - }; - } -} - -// Supported versions of JSC do not implement the newer Object.hasOwn. Remove -// this shim when they do. -// $FlowIgnore[method-unbinding] -const _hasOwnProp = Object.prototype.hasOwnProperty; -const hasOwn: (obj: $ReadOnly<{...}>, prop: string) => boolean = - // $FlowIgnore[method-unbinding] - Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop)); diff --git a/vnext/src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js b/vnext/src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js deleted file mode 100644 index 359d2e7228a..00000000000 --- a/vnext/src-win/Libraries/Animated/nodes/AnimatedStyle.windows.js +++ /dev/null @@ -1,251 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - * @format - */ - -import type {PlatformConfig} from '../AnimatedPlatformConfig'; - -import {validateStyles} from '../../../src/private/animated/NativeAnimatedValidation'; -import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags'; -import flattenStyle from '../../StyleSheet/flattenStyle'; -import Platform from '../../Utilities/Platform'; -import AnimatedNode from './AnimatedNode'; -import AnimatedObject from './AnimatedObject'; -import AnimatedTransform from './AnimatedTransform'; -import AnimatedWithChildren from './AnimatedWithChildren'; - -export type AnimatedStyleAllowlist = $ReadOnly<{[string]: true}>; - -function createAnimatedStyle( - inputStyle: {[string]: mixed}, - allowlist: ?AnimatedStyleAllowlist, - keepUnanimatedValues: boolean, -): [$ReadOnlyArray, $ReadOnlyArray, {[string]: mixed}] { - const nodeKeys: Array = []; - const nodes: Array = []; - const style: {[string]: mixed} = {}; - - const keys = Object.keys(inputStyle); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const value = inputStyle[key]; - - if (allowlist == null || hasOwn(allowlist, key)) { - let node; - if (value != null && key === 'transform') { - node = ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform() - ? AnimatedObject.from(value) - : // $FlowFixMe[incompatible-call] - `value` is mixed. - AnimatedTransform.from(value); - } else if (value instanceof AnimatedNode) { - node = value; - } else { - node = AnimatedObject.from(value); - } - if (node == null) { - if (keepUnanimatedValues) { - style[key] = value; - } - } else { - nodeKeys.push(key); - nodes.push(node); - style[key] = node; - } - } else { - if (__DEV__) { - // WARNING: This is a potentially expensive check that we should only - // do in development. Without this check in development, it might be - // difficult to identify which styles need to be allowlisted. - if (AnimatedObject.from(inputStyle[key]) != null) { - console.error( - `AnimatedStyle: ${key} is not allowlisted for animation, but it ` + - 'contains AnimatedNode values; styles allowing animation: ', - allowlist, - ); - } - } - if (keepUnanimatedValues) { - style[key] = value; - } - } - } - - return [nodeKeys, nodes, style]; -} - -export default class AnimatedStyle extends AnimatedWithChildren { - #inputStyle: any; - #nodeKeys: $ReadOnlyArray; - #nodes: $ReadOnlyArray; - #style: {[string]: mixed}; - - /** - * Creates an `AnimatedStyle` if `value` contains `AnimatedNode` instances. - * Otherwise, returns `null`. - */ - static from( - inputStyle: any, - allowlist: ?AnimatedStyleAllowlist, - ): ?AnimatedStyle { - const flatStyle = flattenStyle(inputStyle); - if (flatStyle == null) { - return null; - } - const [nodeKeys, nodes, style] = createAnimatedStyle( - flatStyle, - allowlist, - Platform.OS !== 'web', - ); - if (nodes.length === 0) { - return null; - } - return new AnimatedStyle(nodeKeys, nodes, style, inputStyle); - } - - constructor( - nodeKeys: $ReadOnlyArray, - nodes: $ReadOnlyArray, - style: {[string]: mixed}, - inputStyle: any, - ) { - super(); - this.#nodeKeys = nodeKeys; - this.#nodes = nodes; - this.#style = style; - this.#inputStyle = inputStyle; - } - - __getValue(): Object | Array { - const style: {[string]: mixed} = {}; - - const keys = Object.keys(this.#style); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const value = this.#style[key]; - - if (value instanceof AnimatedNode) { - style[key] = value.__getValue(); - } else { - style[key] = value; - } - } - - /* $FlowFixMe[incompatible-type] Error found due to incomplete typing of - * Platform.flow.js */ - return Platform.OS === 'web' ? [this.#inputStyle, style] : style; - } - - /** - * Creates a new `style` object that contains the same style properties as - * the supplied `staticStyle` object, except with animated nodes for any - * style properties that were created by this `AnimatedStyle` instance. - */ - __getValueWithStaticStyle(staticStyle: Object): Object | Array { - const flatStaticStyle = flattenStyle(staticStyle); - const style: {[string]: mixed} = - flatStaticStyle == null - ? {} - : flatStaticStyle === staticStyle - ? // Copy the input style, since we'll mutate it below. - {...flatStaticStyle} - : // Reuse `flatStaticStyle` if it is a newly created object. - flatStaticStyle; - - const keys = Object.keys(style); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const maybeNode = this.#style[key]; - - if (key === 'transform' && maybeNode instanceof AnimatedTransform) { - style[key] = maybeNode.__getValueWithStaticTransforms( - // NOTE: This check should not be necessary, but the types are not - // enforced as of this writing. - Array.isArray(style[key]) ? style[key] : [], - ); - } else if (maybeNode instanceof AnimatedObject) { - style[key] = maybeNode.__getValueWithStaticObject(style[key]); - } else if (maybeNode instanceof AnimatedNode) { - style[key] = maybeNode.__getValue(); - } - } - - /* $FlowFixMe[incompatible-type] Error found due to incomplete typing of - * Platform.flow.js */ - return Platform.OS === 'web' ? [this.#inputStyle, style] : style; - } - - __getAnimatedValue(): Object { - const style: {[string]: mixed} = {}; - - const nodeKeys = this.#nodeKeys; - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const key = nodeKeys[ii]; - const node = nodes[ii]; - style[key] = node.__getAnimatedValue(); - } - - return style; - } - - __attach(): void { - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__addChild(this); - } - } - - __detach(): void { - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__removeChild(this); - } - super.__detach(); - } - - __makeNative(platformConfig: ?PlatformConfig) { - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const node = nodes[ii]; - node.__makeNative(platformConfig); - } - super.__makeNative(platformConfig); - } - - __getNativeConfig(): Object { - const platformConfig = this.__getPlatformConfig(); - const styleConfig: {[string]: ?number} = {}; - - const nodeKeys = this.#nodeKeys; - const nodes = this.#nodes; - for (let ii = 0, length = nodes.length; ii < length; ii++) { - const key = nodeKeys[ii]; - const node = nodes[ii]; - node.__makeNative(platformConfig); - styleConfig[key] = node.__getNativeTag(); - } - - if (__DEV__) { - validateStyles(styleConfig); - } - return { - type: 'style', - style: styleConfig, - }; - } -} - -// Supported versions of JSC do not implement the newer Object.hasOwn. Remove -// this shim when they do. -// $FlowIgnore[method-unbinding] -const _hasOwnProp = Object.prototype.hasOwnProperty; -const hasOwn: (obj: $ReadOnly<{...}>, prop: string) => boolean = - // $FlowIgnore[method-unbinding] - Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop)); diff --git a/vnext/src-win/src/private/animated/useAnimatedPropsMemo.windows.js b/vnext/src-win/src/private/animated/useAnimatedPropsMemo.windows.js deleted file mode 100644 index 1f093c205a9..00000000000 --- a/vnext/src-win/src/private/animated/useAnimatedPropsMemo.windows.js +++ /dev/null @@ -1,356 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - * @oncall react_native - */ - -import type AnimatedProps from '../../../Libraries/Animated/nodes/AnimatedProps'; -import type {AnimatedPropsAllowlist} from '../../../Libraries/Animated/nodes/AnimatedProps'; -import type {AnimatedStyleAllowlist} from '../../../Libraries/Animated/nodes/AnimatedStyle'; - -import {AnimatedEvent} from '../../../Libraries/Animated/AnimatedEvent'; -import AnimatedNode from '../../../Libraries/Animated/nodes/AnimatedNode'; -import {isPlainObject} from '../../../Libraries/Animated/nodes/AnimatedObject'; -import flattenStyle from '../../../Libraries/StyleSheet/flattenStyle'; -import nullthrows from 'nullthrows'; -import {useMemo, useState} from 'react'; - -type CompositeKey = { - style?: {[string]: CompositeKeyComponent}, - [string]: - | CompositeKeyComponent - | AnimatedEvent - | $ReadOnlyArray - | $ReadOnly<{[string]: mixed}>, -}; - -type CompositeKeyComponent = - | AnimatedNode - | Array - | {[string]: CompositeKeyComponent}; - -type $ReadOnlyCompositeKey = $ReadOnly<{ - style?: $ReadOnly<{[string]: CompositeKeyComponent}>, - [string]: - | $ReadOnlyCompositeKeyComponent - | AnimatedEvent - | $ReadOnlyArray - | $ReadOnly<{[string]: mixed}>, -}>; - -type $ReadOnlyCompositeKeyComponent = - | AnimatedNode - | $ReadOnlyArray<$ReadOnlyCompositeKeyComponent | null> - | $ReadOnly<{[string]: $ReadOnlyCompositeKeyComponent}>; - -/** - * A hook that returns an `AnimatedProps` object that is memoized based on the - * subset of `props` that are instances of `AnimatedNode` or `AnimatedEvent`. - */ -export function useAnimatedPropsMemo( - create: () => AnimatedProps, - // TODO: Make this two separate arguments after the experiment is over. This - // is only an array-like structure to make it easier to experiment with this - // and `useMemo`. - [allowlist, props]: [?AnimatedPropsAllowlist, {[string]: mixed}], -): AnimatedProps { - const compositeKey = useMemo( - () => createCompositeKeyForProps(props, allowlist), - [allowlist, props], - ); - - const [state, setState] = useState<{ - allowlist: ?AnimatedPropsAllowlist, - compositeKey: $ReadOnlyCompositeKey | null, - value: AnimatedProps, - }>(() => ({ - allowlist, - compositeKey, - value: create(), - })); - - if ( - state.allowlist !== allowlist || - !areCompositeKeysEqual(state.compositeKey, compositeKey) - ) { - setState({ - allowlist, - compositeKey, - value: create(), - }); - } - return state.value; -} - -/** - * Creates a new composite key for a `props` object that can be used to detect - * whether a new `AnimatedProps` instance must be created. - * - * - With an allowlist, those props are searched for `AnimatedNode` instances. - * - Without an allowlist, `style` is searched for `AnimatedNode` instances, - * but all other objects and arrays are included (not searched). We do not - * search objects and arrays without an allowlist in case they are very large - * data structures. We safely traverse `style` becuase it is bounded. - * - * Any `AnimatedEvent` instances at the first depth are always included. - * - * If `props` contains no `AnimatedNode` or `AnimatedEvent` instances, this - * returns null. - */ -export function createCompositeKeyForProps( - props: $ReadOnly<{[string]: mixed}>, - allowlist: ?AnimatedPropsAllowlist, -): $ReadOnlyCompositeKey | null { - let compositeKey: CompositeKey | null = null; - - const keys = Object.keys(props); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - const value = props[key]; - - if (allowlist == null || hasOwn(allowlist, key)) { - let compositeKeyComponent; - if (key === 'style') { - // $FlowFixMe[incompatible-call] - `style` is a valid argument. - // $FlowFixMe[incompatible-type] - `flattenStyle` returns an object. - const flatStyle: ?{[string]: mixed} = flattenStyle(value); - if (flatStyle != null) { - compositeKeyComponent = createCompositeKeyForObject( - flatStyle, - allowlist?.style, - ); - } - } else if ( - value instanceof AnimatedNode || - value instanceof AnimatedEvent - ) { - compositeKeyComponent = value; - } else if (Array.isArray(value)) { - compositeKeyComponent = - allowlist == null ? value : createCompositeKeyForArray(value); - } else if (isPlainObject(value)) { - compositeKeyComponent = - allowlist == null ? value : createCompositeKeyForObject(value); - } - if (compositeKeyComponent != null) { - if (compositeKey == null) { - compositeKey = {} as CompositeKey; - } - compositeKey[key] = compositeKeyComponent; - } - } - } - - return compositeKey; -} - -/** - * Creates a new composite key for an array that retains all values that are or - * contain `AnimatedNode` instances, and `null` for the rest. - * - * If `array` contains no `AnimatedNode` instances, this returns null. - */ -function createCompositeKeyForArray( - array: $ReadOnlyArray, -): $ReadOnlyArray<$ReadOnlyCompositeKeyComponent | null> | null { - let compositeKey: Array<$ReadOnlyCompositeKeyComponent | null> | null = null; - - for (let ii = 0, length = array.length; ii < length; ii++) { - const value = array[ii]; - - let compositeKeyComponent; - if (value instanceof AnimatedNode) { - compositeKeyComponent = value; - } else if (Array.isArray(value)) { - compositeKeyComponent = createCompositeKeyForArray(value); - } else if (isPlainObject(value)) { - compositeKeyComponent = createCompositeKeyForObject(value); - } - if (compositeKeyComponent != null) { - if (compositeKey == null) { - compositeKey = new Array<$ReadOnlyCompositeKeyComponent | null>( - array.length, - ).fill(null); - } - compositeKey[ii] = compositeKeyComponent; - } - } - - return compositeKey; -} - -/** - * Creates a new composite key for an object that retains only properties that - * are or contain `AnimatedNode` instances. - * - * When used to create composite keys for `style` props: - * - * - With an allowlist, those properties are searched. - * - Without an allowlist, every property is searched. - * - * If `object` contains no `AnimatedNode` instances, this returns null. - */ -function createCompositeKeyForObject( - object: $ReadOnly<{[string]: mixed}>, - allowlist?: ?AnimatedStyleAllowlist, -): $ReadOnly<{[string]: $ReadOnlyCompositeKeyComponent}> | null { - let compositeKey: {[string]: $ReadOnlyCompositeKeyComponent} | null = null; - - const keys = Object.keys(object); - for (let ii = 0, length = keys.length; ii < length; ii++) { - const key = keys[ii]; - - if (allowlist == null || hasOwn(allowlist, key)) { - const value = object[key]; - - let compositeKeyComponent; - if (value instanceof AnimatedNode) { - compositeKeyComponent = value; - } else if (Array.isArray(value)) { - compositeKeyComponent = createCompositeKeyForArray(value); - } else if (isPlainObject(value)) { - compositeKeyComponent = createCompositeKeyForObject(value); - } - if (compositeKeyComponent != null) { - if (compositeKey == null) { - compositeKey = {} as {[string]: $ReadOnlyCompositeKeyComponent}; - } - compositeKey[key] = compositeKeyComponent; - } - } - } - - return compositeKey; -} - -export function areCompositeKeysEqual( - maybePrev: $ReadOnlyCompositeKey | null, - maybeNext: $ReadOnlyCompositeKey | null, - allowlist: ?AnimatedPropsAllowlist, -): boolean { - if (maybePrev === maybeNext) { - return true; - } - if (maybePrev === null || maybeNext === null) { - return false; - } - // Help Flow retain the type refinements of these. - const prev = maybePrev; - const next = maybeNext; - - const keys = Object.keys(prev); - const length = keys.length; - if (length !== Object.keys(next).length) { - return false; - } - for (let ii = 0; ii < length; ii++) { - const key = keys[ii]; - if (!hasOwn(next, key)) { - return false; - } - const prevComponent = prev[key]; - const nextComponent = next[key]; - - if (key === 'style') { - // We know style components are objects with non-mixed values. - if ( - !areCompositeKeyComponentsEqual( - // $FlowIgnore[incompatible-cast] - prevComponent as $ReadOnlyCompositeKeyComponent, - // $FlowIgnore[incompatible-cast] - nextComponent as $ReadOnlyCompositeKeyComponent, - ) - ) { - return false; - } - } else if ( - prevComponent instanceof AnimatedNode || - prevComponent instanceof AnimatedEvent - ) { - if (prevComponent !== nextComponent) { - return false; - } - } else { - // When `allowlist` is null, the components must be the same. Otherwise, - // we created the components using deep traversal, so deep compare them. - if (allowlist == null) { - if (prevComponent !== nextComponent) { - return false; - } - } else { - if ( - !areCompositeKeyComponentsEqual( - // $FlowIgnore[incompatible-cast] - prevComponent as $ReadOnlyCompositeKeyComponent, - // $FlowIgnore[incompatible-cast] - nextComponent as $ReadOnlyCompositeKeyComponent, - ) - ) { - return false; - } - } - } - } - return true; -} - -function areCompositeKeyComponentsEqual( - prev: $ReadOnlyCompositeKeyComponent | null, - next: $ReadOnlyCompositeKeyComponent | null, -): boolean { - if (prev === next) { - return true; - } - if (prev instanceof AnimatedNode) { - return prev === next; - } - if (Array.isArray(prev)) { - if (!Array.isArray(next)) { - return false; - } - const length = prev.length; - if (length !== next.length) { - return false; - } - for (let ii = 0; ii < length; ii++) { - if (!areCompositeKeyComponentsEqual(prev[ii], next[ii])) { - return false; - } - } - return true; - } - if (isPlainObject(prev)) { - if (!isPlainObject(next)) { - return false; - } - const keys = Object.keys(prev); - const length = keys.length; - if (length !== Object.keys(next).length) { - return false; - } - for (let ii = 0; ii < length; ii++) { - const key = keys[ii]; - if ( - !hasOwn(nullthrows(next), key) || - !areCompositeKeyComponentsEqual(prev[key], next[key]) - ) { - return false; - } - } - return true; - } - return false; -} - -// Supported versions of JSC do not implement the newer Object.hasOwn. Remove -// this shim when they do. -// $FlowIgnore[method-unbinding] -const _hasOwnProp = Object.prototype.hasOwnProperty; -const hasOwn: (obj: $ReadOnly<{...}>, prop: string) => boolean = - // $FlowIgnore[method-unbinding] - Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop));