@react-native-ohos/react-native-reanimated 3.18.2-rc.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compatibility.json +161 -0
- package/harmony/reanimated/BuildProfile.ets +1 -1
- package/harmony/reanimated/build-profile.json5 +18 -11
- package/harmony/reanimated/oh-package.json5 +12 -11
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +31 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +81 -86
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +46 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +390 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +16 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +30 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.cpp +46 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.h +23 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.cpp +53 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h +21 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.cpp +166 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h +71 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.cpp +368 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h +53 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp +594 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h +67 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp +52 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h +26 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.cpp +156 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.h +76 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +94 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.h +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.cpp +48 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.h +31 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +135 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.h +61 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +100 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +45 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.cpp +81 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.h +53 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +122 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.h +38 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +82 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +63 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +118 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +174 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +111 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.cpp +196 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.h +66 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.cpp +134 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +44 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +174 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +45 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +26 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +90 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +43 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +17 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +127 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +51 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +145 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.cpp +69 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.h +22 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.cpp +66 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.h +15 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.cpp +28 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.h +15 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.cpp +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.h +12 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +157 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +189 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +76 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +66 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/configs.h +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +136 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +40 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.cpp +38 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.h +24 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.cpp +58 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.h +24 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/blur.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/brightness.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/contrast.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/dropShadow.h +17 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/grayscale.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/hueRotate.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/invert.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/opacity.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/saturate.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/sepia.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.cpp +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.h +32 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +99 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +37 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +308 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +100 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.cpp +19 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +94 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.cpp +18 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.h +43 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +26 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +103 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +42 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +224 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.h +52 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +218 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +89 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.cpp +149 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.h +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +208 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.h +56 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.cpp +42 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.h +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.cpp +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.cpp +28 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.h +25 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.cpp +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.h +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.cpp +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.h +25 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.h +43 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +70 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.h +40 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +146 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +71 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +155 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +53 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +170 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +67 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/KeyframeProgressProvider.h +12 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +31 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +193 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +77 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +340 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +80 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +45 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +29 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +167 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +51 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +61 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.cpp +80 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +93 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +111 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +75 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +45 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.cpp +12 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.h +10 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.cpp +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.h +23 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +149 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +32 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +113 -101
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +49 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +46 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +56 -96
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +37 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +104 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +22 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +25 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +160 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +71 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +161 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +65 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +11 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +137 -232
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +82 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +79 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +81 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +864 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +214 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/{LayoutAnimationsProxy.cpp → LayoutAnimationsProxy_Legacy.cpp} +897 -870
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +220 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +31 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +146 -176
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp +456 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +102 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +544 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.cpp +119 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +1380 -971
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +230 -252
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +183 -231
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +93 -109
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +54 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +28 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +58 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +31 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.cpp +18 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.h +44 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +67 -98
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +114 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +46 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/{worklets → reanimated}/Tools/ReanimatedVersion.h +18 -19
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +63 -85
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +0 -3
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +266 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +36 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +3 -3
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +5 -1
- package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +1 -4
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +69 -50
- package/scripts/deploy.js +191 -0
- package/scripts/set-reanimated-version.js +37 -0
- package/scripts/update-version.js +119 -0
- package/scripts/validate-react-native-version.js +46 -0
- package/scripts/validate-worklets-build.js +17 -0
- package/scripts/validate-worklets-version.js +84 -0
- package/scripts/worklets-version.json +4 -0
- package/LICENSE +0 -21
- package/README.OpenSource +0 -11
- package/README.md +0 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +0 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +0 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +0 -147
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +0 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +0 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +0 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +0 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +0 -59
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +0 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +0 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +0 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +0 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +0 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +0 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +0 -326
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +0 -345
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +0 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +0 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +0 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +0 -342
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +0 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +0 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +0 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +0 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +0 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +0 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +0 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +0 -199
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +0 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +0 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +0 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +0 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +0 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +0 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +0 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +0 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +0 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +0 -112
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +0 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +0 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +0 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +0 -191
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +0 -173
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +0 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +0 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +0 -189
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +0 -22
- package/harmony/reanimated/src/main/cpp/ReanimatedLogger.cpp +0 -33
- package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +0 -61
- package/harmony/reanimated/src/main/cpp/WorkletsModule.h +0 -22
- package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +0 -89
- package/harmony/reanimated/src/main/cpp/patches/Fabric/ShadowTreeCloner.cpp +0 -95
- package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +0 -964
- package/harmony/reanimated/src/main/ets/WorkletsModule.ts +0 -15
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <worklets/Tools/Defs.h>
|
|
4
|
-
|
|
5
|
-
// Only include this file in Hermes-enabled builds as some platforms (like tvOS)
|
|
6
|
-
// don't support hermes and it causes the compilation to fail.
|
|
7
|
-
#if JS_RUNTIME_HERMES
|
|
8
|
-
|
|
9
|
-
#include <cxxreact/MessageQueueThread.h>
|
|
10
|
-
#include <hermes/hermes.h>
|
|
11
|
-
#include <jsi/decorator.h>
|
|
12
|
-
#include <jsi/jsi.h>
|
|
13
|
-
|
|
14
|
-
#include <atomic>
|
|
15
|
-
#include <memory>
|
|
16
|
-
#include <string>
|
|
17
|
-
#include <thread>
|
|
18
|
-
|
|
19
|
-
#if HERMES_ENABLE_DEBUGGER
|
|
20
|
-
#include <hermes/inspector-modern/chrome/Registration.h>
|
|
21
|
-
#endif // HERMES_ENABLE_DEBUGGER
|
|
22
|
-
|
|
23
|
-
namespace worklets {
|
|
24
|
-
|
|
25
|
-
using namespace facebook;
|
|
26
|
-
using namespace react;
|
|
27
|
-
#if HERMES_ENABLE_DEBUGGER
|
|
28
|
-
using namespace facebook::hermes::inspector_modern;
|
|
29
|
-
#endif // HERMES_ENABLE_DEBUGGER
|
|
30
|
-
|
|
31
|
-
// ReentrancyCheck is copied from React Native
|
|
32
|
-
// from ReactCommon/hermes/executor/HermesExecutorFactory.cpp
|
|
33
|
-
// https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp
|
|
34
|
-
struct ReanimatedReentrancyCheck {
|
|
35
|
-
// This is effectively a very subtle and complex assert, so only
|
|
36
|
-
// include it in builds which would include asserts.
|
|
37
|
-
#ifndef NDEBUG
|
|
38
|
-
ReanimatedReentrancyCheck() : tid(std::thread::id()), depth(0) {}
|
|
39
|
-
|
|
40
|
-
void before() {
|
|
41
|
-
std::thread::id this_id = std::this_thread::get_id();
|
|
42
|
-
std::thread::id expected = std::thread::id();
|
|
43
|
-
|
|
44
|
-
// A note on memory ordering: the main purpose of these checks is
|
|
45
|
-
// to observe a before/before race, without an intervening after.
|
|
46
|
-
// This will be detected by the compare_exchange_strong atomicity
|
|
47
|
-
// properties, regardless of memory order.
|
|
48
|
-
//
|
|
49
|
-
// For everything else, it is easiest to think of 'depth' as a
|
|
50
|
-
// proxy for any access made inside the VM. If access to depth
|
|
51
|
-
// are reordered incorrectly, the same could be true of any other
|
|
52
|
-
// operation made by the VM. In fact, using acquire/release
|
|
53
|
-
// memory ordering could create barriers which mask a programmer
|
|
54
|
-
// error. So, we use relaxed memory order, to avoid masking
|
|
55
|
-
// actual ordering errors. Although, in practice, ordering errors
|
|
56
|
-
// of this sort would be surprising, because the decorator would
|
|
57
|
-
// need to call after() without before().
|
|
58
|
-
|
|
59
|
-
if (tid.compare_exchange_strong(
|
|
60
|
-
expected, this_id, std::memory_order_relaxed)) {
|
|
61
|
-
// Returns true if tid and expected were the same. If they
|
|
62
|
-
// were, then the stored tid referred to no thread, and we
|
|
63
|
-
// atomically saved this thread's tid. Now increment depth.
|
|
64
|
-
assert(depth == 0 && "[Reanimated] No thread id, but depth != 0");
|
|
65
|
-
++depth;
|
|
66
|
-
} else if (expected == this_id) {
|
|
67
|
-
// If the stored tid referred to a thread, expected was set to
|
|
68
|
-
// that value. If that value is this thread's tid, that's ok,
|
|
69
|
-
// just increment depth again.
|
|
70
|
-
assert(depth != 0 && "[Reanimated] Thread id was set, but depth == 0");
|
|
71
|
-
++depth;
|
|
72
|
-
} else {
|
|
73
|
-
// The stored tid was some other thread. This indicates a bad
|
|
74
|
-
// programmer error, where VM methods were called on two
|
|
75
|
-
// different threads unsafely. Fail fast (and hard) so the
|
|
76
|
-
// crash can be analyzed.
|
|
77
|
-
__builtin_trap();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
void after() {
|
|
82
|
-
assert(
|
|
83
|
-
tid.load(std::memory_order_relaxed) == std::this_thread::get_id() &&
|
|
84
|
-
"[Reanimated] No thread id in after()");
|
|
85
|
-
if (--depth == 0) {
|
|
86
|
-
// If we decremented depth to zero, store no-thread into tid.
|
|
87
|
-
std::thread::id expected = std::this_thread::get_id();
|
|
88
|
-
bool didWrite = tid.compare_exchange_strong(
|
|
89
|
-
expected, std::thread::id(), std::memory_order_relaxed);
|
|
90
|
-
assert(didWrite && "[Reanimated] Decremented to zero, but no tid write");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
std::atomic<std::thread::id> tid;
|
|
95
|
-
// This is not atomic, as it is only written or read from the owning
|
|
96
|
-
// thread.
|
|
97
|
-
unsigned int depth;
|
|
98
|
-
#endif // NDEBUG
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// This is in fact a subclass of jsi::Runtime! WithRuntimeDecorator is a
|
|
102
|
-
// template class that is a subclass of DecoratedRuntime which is also a
|
|
103
|
-
// template class that then inherits its template, which in this case is
|
|
104
|
-
// jsi::Runtime. So the inheritance is: ReanimatedHermesRuntime ->
|
|
105
|
-
// WithRuntimeDecorator -> DecoratedRuntime -> jsi::Runtime You can find out
|
|
106
|
-
// more about this in ReactCommon/jsi/jsi/Decorator.h or by following this link:
|
|
107
|
-
// https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/jsi/jsi/decorator.h
|
|
108
|
-
class ReanimatedHermesRuntime
|
|
109
|
-
: public jsi::WithRuntimeDecorator<ReanimatedReentrancyCheck> {
|
|
110
|
-
public:
|
|
111
|
-
ReanimatedHermesRuntime(
|
|
112
|
-
std::unique_ptr<facebook::hermes::HermesRuntime> runtime,
|
|
113
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
114
|
-
const std::string &name);
|
|
115
|
-
~ReanimatedHermesRuntime();
|
|
116
|
-
|
|
117
|
-
private:
|
|
118
|
-
std::unique_ptr<facebook::hermes::HermesRuntime> runtime_;
|
|
119
|
-
ReanimatedReentrancyCheck reentrancyCheck_;
|
|
120
|
-
#if HERMES_ENABLE_DEBUGGER
|
|
121
|
-
chrome::DebugSessionToken debugToken_;
|
|
122
|
-
#endif // HERMES_ENABLE_DEBUGGER
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
} // namespace worklets
|
|
126
|
-
|
|
127
|
-
#endif // JS_RUNTIME_HERMES
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#include <worklets/Tools/Defs.h>
|
|
2
|
-
#include <worklets/WorkletRuntime/ReanimatedRuntime.h>
|
|
3
|
-
|
|
4
|
-
#include <cxxreact/MessageQueueThread.h>
|
|
5
|
-
#include <jsi/jsi.h>
|
|
6
|
-
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <utility>
|
|
9
|
-
|
|
10
|
-
#if JS_RUNTIME_HERMES
|
|
11
|
-
#include <worklets/WorkletRuntime/ReanimatedHermesRuntime.h>
|
|
12
|
-
#elif JS_RUNTIME_V8
|
|
13
|
-
#include <v8runtime/V8RuntimeFactory.h>
|
|
14
|
-
#else
|
|
15
|
-
#include <jsc/JSCRuntime.h>
|
|
16
|
-
#endif // JS_RUNTIME
|
|
17
|
-
|
|
18
|
-
namespace worklets {
|
|
19
|
-
|
|
20
|
-
using namespace facebook;
|
|
21
|
-
using namespace react;
|
|
22
|
-
|
|
23
|
-
std::shared_ptr<jsi::Runtime> ReanimatedRuntime::make(
|
|
24
|
-
jsi::Runtime &rnRuntime,
|
|
25
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
26
|
-
const std::string &name) {
|
|
27
|
-
(void)rnRuntime; // used only for V8
|
|
28
|
-
#if JS_RUNTIME_HERMES
|
|
29
|
-
// We don't call `jsQueue->quitSynchronous()` here, since it will be done
|
|
30
|
-
// later in ReanimatedHermesRuntime
|
|
31
|
-
|
|
32
|
-
auto runtime = facebook::hermes::makeHermesRuntime();
|
|
33
|
-
return std::make_shared<ReanimatedHermesRuntime>(
|
|
34
|
-
std::move(runtime), jsQueue, name);
|
|
35
|
-
#elif JS_RUNTIME_V8
|
|
36
|
-
// This is required by iOS, because there is an assertion in the destructor
|
|
37
|
-
// that the thread was indeed `quit` before.
|
|
38
|
-
jsQueue->quitSynchronous();
|
|
39
|
-
|
|
40
|
-
auto config = std::make_unique<rnv8::V8RuntimeConfig>();
|
|
41
|
-
config->enableInspector = false;
|
|
42
|
-
config->appName = name;
|
|
43
|
-
return rnv8::createSharedV8Runtime(&rnRuntime, std::move(config));
|
|
44
|
-
#else
|
|
45
|
-
// This is required by iOS, because there is an assertion in the destructor
|
|
46
|
-
// that the thread was indeed `quit` before
|
|
47
|
-
jsQueue->quitSynchronous();
|
|
48
|
-
|
|
49
|
-
return facebook::jsc::makeJSCRuntime();
|
|
50
|
-
#endif
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <cxxreact/MessageQueueThread.h>
|
|
4
|
-
#include <jsi/jsi.h>
|
|
5
|
-
|
|
6
|
-
#include <memory>
|
|
7
|
-
#include <string>
|
|
8
|
-
|
|
9
|
-
namespace worklets {
|
|
10
|
-
|
|
11
|
-
using namespace facebook;
|
|
12
|
-
using namespace react;
|
|
13
|
-
|
|
14
|
-
class ReanimatedRuntime {
|
|
15
|
-
public:
|
|
16
|
-
static std::shared_ptr<jsi::Runtime> make(
|
|
17
|
-
jsi::Runtime &rnRuntime,
|
|
18
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
19
|
-
const std::string &name);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# Hermes Runtime initialization
|
|
2
|
-
|
|
3
|
-
_Last updated_: 13/09/2022 by @Kwasow
|
|
4
|
-
|
|
5
|
-
This document describes the current way of initializing Hermes and connecting
|
|
6
|
-
it to the debugger. The work I did was mainly based on
|
|
7
|
-
|
|
8
|
-
[HermesExecutorFactory.cpp](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp)
|
|
9
|
-
from React Native.
|
|
10
|
-
|
|
11
|
-
## Runtime initialization
|
|
12
|
-
|
|
13
|
-
If you take a look at `NativeProxy` (both on Android and iOS) you'll find
|
|
14
|
-
that it only makes a call to `ReanimatedRuntime::make(jsQueue)`. This
|
|
15
|
-
static function will return the correct runtime based on the user's configuration.
|
|
16
|
-
|
|
17
|
-
The initialization process is pretty simple and has only been moved out of
|
|
18
|
-
`NativeProxy` into `ReanimatedRuntime` without any major changes.
|
|
19
|
-
|
|
20
|
-
## Hermes runtime debugging
|
|
21
|
-
|
|
22
|
-
To enable debugging on the Hermes runtime we need to do two things:
|
|
23
|
-
|
|
24
|
-
1. Include source maps in JavaScript files
|
|
25
|
-
|
|
26
|
-
This part is done purely in JavaScript via the Babel plugin. The `makeWorklet`
|
|
27
|
-
function received an AST tree, which is aware of the modifications it made to
|
|
28
|
-
the code and therefore can generate the necessary source maps. It is important
|
|
29
|
-
that when we want to create a string from the AST we use the `generate` function
|
|
30
|
-
and enable source map generation so line mappings are not lost. Then when
|
|
31
|
-
transforming that code (ex. with `transformSync`) we have to pass the source
|
|
32
|
-
map as input so it can be updated.
|
|
33
|
-
|
|
34
|
-
Source map settings should always be set to `inline` so they are automatically
|
|
35
|
-
appended to the source code. The generated source map will be a base64 encoded
|
|
36
|
-
json.
|
|
37
|
-
|
|
38
|
-
A workletized function would look like this (after formattings):
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
function _f(number) {
|
|
42
|
-
console.log(_WORKLET, number);
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJtYXBwaW5ncyI6IkFBYXNCLFNBQUNBLEVBQUQsQ0FBQ0EsTUFBRCxFQUFvQjtBQUV0Q0MsU0FBTyxDQUFDQyxHQUFSRCxDQUFZRSxRQUFaRixFQUFzQkQsTUFBdEJDO0FBRmtCIiwibmFtZXMiOlsibnVtYmVyIiwiY29uc29sZSIsImxvZyIsIl9XT1JLTEVUIl0sInNvdXJjZXMiOlsiL1VzZXJzL2thcm9sL0dpdC9yZWFjdC1uYXRpdmUtcmVhbmltYXRlZC9GYWJyaWNFeGFtcGxlL3NyYy9Xb3JrbGV0RXhhbXBsZS50c3giXSwic291cmNlc0NvbnRlbnQiOlsiLyogZ2xvYmFsIF9XT1JLTEVUICovXG5pbXBvcnQgeyBCdXR0b24sIFZpZXcsIFN0eWxlU2hlZXQgfSBmcm9tICdyZWFjdC1uYXRpdmUnO1xuaW1wb3J0IHtcbiAgcnVuT25KUyxcbiAgcnVuT25VSSxcbiAgdXNlRGVyaXZlZFZhbHVlLFxuICB1c2VTaGFyZWRWYWx1ZSxcbn0gZnJvbSAncmVhY3QtbmF0aXZlLXJlYW5pbWF0ZWQnO1xuXG5pbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBXb3JrbGV0RXhhbXBsZSgpIHtcbiAgLy8gcnVuT25VSSBkZW1vXG4gIGNvbnN0IHNvbWVXb3JrbGV0ID0gKG51bWJlcjogbnVtYmVyKSA9PiB7XG4gICAgJ3dvcmtsZXQnO1xuICAgIGNvbnNvbGUubG9nKF9XT1JLTEVULCBudW1iZXIpOyAvLyBfV09SS0xFVCBzaG91bGQgYmUgdHJ1ZVxuICB9O1xuXG4gIGNvbnN0IGhhbmRsZVByZXNzMSA9ICgpID0+IHtcbiAgICBydW5PblVJKHNvbWVXb3JrbGV0KShNYXRoLnJhbmRvbSgpKTtcbiAgfTtcblxuICAvLyBydW5PbkpTIGRlbW9cbiAgY29uc3QgeCA9IHVzZVNoYXJlZFZhbHVlKDApO1xuXG4gIGNvbnN0IHNvbWVGdW5jdGlvbiA9IChudW1iZXI6IG51bWJlcikgPT4ge1xuICAgIGNvbnNvbGUubG9nKF9XT1JLTEVULCBudW1iZXIpOyAvLyBfV09SS0xFVCBzaG91bGQgYmUgZmFsc2VcbiAgfTtcblxuICB1c2VEZXJpdmVkVmFsdWUoKCkgPT4ge1xuICAgIHJ1bk9uSlMoc29tZUZ1bmN0aW9uKSh4LnZhbHVlKTtcbiAgfSk7XG5cbiAgY29uc3QgaGFuZGxlUHJlc3MyID0gKCkgPT4ge1xuICAgIHgudmFsdWUgPSBNYXRoLnJhbmRvbSgpO1xuICB9O1xuXG4gIHJldHVybiAoXG4gICAgPFZpZXcgc3R5bGU9e3N0eWxlcy5jb250YWluZXJ9PlxuICAgICAgPEJ1dHRvbiBvblByZXNzPXtoYW5kbGVQcmVzczF9IHRpdGxlPVwicnVuT25VSSBkZW1vXCIgLz5cbiAgICAgIDxCdXR0b24gb25QcmVzcz17aGFuZGxlUHJlc3MyfSB0aXRsZT1cInJ1bk9uSlMgZGVtb1wiIC8+XG4gICAgPC9WaWV3PlxuICApO1xufVxuXG5jb25zdCBzdHlsZXMgPSBTdHlsZVNoZWV0LmNyZWF0ZSh7XG4gIGNvbnRhaW5lcjoge1xuICAgIGZsZXg6IDEsXG4gICAgYWxpZ25JdGVtczogJ2NlbnRlcicsXG4gICAganVzdGlmeUNvbnRlbnQ6ICdjZW50ZXInLFxuICB9LFxufSk7XG4iXX0=
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
And the base64 string after decoding is:
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"version": 3,
|
|
52
|
-
"mappings": "AAasB,SAACA,EAAD,CAACA,MAAD,EAAoB;AAEtCC,SAAO,CAACC,GAARD,CAAYE,QAAZF,EAAsBD,MAAtBC;AAFkB",
|
|
53
|
-
"names": ["number", "console", "log", "_WORKLET"],
|
|
54
|
-
"sources": [
|
|
55
|
-
"/Users/karol/Git/react-native-reanimated/FabricExample/src/WorkletExample.tsx"
|
|
56
|
-
],
|
|
57
|
-
"sourcesContent": [
|
|
58
|
-
"/* global _WORKLET */\nimport { Button, View, StyleSheet } from 'react-native';\nimport {\n runOnJS,\n runOnUI,\n useDerivedValue,\n useSharedValue,\n} from 'react-native-reanimated';\n\nimport React from 'react';\n\nexport default function WorkletExample() {\n // runOnUI demo\n const someWorklet = (number: number) => {\n 'worklet';\n console.log(_WORKLET, number); // _WORKLET should be true\n };\n\n const handlePress1 = () => {\n runOnUI(someWorklet)(Math.random());\n };\n\n // runOnJS demo\n const x = useSharedValue(0);\n\n const someFunction = (number: number) => {\n console.log(_WORKLET, number); // _WORKLET should be false\n };\n\n useDerivedValue(() => {\n runOnJS(someFunction)(x.value);\n });\n\n const handlePress2 = () => {\n x.value = Math.random();\n };\n\n return (\n <View style={styles.container}>\n <Button onPress={handlePress1} title=\"runOnUI demo\" />\n <Button onPress={handlePress2} title=\"runOnJS demo\" />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
We run jest tests in release mode, because source maps will contain absolute
|
|
64
|
-
paths, which will be different on every machine and therefore would also alter
|
|
65
|
-
worklet hashes. Running in release mode prevents this.
|
|
66
|
-
|
|
67
|
-
2. Enable debugging on the runtime object
|
|
68
|
-
|
|
69
|
-
This is done by creating an adapter (`HermesExecutorRuntimeAdapter` inside of
|
|
70
|
-
`ReanimatedHermesRuntime.cpp`) which holds the runtime and allows the debugger
|
|
71
|
-
to communicate with it. The adapter is managed by a `Connection` (`ConnectionDemux`)
|
|
72
|
-
object, but this is not important in our case. We just have to make a call
|
|
73
|
-
to `facebook::hermes::inspector::chrome::enableDebugging()` and pass the adapter
|
|
74
|
-
and runtime name as parameters.
|
|
75
|
-
|
|
76
|
-
It is important to also `disableDebugging()` before the runtime is destroyed.
|
|
77
|
-
Failing to do so will probably crash the app as the debugger will try to
|
|
78
|
-
connect to a non-existent runtime.
|
|
79
|
-
|
|
80
|
-
The runtime should also be destroyed before the Reanimated module, because
|
|
81
|
-
otherwise there might be weird BAD_ACCESS errors when the gc gets it
|
|
82
|
-
hand on the runtime.
|
|
83
|
-
|
|
84
|
-
## Metro endpoint
|
|
85
|
-
|
|
86
|
-
Flipper and Chrome DevTools in general use the `localhost:8081/json` (where `8081`
|
|
87
|
-
is the port metro is running on) endpoint of metro to get the list of debuggable
|
|
88
|
-
targets (runtimes). For a normal React Native app the output would look something
|
|
89
|
-
like this:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
[
|
|
93
|
-
{
|
|
94
|
-
"id": "0-1",
|
|
95
|
-
"description": "org.reactjs.native.example.FabricExample",
|
|
96
|
-
"title": "Hermes React Native",
|
|
97
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
98
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D1",
|
|
99
|
-
"type": "node",
|
|
100
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=0&page=1",
|
|
101
|
-
"vm": "Hermes"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"id": "0--1",
|
|
105
|
-
"description": "org.reactjs.native.example.FabricExample",
|
|
106
|
-
"title": "React Native Experimental (Improved Chrome Reloads)",
|
|
107
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
108
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D-1",
|
|
109
|
-
"type": "node",
|
|
110
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=0&page=-1",
|
|
111
|
-
"vm": "don't use"
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
For an Android app with Reanimated it should include the Reanimated runtime like
|
|
117
|
-
this:
|
|
118
|
-
|
|
119
|
-
```json
|
|
120
|
-
[
|
|
121
|
-
{
|
|
122
|
-
"id": "0-2",
|
|
123
|
-
"description": "com.fabricexample",
|
|
124
|
-
"title": "Reanimated Runtime",
|
|
125
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
126
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D3",
|
|
127
|
-
"type": "node",
|
|
128
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=1&page=2",
|
|
129
|
-
"vm": "Hermes"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"id": "0-1",
|
|
133
|
-
"description": "com.fabricexample",
|
|
134
|
-
"title": "Hermes React Native",
|
|
135
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
136
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D2",
|
|
137
|
-
"type": "node",
|
|
138
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=1&page=1",
|
|
139
|
-
"vm": "Hermes"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"id": "0--1",
|
|
143
|
-
"description": "com.fabricexample",
|
|
144
|
-
"title": "React Native Experimental (Improved Chrome Reloads)",
|
|
145
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
146
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D-1",
|
|
147
|
-
"type": "node",
|
|
148
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=1&page=-1",
|
|
149
|
-
"vm": "don't use"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"id": "0--2",
|
|
153
|
-
"description": "com.fabricexample",
|
|
154
|
-
"title": "Reanimated Runtime Experimental (Improved Chrome Reloads)",
|
|
155
|
-
"faviconUrl": "https://reactjs.org/favicon.ico",
|
|
156
|
-
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D0%26page%3D-2",
|
|
157
|
-
"type": "node",
|
|
158
|
-
"webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=1&page=-2",
|
|
159
|
-
"vm": "don't use"
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Runtimes with negative IDs are 'virtual' - they are just references to the real
|
|
165
|
-
runtimes but their IDs don't change after a reload. If we were to connect to
|
|
166
|
-
the normal runtime and reload the app it would crash, as the debugger would try
|
|
167
|
-
to communicate with a non-existent runtime. These 'virtual' runtimes are made
|
|
168
|
-
and managed by metro (PR: [facebook/metro#864](https://github.com/facebook/metro/pull/864)).
|
|
169
|
-
|
|
170
|
-
## Known issues
|
|
171
|
-
|
|
172
|
-
**IFrame sandboxing**
|
|
173
|
-
|
|
174
|
-
Source maps always define a `sources` array, which contain names of files used
|
|
175
|
-
to generate the source map. For Chrome DevTools this is sufficient as it will
|
|
176
|
-
read files from disk, but the `IFrame` interface used by Flipper is sandboxed
|
|
177
|
-
and doesn't allow filesystem access. Therefore we also need to include the files
|
|
178
|
-
content in the `sourcesContent` array.
|
|
179
|
-
|
|
180
|
-
**Chrome version 105.0.5195.102 doesn't load source maps**
|
|
181
|
-
|
|
182
|
-
This version of Chrome introduced a regression into DevTools that broke source
|
|
183
|
-
maps loading for node.js apps. This issue is not caused by Reanimated in any
|
|
184
|
-
way and should be fixed by Chrome developers in later versions.
|
|
185
|
-
|
|
186
|
-
The issue was tracked here: https://bugs.chromium.org/p/chromium/issues/detail?id=1358497
|
|
187
|
-
|
|
188
|
-
**App reloads don't work**
|
|
189
|
-
|
|
190
|
-
On iOS the app will crash on every reload if a debugger is connected to the runtime.
|
|
191
|
-
On Android it will also crash but only after a few reloads.
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#include <worklets/Tools/JSISerializer.h>
|
|
2
|
-
#include <worklets/Tools/PlatformLogger.h>
|
|
3
|
-
#include <worklets/WorkletRuntime/ReanimatedRuntime.h>
|
|
4
|
-
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
5
|
-
#include <worklets/WorkletRuntime/WorkletRuntimeCollector.h>
|
|
6
|
-
#include <worklets/WorkletRuntime/WorkletRuntimeDecorator.h>
|
|
7
|
-
|
|
8
|
-
#include <jsi/decorator.h>
|
|
9
|
-
|
|
10
|
-
namespace worklets {
|
|
11
|
-
|
|
12
|
-
class AroundLock {
|
|
13
|
-
const std::shared_ptr<std::recursive_mutex> mutex_;
|
|
14
|
-
|
|
15
|
-
public:
|
|
16
|
-
explicit AroundLock(const std::shared_ptr<std::recursive_mutex> &mutex)
|
|
17
|
-
: mutex_(mutex) {}
|
|
18
|
-
|
|
19
|
-
void before() const {
|
|
20
|
-
mutex_->lock();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
void after() const {
|
|
24
|
-
mutex_->unlock();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
class LockableRuntime : public jsi::WithRuntimeDecorator<AroundLock> {
|
|
29
|
-
AroundLock aroundLock_;
|
|
30
|
-
std::shared_ptr<jsi::Runtime> runtime_;
|
|
31
|
-
|
|
32
|
-
public:
|
|
33
|
-
explicit LockableRuntime(
|
|
34
|
-
std::shared_ptr<jsi::Runtime> &runtime,
|
|
35
|
-
const std::shared_ptr<std::recursive_mutex> &runtimeMutex)
|
|
36
|
-
: jsi::WithRuntimeDecorator<AroundLock>(*runtime, aroundLock_),
|
|
37
|
-
aroundLock_(runtimeMutex),
|
|
38
|
-
runtime_(std::move(runtime)) {}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
static std::shared_ptr<jsi::Runtime> makeRuntime(
|
|
42
|
-
jsi::Runtime &runtime,
|
|
43
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
44
|
-
const std::string &name,
|
|
45
|
-
const bool supportsLocking,
|
|
46
|
-
const std::shared_ptr<std::recursive_mutex> &runtimeMutex) {
|
|
47
|
-
auto reanimatedRuntime = ReanimatedRuntime::make(runtime, jsQueue, name);
|
|
48
|
-
if (supportsLocking) {
|
|
49
|
-
return std::make_shared<LockableRuntime>(reanimatedRuntime, runtimeMutex);
|
|
50
|
-
} else {
|
|
51
|
-
return reanimatedRuntime;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
WorkletRuntime::WorkletRuntime(
|
|
56
|
-
jsi::Runtime &rnRuntime,
|
|
57
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
58
|
-
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
59
|
-
const std::string &name,
|
|
60
|
-
const bool supportsLocking,
|
|
61
|
-
const std::string &valueUnpackerCode)
|
|
62
|
-
: runtimeMutex_(std::make_shared<std::recursive_mutex>()),
|
|
63
|
-
runtime_(makeRuntime(
|
|
64
|
-
rnRuntime,
|
|
65
|
-
jsQueue,
|
|
66
|
-
name,
|
|
67
|
-
supportsLocking,
|
|
68
|
-
runtimeMutex_)),
|
|
69
|
-
#ifndef NDEBUG
|
|
70
|
-
supportsLocking_(supportsLocking),
|
|
71
|
-
#endif
|
|
72
|
-
name_(name) {
|
|
73
|
-
jsi::Runtime &rt = *runtime_;
|
|
74
|
-
WorkletRuntimeCollector::install(rt);
|
|
75
|
-
WorkletRuntimeDecorator::decorate(rt, name, jsScheduler);
|
|
76
|
-
|
|
77
|
-
auto codeBuffer = std::make_shared<const jsi::StringBuffer>(
|
|
78
|
-
"(" + valueUnpackerCode + "\n)");
|
|
79
|
-
auto valueUnpacker = rt.evaluateJavaScript(codeBuffer, "valueUnpacker")
|
|
80
|
-
.asObject(rt)
|
|
81
|
-
.asFunction(rt);
|
|
82
|
-
rt.global().setProperty(rt, "__valueUnpacker", valueUnpacker);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
jsi::Value WorkletRuntime::executeSync(
|
|
86
|
-
jsi::Runtime &rt,
|
|
87
|
-
const jsi::Value &worklet) const {
|
|
88
|
-
if (worklet.isNull() || worklet.isUndefined()) {
|
|
89
|
-
PlatformLogger::log('worklet isNull or isUndefined');
|
|
90
|
-
return jsi::Value::undefined();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
assert(
|
|
94
|
-
supportsLocking_ &&
|
|
95
|
-
("[Reanimated] Runtime \"" + name_ + "\" doesn't support locking.")
|
|
96
|
-
.c_str());
|
|
97
|
-
|
|
98
|
-
auto shareableWorklet = extractShareableOrThrow<ShareableWorklet>(
|
|
99
|
-
rt,
|
|
100
|
-
worklet,
|
|
101
|
-
"[Reanimated] Only worklets can be executed synchronously on UI runtime.");
|
|
102
|
-
|
|
103
|
-
if (!shareableWorklet) {
|
|
104
|
-
PlatformLogger::log('shareableWorklet is undefined');
|
|
105
|
-
return jsi::Value::undefined();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
109
|
-
jsi::Runtime &uiRuntime = getJSIRuntime();
|
|
110
|
-
auto result = runGuarded(shareableWorklet);
|
|
111
|
-
auto shareableResult = extractShareableOrThrow(uiRuntime, result);
|
|
112
|
-
lock.unlock();
|
|
113
|
-
|
|
114
|
-
if (shareableResult && !shareableResult->toJSValue(rt).isNull()) {
|
|
115
|
-
return shareableResult->toJSValue(rt);
|
|
116
|
-
}
|
|
117
|
-
PlatformLogger::log('shareableResult is undefined');
|
|
118
|
-
return jsi::Value::undefined();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
jsi::Value WorkletRuntime::get(
|
|
122
|
-
jsi::Runtime &rt,
|
|
123
|
-
const jsi::PropNameID &propName) {
|
|
124
|
-
auto name = propName.utf8(rt);
|
|
125
|
-
if (name == "toString") {
|
|
126
|
-
return jsi::Function::createFromHostFunction(
|
|
127
|
-
rt,
|
|
128
|
-
propName,
|
|
129
|
-
0,
|
|
130
|
-
[weakThis = weak_from_this()](
|
|
131
|
-
jsi::Runtime &rt, const jsi::Value &, const jsi::Value *, size_t)
|
|
132
|
-
-> jsi::Value {
|
|
133
|
-
auto strongThis = weakThis.lock();
|
|
134
|
-
if (!strongThis) {
|
|
135
|
-
return jsi::String::createFromUtf8(rt, "");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return jsi::String::createFromUtf8(rt, strongThis->toString());
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
if (name == "name") {
|
|
142
|
-
return jsi::String::createFromUtf8(rt, name_);
|
|
143
|
-
}
|
|
144
|
-
return jsi::Value::undefined();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
std::vector<jsi::PropNameID> WorkletRuntime::getPropertyNames(
|
|
148
|
-
jsi::Runtime &rt) {
|
|
149
|
-
std::vector<jsi::PropNameID> result;
|
|
150
|
-
result.push_back(jsi::PropNameID::forUtf8(rt, "toString"));
|
|
151
|
-
result.push_back(jsi::PropNameID::forUtf8(rt, "name"));
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
std::shared_ptr<WorkletRuntime> extractWorkletRuntime(
|
|
156
|
-
jsi::Runtime &rt,
|
|
157
|
-
const jsi::Value &value) {
|
|
158
|
-
return value.getObject(rt).getHostObject<WorkletRuntime>(rt);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
void scheduleOnRuntime(
|
|
162
|
-
jsi::Runtime &rt,
|
|
163
|
-
const jsi::Value &workletRuntimeValue,
|
|
164
|
-
const jsi::Value &shareableWorkletValue) {
|
|
165
|
-
auto workletRuntime = extractWorkletRuntime(rt, workletRuntimeValue);
|
|
166
|
-
auto shareableWorklet = extractShareableOrThrow<ShareableWorklet>(
|
|
167
|
-
rt,
|
|
168
|
-
shareableWorkletValue,
|
|
169
|
-
"[Reanimated] Function passed to `_scheduleOnRuntime` is not a shareable worklet. Please make sure that `processNestedWorklets` option in Reanimated Babel plugin is enabled.");
|
|
170
|
-
workletRuntime->runAsyncGuarded(shareableWorklet);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
} // namespace worklets
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <cxxreact/MessageQueueThread.h>
|
|
4
|
-
#include <jsi/jsi.h>
|
|
5
|
-
|
|
6
|
-
#include <worklets/SharedItems/Shareables.h>
|
|
7
|
-
#include <worklets/Tools/AsyncQueue.h>
|
|
8
|
-
#include <worklets/Tools/JSScheduler.h>
|
|
9
|
-
|
|
10
|
-
#include <memory>
|
|
11
|
-
#include <string>
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <vector>
|
|
14
|
-
|
|
15
|
-
using namespace facebook;
|
|
16
|
-
using namespace react;
|
|
17
|
-
|
|
18
|
-
namespace worklets {
|
|
19
|
-
|
|
20
|
-
class WorkletRuntime : public jsi::HostObject,
|
|
21
|
-
public std::enable_shared_from_this<WorkletRuntime> {
|
|
22
|
-
public:
|
|
23
|
-
explicit WorkletRuntime(
|
|
24
|
-
jsi::Runtime &rnRuntime,
|
|
25
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
26
|
-
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
27
|
-
const std::string &name,
|
|
28
|
-
const bool supportsLocking,
|
|
29
|
-
const std::string &valueUnpackerCode);
|
|
30
|
-
|
|
31
|
-
jsi::Runtime &getJSIRuntime() const {
|
|
32
|
-
return *runtime_;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
template <typename... Args>
|
|
36
|
-
inline jsi::Value runGuarded(
|
|
37
|
-
const std::shared_ptr<ShareableWorklet> &shareableWorklet,
|
|
38
|
-
Args &&...args) const {
|
|
39
|
-
jsi::Runtime &rt = *runtime_;
|
|
40
|
-
return runOnRuntimeGuarded(
|
|
41
|
-
rt, shareableWorklet->toJSValue(rt), std::forward<Args>(args)...);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
void runAsyncGuarded(
|
|
45
|
-
const std::shared_ptr<ShareableWorklet> &shareableWorklet) {
|
|
46
|
-
if (queue_ == nullptr) {
|
|
47
|
-
queue_ = std::make_shared<AsyncQueue>(name_);
|
|
48
|
-
}
|
|
49
|
-
queue_->push([=, weakThis = weak_from_this()] {
|
|
50
|
-
auto strongThis = weakThis.lock();
|
|
51
|
-
if (!strongThis) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
strongThis->runGuarded(shareableWorklet);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
jsi::Value executeSync(jsi::Runtime &rt, const jsi::Value &worklet) const;
|
|
60
|
-
|
|
61
|
-
std::string toString() const {
|
|
62
|
-
return "[WorkletRuntime \"" + name_ + "\"]";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override;
|
|
66
|
-
|
|
67
|
-
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
|
|
68
|
-
|
|
69
|
-
private:
|
|
70
|
-
const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
|
|
71
|
-
const std::shared_ptr<jsi::Runtime> runtime_;
|
|
72
|
-
#ifndef NDEBUG
|
|
73
|
-
const bool supportsLocking_;
|
|
74
|
-
#endif
|
|
75
|
-
const std::string name_;
|
|
76
|
-
std::shared_ptr<AsyncQueue> queue_;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// This function needs to be non-inline to avoid problems with dynamic_cast on
|
|
80
|
-
// Android
|
|
81
|
-
std::shared_ptr<WorkletRuntime> extractWorkletRuntime(
|
|
82
|
-
jsi::Runtime &rt,
|
|
83
|
-
const jsi::Value &value);
|
|
84
|
-
|
|
85
|
-
void scheduleOnRuntime(
|
|
86
|
-
jsi::Runtime &rt,
|
|
87
|
-
const jsi::Value &workletRuntimeValue,
|
|
88
|
-
const jsi::Value &shareableWorkletValue);
|
|
89
|
-
|
|
90
|
-
} // namespace worklets
|