@react-native-ohos/react-native-reanimated 3.18.1 → 3.18.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/README.md CHANGED
@@ -2,9 +2,9 @@
2
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
3
 
4
4
  ## Documentation
5
- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-reanimated.md)
5
+ [中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-reanimated.md)
6
6
 
7
- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-reanimated.md)
7
+ [English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-reanimated.md)
8
8
 
9
9
  ## License
10
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.1';
4
+ export const HAR_VERSION = '3.18.2';
5
5
  export const BUILD_MODE_NAME = 'debug';
6
6
  export const DEBUG = true;
7
7
  export const TARGET_NAME = 'default';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  name: '@react-native-ohos/react-native-reanimated',
3
- version: '3.18.1',
3
+ version: '3.18.2',
4
4
  description: "",
5
5
  type: 'module',
6
6
  main: 'index.ets',
@@ -1,5 +1,6 @@
1
1
  #ifdef RCT_NEW_ARCH_ENABLED
2
2
 
3
+ #include <glog/logging.h>
3
4
  #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
4
5
  #include <reanimated/Fabric/ReanimatedMountHook.h>
5
6
 
@@ -44,35 +45,38 @@ void ReanimatedMountHook::shadowTreeDidMount(
44
45
  }
45
46
  }
46
47
 
47
- const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
48
- shadowTreeRegistry.visit(
49
- rootShadowNode->getSurfaceId(), [&](ShadowTree const &shadowTree) {
48
+ try {
49
+ const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
50
+ shadowTreeRegistry.visit(
51
+ rootShadowNode->getSurfaceId(), [=](ShadowTree const &shadowTree) {
50
52
  shadowTree.commit(
51
- [&](RootShadowNode const &oldRootShadowNode)
53
+ [=](RootShadowNode const &oldRootShadowNode)
52
54
  -> RootShadowNode::Unshared {
53
55
  PropsMap propsMap;
54
56
 
55
57
  RootShadowNode::Unshared rootNode =
56
58
  std::static_pointer_cast<RootShadowNode>(
57
59
  oldRootShadowNode.ShadowNode::clone({}));
58
- {
60
+
61
+ if (rootNode) {
59
62
  auto lock = propsRegistry_->createLock();
60
63
 
61
- propsRegistry_->for_each([&](const ShadowNodeFamily &family,
62
- const folly::dynamic &props) {
63
- propsMap[&family].emplace_back(props);
64
- });
64
+ if (!propsRegistry_->isEmpty()) {
65
+ propsRegistry_->for_each([&](const ShadowNodeFamily &family,
66
+ const folly::dynamic &props) {
67
+ propsMap[&family].emplace_back(props);
68
+ });
65
69
 
66
- rootNode =
67
- cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
70
+ rootNode = cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
71
+ }
68
72
  }
69
73
 
70
- // Mark the commit as Reanimated commit so that we can
71
- // distinguish it in ReanimatedCommitHook.
72
- auto reaShadowNode =
73
- std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
74
- rootNode);
75
- reaShadowNode->setReanimatedCommitTrait();
74
+ if (rootNode) {
75
+ auto reaShadowNode =
76
+ std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
77
+ rootNode);
78
+ reaShadowNode->setReanimatedCommitTrait();
79
+ }
76
80
 
77
81
  return rootNode;
78
82
  },
@@ -80,6 +84,11 @@ void ReanimatedMountHook::shadowTreeDidMount(
80
84
  false,
81
85
  /* .mountSynchronously = */ true});
82
86
  });
87
+ } catch (const std::exception &e) {
88
+ LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount error: " << e.what();
89
+ } catch (...) {
90
+ LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount unknown error";
91
+ }
83
92
  }
84
93
 
85
94
  } // namespace reanimated
@@ -64,6 +64,8 @@ class ReanimatedModuleProxy
64
64
 
65
65
  ~ReanimatedModuleProxy();
66
66
 
