@react-native-ohos/react-native-reanimated 3.18.2 → 3.18.3-beta.2
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/LICENSE +21 -21
- package/README.OpenSource +10 -10
- package/README.md +10 -10
- package/harmony/reanimated/BuildProfile.ets +1 -1
- package/harmony/reanimated/build-profile.json5 +11 -11
- package/harmony/reanimated/oh-package-lock.json5 +29 -0
- package/harmony/reanimated/oh-package.json5 +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +73 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -96
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -254
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -173
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -189
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +4 -6
- package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
- package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
- package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +22 -4
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +88 -13
- 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 +51 -50
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016 Software Mansion <swmansion.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Software Mansion <swmansion.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.OpenSource
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"Name": "react-native-reanimated",
|
|
4
|
-
"License": "MIT License",
|
|
5
|
-
"License File": "LICENSE",
|
|
6
|
-
"Version Number": "3.18.0",
|
|
7
|
-
"Owner" : "xiafeng@huawei.com",
|
|
8
|
-
"Upstream URL": "https://github.com/software-mansion/react-native-reanimated",
|
|
9
|
-
"Description": "React Native's Animated library reimplemented"
|
|
10
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-reanimated",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "LICENSE",
|
|
6
|
+
"Version Number": "3.18.0",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/software-mansion/react-native-reanimated",
|
|
9
|
+
"Description": "React Native's Animated library reimplemented"
|
|
10
|
+
}
|
|
11
11
|
]
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# @react-native-ohos/react-native-reanimated
|
|
2
|
-
This project is based on [react-native-reanimated@v3.18.0](https://github.com/software-mansion/react-native-reanimated/tree/3.18.0)
|
|
3
|
-
|
|
4
|
-
## Documentation
|
|
5
|
-
[中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-reanimated.md)
|
|
6
|
-
|
|
7
|
-
[English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-reanimated.md)
|
|
8
|
-
|
|
9
|
-
## License
|
|
10
|
-
This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-harmony-reanimated/blob/sig/LICENSE).
|
|
1
|
+
# @react-native-ohos/react-native-reanimated
|
|
2
|
+
This project is based on [react-native-reanimated@v3.18.0](https://github.com/software-mansion/react-native-reanimated/tree/3.18.0)
|
|
3
|
+
|
|
4
|
+
## Documentation
|
|
5
|
+
[中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-reanimated.md)
|
|
6
|
+
|
|
7
|
+
[English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-reanimated.md)
|
|
8
|
+
|
|
9
|
+
## License
|
|
10
|
+
This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-harmony-reanimated/blob/sig/LICENSE).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
3
|
*/
|
|
4
|
-
export const HAR_VERSION = '3.18.2';
|
|
4
|
+
export const HAR_VERSION = '3.18.3-beta.2';
|
|
5
5
|
export const BUILD_MODE_NAME = 'debug';
|
|
6
6
|
export const DEBUG = true;
|
|
7
7
|
export const TARGET_NAME = 'default';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiType": 'stageMode',
|
|
3
|
-
"targets": [
|
|
4
|
-
{
|
|
5
|
-
"name": "default",
|
|
6
|
-
"runtimeOS": "HarmonyOS"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "ohosTest",
|
|
10
|
-
}
|
|
11
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"apiType": 'stageMode',
|
|
3
|
+
"targets": [
|
|
4
|
+
{
|
|
5
|
+
"name": "default",
|
|
6
|
+
"runtimeOS": "HarmonyOS"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "ohosTest",
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
12
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"stableOrder": true
|
|
4
|
+
},
|
|
5
|
+
"lockfileVersion": 3,
|
|
6
|
+
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
7
|
+
"specifiers": {
|
|
8
|
+
"@ppd/ffrt@1.1.5": "@ppd/ffrt@1.1.5",
|
|
9
|
+
"@rnoh/react-native-openharmony@../../example/node_modules/react-native-harmony/react_native_openharmony.har": "@rnoh/react-native-openharmony@../../example/node_modules/react-native-harmony/react_native_openharmony.har"
|
|
10
|
+
},
|
|
11
|
+
"packages": {
|
|
12
|
+
"@ppd/ffrt@1.1.5": {
|
|
13
|
+
"name": "@ppd/ffrt",
|
|
14
|
+
"version": "1.1.5",
|
|
15
|
+
"integrity": "sha512-MbXdRqeNHQQv4ALTGdosvOCQI+xH8nt0+E2/aFLS4UuGJ5541MAeenRCDOrgIG05k7SnSJ4WngsCfjj3FbTCQg==",
|
|
16
|
+
"resolved": "https://ohpm.openharmony.cn/ohpm/@ppd/ffrt/-/ffrt-1.1.5.har",
|
|
17
|
+
"registryType": "ohpm"
|
|
18
|
+
},
|
|
19
|
+
"@rnoh/react-native-openharmony@../../example/node_modules/react-native-harmony/react_native_openharmony.har": {
|
|
20
|
+
"name": "@rnoh/react-native-openharmony",
|
|
21
|
+
"version": "0.77.71",
|
|
22
|
+
"resolved": "../../example/node_modules/react-native-harmony/react_native_openharmony.har",
|
|
23
|
+
"registryType": "local",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@ppd/ffrt": "1.1.5"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
name: '@react-native-ohos/react-native-reanimated',
|
|
3
|
-
version: '3.18.2',
|
|
4
|
-
description: "",
|
|
5
|
-
type: 'module',
|
|
6
|
-
main: 'index.ets',
|
|
7
|
-
author: '',
|
|
8
|
-
license: '',
|
|
9
|
-
dependencies: {
|
|
10
|
-
"@rnoh/react-native-openharmony": "file:../react_native_openharmony.har",
|
|
11
|
-
},
|
|
1
|
+
{
|
|
2
|
+
name: '@react-native-ohos/react-native-reanimated',
|
|
3
|
+
version: '3.18.3-beta.2',
|
|
4
|
+
description: "",
|
|
5
|
+
type: 'module',
|
|
6
|
+
main: 'index.ets',
|
|
7
|
+
author: '',
|
|
8
|
+
license: '',
|
|
9
|
+
dependencies: {
|
|
10
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony.har",
|
|
11
|
+
},
|
|
12
12
|
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
#include <reanimated/AnimatedSensor/AnimatedSensorModule.h>
|
|
2
|
-
|
|
3
|
-
#include <utility>
|
|
4
|
-
|
|
5
|
-
namespace reanimated {
|
|
6
|
-
|
|
7
|
-
AnimatedSensorModule::AnimatedSensorModule(
|
|
8
|
-
const PlatformDepMethodsHolder &platformDepMethodsHolder)
|
|
9
|
-
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
|
|
10
|
-
platformUnregisterSensorFunction_(
|
|
11
|
-
platformDepMethodsHolder.unregisterSensor) {}
|
|
12
|
-
|
|
13
|
-
AnimatedSensorModule::~AnimatedSensorModule() {
|
|
14
|
-
assert(sensorsIds_.empty());
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
jsi::Value AnimatedSensorModule::registerSensor(
|
|
18
|
-
jsi::Runtime &rt,
|
|
19
|
-
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
20
|
-
const jsi::Value &sensorTypeValue,
|
|
21
|
-
const jsi::Value &interval,
|
|
22
|
-
const jsi::Value &iosReferenceFrame,
|
|
23
|
-
const jsi::Value &sensorDataHandler) {
|
|
24
|
-
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
|
|
25
|
-
|
|
26
|
-
auto shareableHandler = extractShareableOrThrow<ShareableWorklet>(
|
|
27
|
-
rt,
|
|
28
|
-
sensorDataHandler,
|
|
29
|
-
"[Reanimated] Sensor event handler must be a worklet.");
|
|
30
|
-
|
|
31
|
-
int sensorId = platformRegisterSensorFunction_(
|
|
32
|
-
sensorType,
|
|
33
|
-
interval.asNumber(),
|
|
34
|
-
iosReferenceFrame.asNumber(),
|
|
35
|
-
[sensorType,
|
|
36
|
-
shareableHandler,
|
|
37
|
-
weakUiWorkletRuntime = std::weak_ptr<WorkletRuntime>(uiWorkletRuntime)](
|
|
38
|
-
double newValues[], int orientationDegrees) {
|
|
39
|
-
auto uiWorkletRuntime = weakUiWorkletRuntime.lock();
|
|
40
|
-
if (uiWorkletRuntime == nullptr) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
jsi::Runtime &uiRuntime = uiWorkletRuntime->getJSIRuntime();
|
|
45
|
-
jsi::Object value(uiRuntime);
|
|
46
|
-
if (sensorType == SensorType::ROTATION_VECTOR) {
|
|
47
|
-
// TODO: timestamp should be provided by the platform implementation
|
|
48
|
-
// such that the native side has a chance of providing a true event
|
|
49
|
-
// timestamp
|
|
50
|
-
value.setProperty(uiRuntime, "qx", newValues[0]);
|
|
51
|
-
value.setProperty(uiRuntime, "qy", newValues[1]);
|
|
52
|
-
value.setProperty(uiRuntime, "qz", newValues[2]);
|
|
53
|
-
value.setProperty(uiRuntime, "qw", newValues[3]);
|
|
54
|
-
value.setProperty(uiRuntime, "yaw", newValues[4]);
|
|
55
|
-
value.setProperty(uiRuntime, "pitch", newValues[5]);
|
|
56
|
-
value.setProperty(uiRuntime, "roll", newValues[6]);
|
|
57
|
-
} else {
|
|
58
|
-
value.setProperty(uiRuntime, "x", newValues[0]);
|
|
59
|
-
value.setProperty(uiRuntime, "y", newValues[1]);
|
|
60
|
-
value.setProperty(uiRuntime, "z", newValues[2]);
|
|
61
|
-
}
|
|
62
|
-
value.setProperty(
|
|
63
|
-
uiRuntime, "interfaceOrientation", orientationDegrees);
|
|
64
|
-
|
|
65
|
-
uiWorkletRuntime->runGuarded(shareableHandler, value);
|
|
66
|
-
});
|
|
67
|
-
if (sensorId != -1) {
|
|
68
|
-
sensorsIds_.insert(sensorId);
|
|
69
|
-
}
|
|
70
|
-
return jsi::Value(sensorId);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) {
|
|
74
|
-
// It is called during sensor hook unmounting
|
|
75
|
-
sensorsIds_.erase(sensorId.getNumber());
|
|
76
|
-
platformUnregisterSensorFunction_(sensorId.asNumber());
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void AnimatedSensorModule::unregisterAllSensors() {
|
|
80
|
-
for (auto sensorId : sensorsIds_) {
|
|
81
|
-
platformUnregisterSensorFunction_(sensorId);
|
|
82
|
-
}
|
|
83
|
-
sensorsIds_.clear();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
} // namespace reanimated
|
|
1
|
+
#include <reanimated/AnimatedSensor/AnimatedSensorModule.h>
|
|
2
|
+
|
|
3
|
+
#include <utility>
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
|
|
7
|
+
AnimatedSensorModule::AnimatedSensorModule(
|
|
8
|
+
const PlatformDepMethodsHolder &platformDepMethodsHolder)
|
|
9
|
+
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
|
|
10
|
+
platformUnregisterSensorFunction_(
|
|
11
|
+
platformDepMethodsHolder.unregisterSensor) {}
|
|
12
|
+
|
|
13
|
+
AnimatedSensorModule::~AnimatedSensorModule() {
|
|
14
|
+
assert(sensorsIds_.empty());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
jsi::Value AnimatedSensorModule::registerSensor(
|
|
18
|
+
jsi::Runtime &rt,
|
|
19
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
20
|
+
const jsi::Value &sensorTypeValue,
|
|
21
|
+
const jsi::Value &interval,
|
|
22
|
+
const jsi::Value &iosReferenceFrame,
|
|
23
|
+
const jsi::Value &sensorDataHandler) {
|
|
24
|
+
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
|
|
25
|
+
|
|
26
|
+
auto shareableHandler = extractShareableOrThrow<ShareableWorklet>(
|
|
27
|
+
rt,
|
|
28
|
+
sensorDataHandler,
|
|
29
|
+
"[Reanimated] Sensor event handler must be a worklet.");
|
|
30
|
+
|
|
31
|
+
int sensorId = platformRegisterSensorFunction_(
|
|
32
|
+
sensorType,
|
|
33
|
+
interval.asNumber(),
|
|
34
|
+
iosReferenceFrame.asNumber(),
|
|
35
|
+
[sensorType,
|
|
36
|
+
shareableHandler,
|
|
37
|
+
weakUiWorkletRuntime = std::weak_ptr<WorkletRuntime>(uiWorkletRuntime)](
|
|
38
|
+
double newValues[], int orientationDegrees) {
|
|
39
|
+
auto uiWorkletRuntime = weakUiWorkletRuntime.lock();
|
|
40
|
+
if (uiWorkletRuntime == nullptr) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
jsi::Runtime &uiRuntime = uiWorkletRuntime->getJSIRuntime();
|
|
45
|
+
jsi::Object value(uiRuntime);
|
|
46
|
+
if (sensorType == SensorType::ROTATION_VECTOR) {
|
|
47
|
+
// TODO: timestamp should be provided by the platform implementation
|
|
48
|
+
// such that the native side has a chance of providing a true event
|
|
49
|
+
// timestamp
|
|
50
|
+
value.setProperty(uiRuntime, "qx", newValues[0]);
|
|
51
|
+
value.setProperty(uiRuntime, "qy", newValues[1]);
|
|
52
|
+
value.setProperty(uiRuntime, "qz", newValues[2]);
|
|
53
|
+
value.setProperty(uiRuntime, "qw", newValues[3]);
|
|
54
|
+
value.setProperty(uiRuntime, "yaw", newValues[4]);
|
|
55
|
+
value.setProperty(uiRuntime, "pitch", newValues[5]);
|
|
56
|
+
value.setProperty(uiRuntime, "roll", newValues[6]);
|
|
57
|
+
} else {
|
|
58
|
+
value.setProperty(uiRuntime, "x", newValues[0]);
|
|
59
|
+
value.setProperty(uiRuntime, "y", newValues[1]);
|
|
60
|
+
value.setProperty(uiRuntime, "z", newValues[2]);
|
|
61
|
+
}
|
|
62
|
+
value.setProperty(
|
|
63
|
+
uiRuntime, "interfaceOrientation", orientationDegrees);
|
|
64
|
+
|
|
65
|
+
uiWorkletRuntime->runGuarded(shareableHandler, value);
|
|
66
|
+
});
|
|
67
|
+
if (sensorId != -1) {
|
|
68
|
+
sensorsIds_.insert(sensorId);
|
|
69
|
+
}
|
|
70
|
+
return jsi::Value(sensorId);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) {
|
|
74
|
+
// It is called during sensor hook unmounting
|
|
75
|
+
sensorsIds_.erase(sensorId.getNumber());
|
|
76
|
+
platformUnregisterSensorFunction_(sensorId.asNumber());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void AnimatedSensorModule::unregisterAllSensors() {
|
|
80
|
+
for (auto sensorId : sensorsIds_) {
|
|
81
|
+
platformUnregisterSensorFunction_(sensorId);
|
|
82
|
+
}
|
|
83
|
+
sensorsIds_.clear();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} // namespace reanimated
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <reanimated/Tools/PlatformDepMethodsHolder.h>
|
|
4
|
-
|
|
5
|
-
#include <worklets/SharedItems/Shareables.h>
|
|
6
|
-
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
7
|
-
|
|
8
|
-
#include <jsi/jsi.h>
|
|
9
|
-
|
|
10
|
-
#include <memory>
|
|
11
|
-
#include <unordered_set>
|
|
12
|
-
|
|
13
|
-
namespace reanimated {
|
|
14
|
-
|
|
15
|
-
using namespace facebook;
|
|
16
|
-
using namespace worklets;
|
|
17
|
-
|
|
18
|
-
enum SensorType {
|
|
19
|
-
ACCELEROMETER = 1,
|
|
20
|
-
GYROSCOPE = 2,
|
|
21
|
-
GRAVITY = 3,
|
|
22
|
-
MAGNETIC_FIELD = 4,
|
|
23
|
-
ROTATION_VECTOR = 5,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
class AnimatedSensorModule {
|
|
27
|
-
std::unordered_set<int> sensorsIds_;
|
|
28
|
-
RegisterSensorFunction platformRegisterSensorFunction_;
|
|
29
|
-
UnregisterSensorFunction platformUnregisterSensorFunction_;
|
|
30
|
-
|
|
31
|
-
public:
|
|
32
|
-
AnimatedSensorModule(
|
|
33
|
-
const PlatformDepMethodsHolder &platformDepMethodsHolder);
|
|
34
|
-
~AnimatedSensorModule();
|
|
35
|
-
|
|
36
|
-
jsi::Value registerSensor(
|
|
37
|
-
jsi::Runtime &rt,
|
|
38
|
-
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
39
|
-
const jsi::Value &sensorType,
|
|
40
|
-
const jsi::Value &interval,
|
|
41
|
-
const jsi::Value &iosReferenceFrame,
|
|
42
|
-
const jsi::Value &sensorDataContainer);
|
|
43
|
-
void unregisterSensor(const jsi::Value &sensorId);
|
|
44
|
-
void unregisterAllSensors();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
} // namespace reanimated
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/Tools/PlatformDepMethodsHolder.h>
|
|
4
|
+
|
|
5
|
+
#include <worklets/SharedItems/Shareables.h>
|
|
6
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
7
|
+
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
#include <memory>
|
|
11
|
+
#include <unordered_set>
|
|
12
|
+
|
|
13
|
+
namespace reanimated {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
using namespace worklets;
|
|
17
|
+
|
|
18
|
+
enum SensorType {
|
|
19
|
+
ACCELEROMETER = 1,
|
|
20
|
+
GYROSCOPE = 2,
|
|
21
|
+
GRAVITY = 3,
|
|
22
|
+
MAGNETIC_FIELD = 4,
|
|
23
|
+
ROTATION_VECTOR = 5,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class AnimatedSensorModule {
|
|
27
|
+
std::unordered_set<int> sensorsIds_;
|
|
28
|
+
RegisterSensorFunction platformRegisterSensorFunction_;
|
|
29
|
+
UnregisterSensorFunction platformUnregisterSensorFunction_;
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
AnimatedSensorModule(
|
|
33
|
+
const PlatformDepMethodsHolder &platformDepMethodsHolder);
|
|
34
|
+
~AnimatedSensorModule();
|
|
35
|
+
|
|
36
|
+
jsi::Value registerSensor(
|
|
37
|
+
jsi::Runtime &rt,
|
|
38
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
39
|
+
const jsi::Value &sensorType,
|
|
40
|
+
const jsi::Value &interval,
|
|
41
|
+
const jsi::Value &iosReferenceFrame,
|
|
42
|
+
const jsi::Value &sensorDataContainer);
|
|
43
|
+
void unregisterSensor(const jsi::Value &sensorId);
|
|
44
|
+
void unregisterAllSensors();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace reanimated
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
-
|
|
3
|
-
#include <reanimated/Fabric/PropsRegistry.h>
|
|
4
|
-
|
|
5
|
-
namespace reanimated {
|
|
6
|
-
|
|
7
|
-
std::lock_guard<std::mutex> PropsRegistry::createLock() const {
|
|
8
|
-
return std::lock_guard<std::mutex>(mutex_);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
void PropsRegistry::update(
|
|
12
|
-
const ShadowNode::Shared &shadowNode,
|
|
13
|
-
folly::dynamic &&props) {
|
|
14
|
-
const auto tag = shadowNode->getTag();
|
|
15
|
-
const auto it = map_.find(tag);
|
|
16
|
-
if (it == map_.cend()) {
|
|
17
|
-
// we need to store ShadowNode because `ShadowNode::getFamily`
|
|
18
|
-
// returns `ShadowNodeFamily const &` which is non-owning
|
|
19
|
-
map_[tag] = std::make_pair(shadowNode, props);
|
|
20
|
-
} else {
|
|
21
|
-
// no need to update `.first` because ShadowNode's family never changes
|
|
22
|
-
// merge new props with old props
|
|
23
|
-
it->second.second.update(props);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
void PropsRegistry::for_each(std::function<void(
|
|
28
|
-
const ShadowNodeFamily &family,
|
|
29
|
-
const folly::dynamic &props)> callback) const {
|
|
30
|
-
for (const auto &[_, value] : map_) {
|
|
31
|
-
callback(value.first->getFamily(), value.second);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
void PropsRegistry::markNodeAsRemovable(const ShadowNode::Shared &shadowNode) {
|
|
36
|
-
removableShadowNodes_[shadowNode->getTag()] = shadowNode;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
void PropsRegistry::unmarkNodeAsRemovable(Tag viewTag) {
|
|
40
|
-
removableShadowNodes_.erase(viewTag);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
void PropsRegistry::handleNodeRemovals(const RootShadowNode &rootShadowNode) {
|
|
44
|
-
for (auto it = removableShadowNodes_.begin();
|
|
45
|
-
it != removableShadowNodes_.end();) {
|
|
46
|
-
const auto &shadowNode = it->second;
|
|
47
|
-
const auto &family = shadowNode->getFamily();
|
|
48
|
-
const auto &ancestors = family.getAncestors(rootShadowNode);
|
|
49
|
-
|
|
50
|
-
// Skip if the node hasn't been removed
|
|
51
|
-
if (!ancestors.empty()) {
|
|
52
|
-
++it;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const auto tag = shadowNode->getTag();
|
|
57
|
-
map_.erase(tag);
|
|
58
|
-
it = removableShadowNodes_.erase(it);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void PropsRegistry::remove(const Tag tag) {
|
|
63
|
-
map_.erase(tag);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
} // namespace reanimated
|
|
67
|
-
|
|
68
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#include <reanimated/Fabric/PropsRegistry.h>
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
|
|
7
|
+
std::lock_guard<std::mutex> PropsRegistry::createLock() const {
|
|
8
|
+
return std::lock_guard<std::mutex>(mutex_);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void PropsRegistry::update(
|
|
12
|
+
const ShadowNode::Shared &shadowNode,
|
|
13
|
+
folly::dynamic &&props) {
|
|
14
|
+
const auto tag = shadowNode->getTag();
|
|
15
|
+
const auto it = map_.find(tag);
|
|
16
|
+
if (it == map_.cend()) {
|
|
17
|
+
// we need to store ShadowNode because `ShadowNode::getFamily`
|
|
18
|
+
// returns `ShadowNodeFamily const &` which is non-owning
|
|
19
|
+
map_[tag] = std::make_pair(shadowNode, props);
|
|
20
|
+
} else {
|
|
21
|
+
// no need to update `.first` because ShadowNode's family never changes
|
|
22
|
+
// merge new props with old props
|
|
23
|
+
it->second.second.update(props);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void PropsRegistry::for_each(std::function<void(
|
|
28
|
+
const ShadowNodeFamily &family,
|
|
29
|
+
const folly::dynamic &props)> callback) const {
|
|
30
|
+
for (const auto &[_, value] : map_) {
|
|
31
|
+
callback(value.first->getFamily(), value.second);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void PropsRegistry::markNodeAsRemovable(const ShadowNode::Shared &shadowNode) {
|
|
36
|
+
removableShadowNodes_[shadowNode->getTag()] = shadowNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void PropsRegistry::unmarkNodeAsRemovable(Tag viewTag) {
|
|
40
|
+
removableShadowNodes_.erase(viewTag);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void PropsRegistry::handleNodeRemovals(const RootShadowNode &rootShadowNode) {
|
|
44
|
+
for (auto it = removableShadowNodes_.begin();
|
|
45
|
+
it != removableShadowNodes_.end();) {
|
|
46
|
+
const auto &shadowNode = it->second;
|
|
47
|
+
const auto &family = shadowNode->getFamily();
|
|
48
|
+
const auto &ancestors = family.getAncestors(rootShadowNode);
|
|
49
|
+
|
|
50
|
+
// Skip if the node hasn't been removed
|
|
51
|
+
if (!ancestors.empty()) {
|
|
52
|
+
++it;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const auto tag = shadowNode->getTag();
|
|
57
|
+
map_.erase(tag);
|
|
58
|
+
it = removableShadowNodes_.erase(it);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void PropsRegistry::remove(const Tag tag) {
|
|
63
|
+
map_.erase(tag);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
} // namespace reanimated
|
|
67
|
+
|
|
68
|
+
#endif // RCT_NEW_ARCH_ENABLED
|