67
+ void invalidate();
68
+
67
69
  jsi::Value registerEventHandler(
68
70
  jsi::Runtime &rt,
69
71
  const jsi::Value &worklet,
@@ -1,4 +1,5 @@
1
1
  #include <worklets/Tools/JSISerializer.h>
2
+ #include <worklets/Tools/PlatformLogger.h>
2
3
  #include <worklets/WorkletRuntime/ReanimatedRuntime.h>
3
4
  #include <worklets/WorkletRuntime/WorkletRuntime.h>
4
5
  #include <worklets/WorkletRuntime/WorkletRuntimeCollector.h>
@@ -84,20 +85,37 @@ WorkletRuntime::WorkletRuntime(
84
85
  jsi::Value WorkletRuntime::executeSync(
85
86
  jsi::Runtime &rt,
86
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
+
87
93
  assert(
88
94
  supportsLocking_ &&
89
95
  ("[Reanimated] Runtime \"" + name_ + "\" doesn't support locking.")
90
96
  .c_str());
97
+
91
98
  auto shareableWorklet = extractShareableOrThrow<ShareableWorklet>(
92
99
  rt,
93
100
  worklet,
94
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
+
95
108
  auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
96
109
  jsi::Runtime &uiRuntime = getJSIRuntime();
97
110
  auto result = runGuarded(shareableWorklet);
98
111
  auto shareableResult = extractShareableOrThrow(uiRuntime, result);
99
112
  lock.unlock();
100
- return shareableResult->toJSValue(rt);
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();
101
119
  }
102
120
 
103
121
  jsi::Value WorkletRuntime::get(
@@ -137,8 +137,15 @@ void WorkletRuntimeDecorator::decorate(
137
137
  jsi::Runtime &rt,
138
138
  const jsi::Value &hostFunValue,
139
139
  const jsi::Value &argsValue) {
140
+ if (hostFunValue.isUndefined() || !hostFunValue.isObject()) {
141
+ return;
142
+ }
143
+ auto hostFunObject = hostFunValue.asObject(rt);
144
+ if (!hostFunObject.isFunction(rt) || !hostFunObject.asFunction(rt).isHostFunction(rt)) {
145
+ return;
146
+ }
140
147
  auto hostFun =
141
- hostFunValue.asObject(rt).asFunction(rt).getHostFunction(rt);
148
+ hostFunObject.asFunction(rt).getHostFunction(rt);
142
149
 
143
150
  auto shareableArgs = argsValue.isUndefined()
144
151
  ? nullptr
@@ -50,6 +50,9 @@ ReanimatedModule::~ReanimatedModule()
50
50
  if (keyboardEventDataUpdater_) {
51
51
  keyboardEventDataUpdater_ = nullptr;
52
52
  }
53
+ if (auto nativeReanimatedModule = weakNativeReanimatedModule_.lock()) {
54
+ nativeReanimatedModule->invalidate();
55
+ }
53
56
  }
54
57
 
55
58
  void ReanimatedModule::installTurboModule(facebook::jsi::Runtime &rt)
@@ -228,6 +228,10 @@ void ReanimatedModuleProxy::init(
228
228
  }
229
229
 
230
230
  ReanimatedModuleProxy::~ReanimatedModuleProxy() {
231
+ invalidate();
232
+ }
233
+
234
+ void ReanimatedModuleProxy::invalidate() {
231
235
  // event handler registry and frame callbacks store some JSI values from UI
232
236
  // runtime, so they have to go away before we tear down the runtime
233
237
  eventHandlerRegistry_.reset();
@@ -38,4 +38,11 @@ export class ReanimatedModule extends UITurboModule {
38
38
  windowInstance.off('keyboardHeightChange', (v) => {
39
39
  })
40
40
  }
41
+
42
+ public setGestureHandlerState(handlerTag: Tag, newState: number) {
43
+ const module = this.ctx.rnInstance.getTurboModule("RNGestureHandlerModule") as any;
44
+ if (module && module.setGestureHandlerState) {
45
+ module.setGestureHandlerState(handlerTag, newState);
46
+ }
47
+ }
41
48
  }
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "alias": "react-native-reanimated",
5
5
  "redirectInternalImports": true
6
6
  },
7
- "version": "3.18.1",
7
+ "version": "3.18.2",
8
8
  "description": "",
9
9
  "main": "lib/index.js",
10
10
  "scripts": {
@@ -1,31 +0,0 @@
1
- {
2
- "meta": {
3
- "stableOrder": true,
4
- "enableUnifiedLockfile": false
5
- },
6
- "lockfileVersion": 3,
7
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
8
- "specifiers": {
9
- "@ohos/materialprogressbar@2.1.3-rc.0": "@ohos/materialprogressbar@2.1.3-rc.0",
10
- "@ppd/ffrt@1.1.5": "@ppd/ffrt@1.1.5",
11
- "@rnoh/react-native-openharmony@../../../../tester/25P4/harmony/react_native_openharmony-6.0.0.202.har": "@rnoh/react-native-openharmony@../../../../tester/25P4/harmony/react_native_openharmony-6.0.0.202.har"
12
- },
13
- "packages": {
14
- "@ppd/ffrt@1.1.5": {
15
- "name": "@ppd/ffrt",
16
- "version": "1.1.5",
17
- "integrity": "sha512-MbXdRqeNHQQv4ALTGdosvOCQI+xH8nt0+E2/aFLS4UuGJ5541MAeenRCDOrgIG05k7SnSJ4WngsCfjj3FbTCQg==",
18
- "resolved": "https://ohpm.openharmony.cn/ohpm/@ppd/ffrt/-/ffrt-1.1.5.har",
19
- "registryType": "ohpm"
20
- },
21
- "@rnoh/react-native-openharmony@../../../../tester/25P4/harmony/react_native_openharmony-6.0.0.202.har": {
22
- "name": "@rnoh/react-native-openharmony",
23
- "version": "0.77.56",
24
- "resolved": "../../../../tester/25P4/harmony/react_native_openharmony-6.0.0.202.har",
25
- "registryType": "local",
26
- "dependencies": {
27
- "@ppd/ffrt": "1.1.5"
28
- }
29
- }
30
- }
31
- }