@react-native-ohos/react-native-bindingx 1.0.4-rc.1 → 1.0.4-rc.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.OpenSource CHANGED
@@ -1,11 +1,11 @@
1
- [
2
- {
3
- "Name": "react-native-bindingx",
4
- "License": "Apache License",
5
- "License File": "LICENSE.md",
6
- "Version Number": "1.0.3",
7
- "Owner" : "xiafeng@huawei.com",
8
- "Upstream URL": "https://github.com/alibaba/bindingx",
9
- "Description": "Bind actions to effects"
10
- }
1
+ [
2
+ {
3
+ "Name": "react-native-bindingx",
4
+ "License": "Apache License",
5
+ "License File": "LICENSE.md",
6
+ "Version Number": "1.0.3",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/alibaba/bindingx",
9
+ "Description": "Bind actions to effects"
10
+ }
11
11
  ]
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # @react-native-oh-tpl/react-native-bindingx
1
+ # @react-native-ohos/react-native-bindingx
2
2
 
3
- This project is based on [alibaba/bindingx](https://github.com/alibaba/bindingx)
3
+ This project is based on [alibaba/bindingx@1.0.3](https://github.com/alibaba/bindingx/tree/1.0.3)
4
4
 
5
5
  ## Documentation
6
6
 
@@ -22,4 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import { ReactBindingXPackage } from './src/main/ets/ReactBindingXPackage'
25
26
  export * from "./ts"
27
+ export default ReactBindingXPackage
@@ -5,7 +5,7 @@
5
5
  name: '@react-native-ohos/react-native-bindingx',
6
6
  description: '',
7
7
  main: 'index.ets',
8
- version: '1.0.4-rc.1',
8
+ version: '1.0.4-rc.2',
9
9
  dependencies: {
10
10
  "@rnoh/react-native-openharmony": 'file:../react_native_openharmony',
11
11
  },
@@ -24,15 +24,16 @@
24
24
 
25
25
  #include "ExpressHandleEval.h"
26
26
 
27
+ #define BINDINGX_EVAL_TWO 2
27
28
  namespace rnoh {
28
29
 
29
30
  string ops = "+-*/()";
30
- bool ValueError = false;
31
- bool ExpressionError = false;
31
+ bool ValueError = false;
32
+ bool ExpressionError = false;
32
33
  ExpressHandleEval *m_ExpressHandleEval;
33
34
 
34
-
35
- double toDouble(string str) {
35
+ double toDouble(string str)
36
+ {
36
37
  double target;
37
38
  stringstream ss;
38
39
  ss << str;
@@ -41,27 +42,28 @@ namespace rnoh {
41
42
  }
42
43
 
43
44
 
44
- void ExpressHandleEval::init_mapping(map<string, int> &mapping) {
45
+ void ExpressHandleEval::init_mapping(map<string, int> &mapping)
46
+ {
45
47
  mapping["+"] = 0;
46
48
  mapping["-"] = 0;
47
49
  mapping["*"] = 1;
48
50
  mapping["/"] = 1;
49
- mapping["("] = 2;
50
- mapping[")"] = 2;
51
+ mapping["("] = BINDINGX_EVAL_TWO;
52
+ mapping[")"] = BINDINGX_EVAL_TWO;
51
53
  }
52
54
 
53
55
 
54
- vector<string> toPostfix(string formula) {
56
+ vector<string> toPostfix(string formula)
57
+ {
55
58
  vector<string> result;
56
59
  vector<string> op_stack;
57
- string cur_num, cur_op;
60
+ string cur_num;
61
+ string cur_op;
58
62
 
59
63
  for (int i = 0; i < formula.size(); ++i) {
60
- if (ops.find(formula[i]) == ops.npos)
64
+ if (ops.find(formula[i]) == ops.npos) {
61
65
  cur_num += formula[i];
62
-
63
- else
64
- {
66
+ } else {
65
67
  if (!cur_num.empty()) {
66
68
  result.push_back(cur_num);
67
69
  cur_num.clear();
@@ -69,43 +71,37 @@ namespace rnoh {
69
71
 
70
72
  cur_op = formula[i];
71
73
 
72
- if (op_stack.empty())
74
+ if (op_stack.empty()) {
73
75
  op_stack.push_back(cur_op);
74
- else if (cur_op == "(")
76
+ } else if (cur_op == "(") {
75
77
  op_stack.push_back(cur_op);
76
-
77
- else if (cur_op == ")")
78
- {
78
+ } else if (cur_op == ")") {
79
79
  while (op_stack.back() != "(") {
80
80
  result.push_back(op_stack.back());
81
81
  op_stack.pop_back();
82
82
 
83
- if (op_stack.empty())
84
- {
83
+ if (op_stack.empty()) {
85
84
  ExpressionError = true;
86
85
  result.push_back("0");
87
86
  return result;
88
87
  }
89
88
  }
90
- op_stack.pop_back();
91
- } else if (op_stack.back() == "(")
89
+ op_stack.pop_back();
90
+ } else if (op_stack.back() == "(") {
92
91
  op_stack.push_back(cur_op);
93
- else if (
94
- ExpressHandleEval::getInstance()->op_mapping[cur_op] >
95
- ExpressHandleEval::getInstance()->op_mapping
96
- [op_stack
97
- .back()])
92
+ } else if (ExpressHandleEval::getInstance()->op_mapping[cur_op] >
93
+ ExpressHandleEval::getInstance()->op_mapping[op_stack.back()]) {
98
94
  op_stack.push_back(cur_op);
99
- else
100
- {
95
+ } else {
101
96
  while ((op_stack.back() != "(") && (ExpressHandleEval::getInstance()->op_mapping[op_stack.back()] >=
102
97
  ExpressHandleEval::getInstance()->op_mapping[cur_op])) {
103
98
  result.push_back(op_stack.back());
104
99
  op_stack.pop_back();
105
- if (op_stack.empty())
100
+ if (op_stack.empty()) {
106
101
  break;
102
+ }
107
103
  }
108
- op_stack.push_back(cur_op);
104
+ op_stack.push_back(cur_op);
109
105
  }
110
106
  }
111
107
  }
@@ -118,14 +114,14 @@ namespace rnoh {
118
114
 
119
115
  return result;
120
116
  }
121
- double calculatePostfix(vector<string> &postfix) {
117
+ double calculatePostfix(vector<string> &postfix)
118
+ {
122
119
  vector<double> result;
123
120
  for (int i = 0; i < postfix.size(); ++i) {
124
- if (ops.find(postfix[i]) == ops.npos)
121
+ if (ops.find(postfix[i]) == ops.npos) {
125
122
  result.push_back(toDouble(postfix[i]));
126
- else
127
- {
128
- if (result.size() < 2) {
123
+ } else {
124
+ if (result.size() < BINDINGX_EVAL_TWO) {
129
125
  ExpressionError = true;
130
126
  return 0.0;
131
127
  }
@@ -134,13 +130,13 @@ namespace rnoh {
134
130
  double num2 = result.back();
135
131
  result.pop_back();
136
132
  double op_res;
137
- if (postfix[i] == "+")
133
+ if (postfix[i] == "+") {
138
134
  op_res = num2 + num1;
139
- else if (postfix[i] == "-")
135
+ } else if (postfix[i] == "-") {
140
136
  op_res = num2 - num1;
141
- else if (postfix[i] == "*")
137
+ } else if (postfix[i] == "*") {
142
138
  op_res = num2 * num1;
143
- else if (postfix[i] == "/") {
139
+ } else if (postfix[i] == "/") {
144
140
  if (num1 == 0) {
145
141
  ValueError = true;
146
142
  return 0.0;
@@ -151,21 +147,22 @@ namespace rnoh {
151
147
  result.push_back(op_res);
152
148
  }
153
149
  }
154
- if (result.size() == 1)
150
+ if (result.size() == 1) {
155
151
  return result.back();
156
- else
157
- {
152
+ } else {
158
153
  ExpressionError = true;
159
154
  return 0.0;
160
155
  }
161
156
  }
162
157
 
163
- double ExpressHandleEval::eval(const string &infix) {
158
+ double ExpressHandleEval::eval(const string &infix)
159
+ {
164
160
  vector<string> postfix = toPostfix(infix);
165
161
  return calculatePostfix(postfix);
166
162
  }
167
163
 
168
- ExpressHandleEval *ExpressHandleEval::getInstance() {
164
+ ExpressHandleEval *ExpressHandleEval::getInstance()
165
+ {
169
166
  if (!m_ExpressHandleEval) {
170
167
  m_ExpressHandleEval = new ExpressHandleEval();
171
168
  }
@@ -26,7 +26,7 @@
26
26
  #define HARMONY_EXPRESSHANDLEEVAL_H
27
27
 
28
28
  #include <iostream>
29
- #include <stdio.h>
29
+ #include <cstdio>
30
30
  #include <sstream>
31
31
  #include <string>
32
32
  #include <vector>
@@ -37,7 +37,7 @@ namespace rnoh {
37
37
  class ExpressHandleEval {
38
38
 
39
39
  public:
40
- map<string, int> op_mapping;
40
+ map<string, int> op_mapping;
41
41
 
42
42
  public:
43
43
  ExpressHandleEval() {}
@@ -29,7 +29,9 @@
29
29
  namespace rnoh {
30
30
  using namespace facebook;
31
31
 
32
- ReactBindingXModule::ReactBindingXModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
32
+ ReactBindingXModule::ReactBindingXModule(const ArkTSTurboModule::Context ctx, const std::string name)
33
+ : ArkTSTurboModule(ctx, name)
34
+ {
33
35
  methodMap_ = {
34
36
  ARK_METHOD_METADATA(bind, 1),
35
37
  ARK_METHOD_METADATA(unbind, 1),
@@ -35,7 +35,8 @@ using namespace facebook;
35
35
 
36
36
  class ReactBindingXTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
37
37
  public:
38
- SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
38
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
39
+ {
39
40
  if (name == "ReactBindingXModule") {
40
41
  return std::make_shared<ReactBindingXModule>(ctx, name);
41
42
  }
@@ -44,10 +45,12 @@ public:
44
45
  };
45
46
 
46
47
 
47
- std::unique_ptr<TurboModuleFactoryDelegate> ReactBindingXPackage::createTurboModuleFactoryDelegate() {
48
+ std::unique_ptr<TurboModuleFactoryDelegate> ReactBindingXPackage::createTurboModuleFactoryDelegate()
49
+ {
48
50
  return std::make_unique<ReactBindingXTurboModuleFactoryDelegate>();
49
51
  }
50
52
 
51
- std::vector<ArkTSMessageHandler::Shared> ReactBindingXPackage::createArkTSMessageHandlers() {
53
+ std::vector<ArkTSMessageHandler::Shared> ReactBindingXPackage::createArkTSMessageHandlers()
54
+ {
52
55
  return {std::make_shared<ReactBindingxArkTSMessageHandler>()};
53
56
  }
@@ -28,7 +28,7 @@
28
28
  namespace rnoh {
29
29
  class ReactBindingXPackage : public Package {
30
30
  public:
31
- ReactBindingXPackage(Package::Context ctx) : Package(ctx) {}
31
+ explicit ReactBindingXPackage(Package::Context ctx) : Package(ctx) {}
32
32
 
33
33
  std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
34
34
 
@@ -25,66 +25,77 @@
25
25
  #include <string>
26
26
  #include <vector>
27
27
 
28
- namespace rnoh
29
- {
28
+ #define MESSAGE_HANDLER_THREE 3
30
29
 
30
+ namespace rnoh {
31
31
  double scrollEvalValue;
32
32
  ReactBindingxArkTSMessageHandler *m_reactBindingxArkTSMessageHandler;
33
33
 
34
34
  int hex_char_value(char c)
35
35
  {
36
- if (c >= '0' && c <= '9')
36
+ const int decimalBaseOffset = 10;
37
+ if (c >= '0' && c <= '9') {
37
38
  return c - '0';
38
- else if (c >= 'a' && c <= 'f')
39
- return (c - 'a' + 10);
40
- else if (c >= 'A' && c <= 'F')
41
- return (c - 'A' + 10);
39
+ } else if (c >= 'a' && c <= 'f') {
40
+ return (c - 'a' + decimalBaseOffset);
41
+ } else if (c >= 'A' && c <= 'F') {
42
+ return (c - 'A' + decimalBaseOffset);
43
+ }
42
44
  return 0;
43
45
  }
44
46
  int hex_to_decimal(const char *szHex, int len)
45
47
  {
48
+ const int hexBase = 16;
46
49
  int result = 0;
47
- for (int i = 0; i < len; i++)
48
- {
49
- result += (int)pow((float)16, (int)len - i - 1) * hex_char_value(szHex[i]);
50
+ for (int i = 0; i < len; i++) {
51
+ result += static_cast<int>(pow(static_cast<float>(hexBase), static_cast<int>(len) - i - 1)) *
52
+ hex_char_value(szHex[i]);
50
53
  }
51
54
  return result;
52
55
  }
53
56
  int evaluate(float fraction, int startValue, int endValue)
54
57
  {
55
58
  int startInt = startValue;
56
- float startA = ((startInt >> 24) & 0xff) / 255.0;
57
- float startR = ((startInt >> 16) & 0xff) / 255.0;
58
- float startG = ((startInt >> 8) & 0xff) / 255.0;
59
- float startB = (startInt & 0xff) / 255.0;
59
+
60
+ const int alphaShift = 24;
61
+ const int redShift = 16;
62
+ const int greenShift = 8;
63
+ const double colorNormalization = 255.0;
64
+ const double gammaEncode = 2.2;
65
+ const double gammaDecode = 1.0;
66
+
67
+ float startA = ((startInt >> alphaShift) & 0xff) / colorNormalization;
68
+ float startR = ((startInt >> redShift) & 0xff) / colorNormalization;
69
+ float startG = ((startInt >> greenShift) & 0xff) / colorNormalization;
70
+ float startB = (startInt & 0xff) / colorNormalization;
60
71
 
61
72
  int endInt = endValue;
62
- float endA = ((endInt >> 24) & 0xff) / 255.0;
63
- float endR = ((endInt >> 16) & 0xff) / 255.0;
64
- float endG = ((endInt >> 8) & 0xff) / 255.0;
65
- float endB = (endInt & 0xff) / 255.0;
73
+ float endA = ((endInt >> alphaShift) & 0xff) / colorNormalization;
74
+ float endR = ((endInt >> redShift) & 0xff) / colorNormalization;
75
+ float endG = ((endInt >> greenShift) & 0xff) / colorNormalization;
76
+ float endB = (endInt & 0xff) / colorNormalization;
66
77
 
67
- startR = pow(startR, 2.2);
68
- startG = pow(startG, 2.2);
69
- startB = pow(startB, 2.2);
78
+ startR = pow(startR, gammaEncode);
79
+ startG = pow(startG, gammaEncode);
80
+ startB = pow(startB, gammaEncode);
70
81
 
71
- endR = pow(endR, 2.2);
72
- endG = pow(endG, 2.2);
73
- endB = pow(endB, 2.2);
82
+ endR = pow(endR, gammaEncode);
83
+ endG = pow(endG, gammaEncode);
84
+ endB = pow(endB, gammaEncode);
74
85
  float a = startA + fraction * (endA - startA);
75
86
  float r = startR + fraction * (endR - startR);
76
87
  float g = startG + fraction * (endG - startG);
77
88
  float b = startB + fraction * (endB - startB);
78
- a = a * 255.0;
79
- r = pow(r, 1.0 / 2.2) * 255.0;
80
- g = pow(g, 1.0 / 2.2) * 255.0;
81
- b = pow(b, 1.0 / 2.2) * 255.0;
89
+ a = a * colorNormalization;
90
+ r = pow(r, gammaDecode / gammaEncode) * colorNormalization;
91
+ g = pow(g, gammaDecode / gammaEncode) * colorNormalization;
92
+ b = pow(b, gammaDecode / gammaEncode) * colorNormalization;
82
93
 
83
94
  int ra = round(a);
84
95
  int rr = round(r);
85
96
  int rg = round(g);
86
97
  int rb = round(b);
87
- return ra << 24 | rr << 16 | rg << 8 | rb;
98
+ return (ra << alphaShift) | (rr << redShift) | (rg << greenShift) | rb;
88
99
  }
89
100
 
90
101
  int minNum(int a, int b) { return a > b ? b : a; }
@@ -92,17 +103,16 @@ namespace rnoh
92
103
  std::vector<std::string> split(const std::string &src, const std::string &sep)
93
104
  {
94
105
  std::vector<std::string> tokens;
95
- int lastPos = 0,
96
- index, sepLen = sep.length();
97
- while (-1 != (index = src.find(sep, lastPos)))
98
- {
106
+ int lastPos = 0;
107
+ int index;
108
+ int sepLen = sep.length();
109
+ while (-1 != (index = src.find(sep, lastPos))) {
99
110
  tokens.push_back(src.substr(lastPos, index - lastPos));
100
111
  lastPos = index + sepLen;
101
112
  }
102
113
 
103
114
  std::string lastString = src.substr(lastPos);
104
- if (!lastString.empty())
105
- {
115
+ if (!lastString.empty()) {
106
116
  tokens.push_back(lastString);
107
117
  }
108
118
  return tokens;
@@ -111,13 +121,10 @@ namespace rnoh
111
121
  std::vector<std::string> findProperty(std::vector<std::string> propertyWords, std::vector<std::string> propertyAtr)
112
122
  {
113
123
  std::vector<std::string> result;
114
- for (int i = 0; i < propertyAtr.size(); i++)
115
- {
124
+ for (int i = 0; i < propertyAtr.size(); i++) {
116
125
  auto temp = propertyAtr[i];
117
- for (int j = 0; j < propertyWords.size(); j++)
118
- {
119
- if (temp == propertyWords[j])
120
- {
126
+ for (int j = 0; j < propertyWords.size(); j++) {
127
+ if (temp == propertyWords[j]) {
121
128
  result.push_back(temp);
122
129
  }
123
130
  }
@@ -127,17 +134,16 @@ namespace rnoh
127
134
 
128
135
  void ReactBindingxArkTSMessageHandler::handleScroll()
129
136
  {
137
+ const double angleScaleFactor = 0.03;
130
138
  auto panActionCallBack = ReactBindingxArkTSMessageHandler::getInstance()->m_panActionCallBack;
131
139
  auto scrollViewComponentInstance =
132
140
  std::dynamic_pointer_cast<rnoh::ScrollViewComponentInstance>(panActionCallBack->componentInstance);
133
141
 
134
142
  float scrollY = scrollViewComponentInstance->getScrollViewMetrics().contentOffset.y;
135
- if (this->m_scrollY != scrollY)
136
- {
143
+ if (this->m_scrollY != scrollY) {
137
144
  this->m_scrollY = scrollY;
138
145
  }
139
- if (this->m_scrollY <= 0)
140
- {
146
+ if (this->m_scrollY <= 0) {
141
147
  this->m_scrollY = 1;
142
148
  panActionCallBack->angle = 1;
143
149
  }
@@ -147,8 +153,7 @@ namespace rnoh
147
153
  roateMatchPropertys.push_back("transform.rotateX");
148
154
  roateMatchPropertys.push_back("transform.rotateY");
149
155
  std::vector<std::string> findRoateAtr = findProperty(roateMatchPropertys, panActionCallBack->propertyAtr);
150
- if (findRoateAtr.size() > 0)
151
- {
156
+ if (findRoateAtr.size() > 0) {
152
157
  ArkUI_NumberValue roateValue[] = {
153
158
  {.f32 = 0}, {.f32 = 0}, {.f32 = 1}, {.f32 = static_cast<float>(this->m_scrollY)}, {.f32 = 0}};
154
159
  ArkUI_AttributeItem roateItem = {roateValue, sizeof(roateValue) / sizeof(ArkUI_NumberValue)};
@@ -157,24 +162,21 @@ namespace rnoh
157
162
  NODE_ROTATE, &roateItem);
158
163
  }
159
164
  DLOG(INFO) << "ReactBindingXPackage::scroll getScrollViewMetrics y:" << this->m_scrollY
160
- << " scrollY:" << panActionCallBack->scrollY << " angle:" << panActionCallBack->angle
161
- << " width:" << scrollViewComponentInstance->getLayoutMetrics().frame.size.width;
165
+ << " scrollY:" << panActionCallBack->scrollY << " angle:" << panActionCallBack->angle
166
+ << " width:" << scrollViewComponentInstance->getLayoutMetrics().frame.size.width;
162
167
  float translate = this->m_scrollY;
163
- std::array<ArkUI_NumberValue, 3> translateValue = {ArkUI_NumberValue{.f32 = translate}, {.f32 = 0}, {.f32 = 0}};
168
+ std::array<ArkUI_NumberValue, MESSAGE_HANDLER_THREE> translateValue = {ArkUI_NumberValue{.f32 = translate},
169
+ {.f32 = 0}, {.f32 = 0}};
164
170
  ArkUI_AttributeItem translateItem = {translateValue.data(), translateValue.size()};
165
171
  NativeNodeApi::getInstance()->setAttribute(
166
172
  panActionCallBack->elementViewComponentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
167
173
  NODE_TRANSLATE, &translateItem);
168
174
 
169
- if (panActionCallBack->scrollY != this->m_scrollY)
170
- {
171
- if (panActionCallBack->scrollY > this->m_scrollY)
172
- {
173
- panActionCallBack->angle = this->m_scrollY * 0.03;
174
- }
175
- else
176
- {
177
- panActionCallBack->angle = this->m_scrollY * 0.03;
175
+ if (panActionCallBack->scrollY != this->m_scrollY) {
176
+ if (panActionCallBack->scrollY > this->m_scrollY) {
177
+ panActionCallBack->angle = this->m_scrollY * angleScaleFactor;
178
+ } else {
179
+ panActionCallBack->angle = this->m_scrollY * angleScaleFactor;
178
180
  }
179
181
  }
180
182
  panActionCallBack->scrollY = this->m_scrollY;
@@ -183,18 +185,14 @@ namespace rnoh
183
185
  backgroundColorMatchPropertys.push_back("background-color");
184
186
  std::vector<std::string> findbackgroundColorAtr =
185
187
  findProperty(backgroundColorMatchPropertys, panActionCallBack->propertyAtr);
186
- if (findbackgroundColorAtr.size() > 0 && panActionCallBack->backgroundcolor.c_str() != nullptr)
187
- {
188
+ if (findbackgroundColorAtr.size() > 0 && panActionCallBack->backgroundcolor.c_str() != nullptr) {
188
189
  auto backgroundcolorAtr = split(panActionCallBack->backgroundcolor, ",");
189
- if (panActionCallBack->angle < 1)
190
- {
190
+ if (panActionCallBack->angle < 1) {
191
191
  panActionCallBack->angle = 1;
192
192
  std::string color = backgroundcolorAtr[0];
193
193
  int color1 = hex_to_decimal(color.c_str(), color.size());
194
194
  panActionCallBack->elementViewComponentInstance->getLocalRootArkUINode().setBackgroundColor(color1);
195
- }
196
- else
197
- {
195
+ } else {
198
196
  std::string color = backgroundcolorAtr[0];
199
197
  int color1 = hex_to_decimal(color.c_str(), color.size());
200
198
  std::string backgroundcolorEval = panActionCallBack->backgroundcolorEval;
@@ -221,8 +219,7 @@ namespace rnoh
221
219
  scaleMatchPropertys.push_back("transform.scaleX");
222
220
  scaleMatchPropertys.push_back("transform.scaleY");
223
221
  std::vector<std::string> findScaleAtr = findProperty(scaleMatchPropertys, panActionCallBack->propertyAtr);
224
- if (findScaleAtr.size() > 0)
225
- {
222
+ if (findScaleAtr.size() > 0) {
226
223
  ArkUI_NumberValue scaleValue[] = {{.f32 = static_cast<float>((panActionCallBack->angle))},
227
224
  {.f32 = static_cast<float>((panActionCallBack->angle))}};
228
225
  ArkUI_AttributeItem scaleItem = {scaleValue, sizeof(scaleValue) / sizeof(ArkUI_NumberValue)};
@@ -235,13 +232,12 @@ namespace rnoh
235
232
  void ReactBindingxArkTSMessageHandler::handleArkTSMessage(const Context &ctx)
236
233
  {
237
234
  auto rnInstance = ctx.rnInstance.lock();
238
- if (!rnInstance)
235
+ if (!rnInstance) {
239
236
  return;
240
- if (ctx.messageName == "prepare")
241
- {
237
+ }
238
+ if (ctx.messageName == "prepare") {
242
239
  auto eventType = ctx.messagePayload["eventType"];
243
- if (eventType == "pan")
244
- {
240
+ if (eventType == "pan") {
245
241
  auto maybeTag = ctx.messagePayload["anchor"];
246
242
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
247
243
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
@@ -250,19 +246,18 @@ namespace rnoh
250
246
  panGestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(anyGestureApi);
251
247
  panPanGesture =
252
248
  panGestureApi->createPanGesture(1, GESTURE_DIRECTION_HORIZONTAL | GESTURE_DIRECTION_VERTICAL, 0);
253
- auto onPanActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam)
254
- {
255
- if (ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan)
249
+ auto onPanActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
250
+ if (ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan) {
256
251
  return;
252
+ }
257
253
  PanActionCallBack *panActionCallBack = (PanActionCallBack *)extraParam;
258
254
  ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
259
255
  float x = OH_ArkUI_PanGesture_GetOffsetX(event);
260
256
  float y = OH_ArkUI_PanGesture_GetOffsetY(event);
261
- if (actionType == GESTURE_EVENT_ACTION_UPDATE)
262
- {
257
+ if (actionType == GESTURE_EVENT_ACTION_UPDATE) {
263
258
  panActionCallBack->offsetX = panActionCallBack->positionX + x;
264
259
  panActionCallBack->offsetY = panActionCallBack->positionY + y;
265
- std::array<ArkUI_NumberValue, 3> translateValue = {
260
+ std::array<ArkUI_NumberValue, MESSAGE_HANDLER_THREE> translateValue = {
266
261
  ArkUI_NumberValue{.f32 = panActionCallBack->offsetX * panActionCallBack->px2vp},
267
262
  {.f32 = panActionCallBack->offsetY * panActionCallBack->px2vp},
268
263
  {.f32 = 0}};
@@ -270,10 +265,10 @@ namespace rnoh
270
265
  NativeNodeApi::getInstance()->setAttribute(
271
266
  panActionCallBack->componentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
272
267
  NODE_TRANSLATE, &translateItem);
273
- panActionCallBack->rnInstance.lock()->postMessageToArkTS("touch", to_string(panActionCallBack->offsetX * panActionCallBack->px2vp) + "," + to_string(panActionCallBack->offsetY * panActionCallBack->px2vp));
274
- }
275
- else if (actionType == GESTURE_EVENT_ACTION_END)
276
- {
268
+ panActionCallBack->rnInstance.lock()->postMessageToArkTS("touch", to_string(panActionCallBack->
269
+ offsetX * panActionCallBack->px2vp) + "," + to_string(panActionCallBack->
270
+ offsetY * panActionCallBack->px2vp));
271
+ } else if (actionType == GESTURE_EVENT_ACTION_END) {
277
272
  panActionCallBack->positionX = panActionCallBack->offsetX;
278
273
  panActionCallBack->positionY = panActionCallBack->offsetY;
279
274
  }
@@ -285,30 +280,21 @@ namespace rnoh
285
280
  panGestureApi->setGestureEventTarget(
286
281
  panPanGesture, GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_END,
287
282
  panActionCallBack, onPanActionCallBack);
288
- if (panGestureApi && componentInstance)
289
- {
290
- panGestureApi->addGestureToNode(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
291
- panPanGesture, PARALLEL, NORMAL_GESTURE_MASK);
292
- ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan = true;
293
- }
294
- else if (!componentInstance)
295
- {
296
- DLOG(INFO) << "ReactBindingXPackage componentInstance is null";
297
- }
283
+ panGestureApi->addGestureToNode(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
284
+ panPanGesture, PARALLEL, NORMAL_GESTURE_MASK);
285
+ ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan = true;
298
286
  }
299
287
  }
300
- if (ctx.messageName == "bind")
301
- {
288
+ if (ctx.messageName == "bind") {
302
289
  DLOG(INFO) << "ReactBindingXPackage::messagePayload:" << ctx.messagePayload;
303
290
  auto eventType = (ctx.messagePayload["options"])["eventType"];
304
- if (eventType == "orientation")
305
- {
291
+ if (eventType == "orientation") {
306
292
  auto maybeTag = ((ctx.messagePayload["options"])["props"])[0]["element"];
307
293
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
308
294
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
309
295
  auto x = (ctx.messagePayload["data"])["x"].asDouble();
310
296
  auto y = (ctx.messagePayload["data"])["y"].asDouble();
311
- std::array<ArkUI_NumberValue, 3> translateValue = {
297
+ std::array<ArkUI_NumberValue, MESSAGE_HANDLER_THREE> translateValue = {
312
298
  ArkUI_NumberValue{.f32 = static_cast<float>(x) * 100},
313
299
  {.f32 = static_cast<float>(y) * 100},
314
300
  {.f32 = 0}};
@@ -316,101 +302,36 @@ namespace rnoh
316
302
  NativeNodeApi::getInstance()->setAttribute(
317
303
  componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_TRANSLATE,
318
304
  &translateItem);
319
- }
320
- else if (eventType == "pan")
321
- {
322
- DLOG(INFO) << "ReactBindingXPackage bind :pan:" << ctx.messagePayload;
323
- auto maybeTag = (ctx.messagePayload["options"])["anchor"];
324
- DLOG(INFO) << " ReactBindingXPackage pan maybeTag:" << maybeTag.asDouble();
325
- auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
326
- auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
327
- auto anyGestureApi = OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1");
328
- panGestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(anyGestureApi);
329
- panPanGesture =
330
- panGestureApi->createPanGesture(1, GESTURE_DIRECTION_HORIZONTAL | GESTURE_DIRECTION_VERTICAL, 0);
331
- auto onPanActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam)
332
- {
333
- if (ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan)
334
- return;
335
- PanActionCallBack *panActionCallBack = (PanActionCallBack *)extraParam;
336
- ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
337
- float x = OH_ArkUI_PanGesture_GetOffsetX(event);
338
- float y = OH_ArkUI_PanGesture_GetOffsetY(event);
339
- if (actionType == GESTURE_EVENT_ACTION_UPDATE)
340
- {
341
- panActionCallBack->offsetX = panActionCallBack->positionX + x;
342
- panActionCallBack->offsetY = panActionCallBack->positionY + y;
343
- std::array<ArkUI_NumberValue, 3> translateValue = {
344
- ArkUI_NumberValue{.f32 = panActionCallBack->offsetX * panActionCallBack->px2vp},
345
- {.f32 = panActionCallBack->offsetY * panActionCallBack->px2vp},
346
- {.f32 = 0}};
347
- ArkUI_AttributeItem translateItem = {translateValue.data(), translateValue.size()};
348
- NativeNodeApi::getInstance()->setAttribute(
349
- panActionCallBack->componentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
350
- NODE_TRANSLATE, &translateItem);
351
- panActionCallBack->rnInstance.lock()->postMessageToArkTS(
352
- "touch", to_string(panActionCallBack->offsetX * panActionCallBack->px2vp) + "," +
353
- to_string(panActionCallBack->offsetY * panActionCallBack->px2vp));
354
- }
355
- else if (actionType == GESTURE_EVENT_ACTION_END)
356
- {
357
- panActionCallBack->positionX = panActionCallBack->offsetX;
358
- panActionCallBack->positionY = panActionCallBack->offsetY;
359
- }
360
- };
361
- PanActionCallBack *panActionCallBack =
362
- new PanActionCallBack{.componentInstance = componentInstance,
363
- .px2vp = static_cast<float>(ctx.messagePayload["px2vp"].asDouble()),
364
- .rnInstance = rnInstance};
365
- panGestureApi->setGestureEventTarget(
366
- panPanGesture, GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_END,
367
- panActionCallBack, onPanActionCallBack);
368
- if (panGestureApi && componentInstance)
369
- {
370
- panGestureApi->addGestureToNode(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(),
371
- panPanGesture, PARALLEL, NORMAL_GESTURE_MASK);
372
- ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan = true;
373
- }
374
- else if (!componentInstance)
375
- {
376
- DLOG(INFO) << "ReactBindingXPackage componentInstance is null";
377
- }
378
-
305
+ } else if (eventType == "pan") {
379
306
  ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan = false;
380
- }
381
- else if (eventType == "scroll")
382
- {
307
+ } else if (eventType == "scroll") {
383
308
  auto maybeTag = (ctx.messagePayload["options"])["anchor"];
384
309
  DLOG(INFO) << "ReactBindingXPackage::scroll maybeTag: " << maybeTag.asDouble();
385
310
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
386
311
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
387
- auto anyGestureApi =
388
- OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1");
312
+ auto anyGestureApi = OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE,
313
+ "ArkUI_NativeGestureAPI_1");
389
314
  scrollGestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(anyGestureApi);
390
315
  scrollPanGesture = scrollGestureApi->createPanGesture(1, GESTURE_DIRECTION_VERTICAL, 1);
391
316
  folly::dynamic elementViewTag;
392
317
  folly::dynamic elementTextTag;
393
318
  vector<std::string> propertyAtr;
394
- for (int i = 0; i < ((ctx.messagePayload["options"])["props"]).size(); i++)
395
- {
319
+ for (int i = 0; i < ((ctx.messagePayload["options"])["props"]).size(); i++) {
396
320
  auto element = ((ctx.messagePayload["options"])["props"])[i]["element"];
397
321
  auto property = ((ctx.messagePayload["options"])["props"])[i]["property"];
398
322
  propertyAtr.push_back(property.asString());
399
- if (property == "color")
400
- {
323
+ if (property == "color") {
401
324
  elementTextTag = element;
402
- }
403
- else
404
- {
325
+ } else {
405
326
  elementViewTag = element;
406
327
  }
407
328
  }
408
- if (elementViewTag == nullptr)
329
+ if (elementViewTag == nullptr) {
409
330
  return;
331
+ }
410
332
  auto elementComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(elementViewTag.asDouble());
411
333
  ComponentInstance::Shared elementTextComponentInstance;
412
- if (elementTextTag != nullptr)
413
- {
334
+ if (elementTextTag != nullptr) {
414
335
  elementTextComponentInstance =
415
336
  rnInstanceCAPI->findComponentInstanceByTag(elementTextTag.asDouble());
416
337
  }
@@ -429,8 +350,7 @@ namespace rnoh
429
350
  .color =
430
351
  (ctx.messagePayload["color"] != nullptr) ? ctx.messagePayload["color"].asString() : nullptr,
431
352
  };
432
- auto onPanActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam)
433
- {
353
+ auto onPanActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
434
354
  PanActionCallBack *panActionCallBack = (PanActionCallBack *)extraParam;
435
355
  ReactBindingxArkTSMessageHandler::getInstance()->m_panActionCallBack = panActionCallBack;
436
356
  ReactBindingxArkTSMessageHandler::getInstance()->handleScroll();
@@ -443,9 +363,7 @@ namespace rnoh
443
363
  scrollGestureApi->addGestureToNode(
444
364
  componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), scrollPanGesture,
445
365
  PARALLEL, NORMAL_GESTURE_MASK);
446
- }
447
- else if (eventType == "timing")
448
- {
366
+ } else if (eventType == "timing") {
449
367
  auto maybeTag = ((ctx.messagePayload["options"])["props"])[0]["element"];
450
368
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
451
369
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
@@ -453,8 +371,7 @@ namespace rnoh
453
371
  auto y = (ctx.messagePayload["data"])["y"].asDouble();
454
372
  DLOG(INFO) << "ReactBindingXPackage::timing x:" << x << " y:" << y;
455
373
  vector<std::string> propertyAtr;
456
- for (int i = 0; i < ((ctx.messagePayload["options"])["props"]).size(); i++)
457
- {
374
+ for (int i = 0; i < ((ctx.messagePayload["options"])["props"]).size(); i++) {
458
375
  auto property = ((ctx.messagePayload["options"])["props"])[i]["property"];
459
376
  propertyAtr.push_back(property.asString());
460
377
  }
@@ -463,9 +380,8 @@ namespace rnoh
463
380
  translateMatchPropertys.push_back("transform.translateX");
464
381
  translateMatchPropertys.push_back("transform.translateY");
465
382
  vector<std::string> findTranslateAtr = findProperty(translateMatchPropertys, propertyAtr);
466
- if (findTranslateAtr.size() > 0)
467
- {
468
- std::array<ArkUI_NumberValue, 3> translateValue = {
383
+ if (findTranslateAtr.size() > 0) {
384
+ std::array<ArkUI_NumberValue, MESSAGE_HANDLER_THREE> translateValue = {
469
385
  ArkUI_NumberValue{.f32 = static_cast<float>(x)}, {.f32 = static_cast<float>(y)}, {.f32 = 0}};
470
386
  ArkUI_AttributeItem translateItem = {translateValue.data(), translateValue.size()};
471
387
  NativeNodeApi::getInstance()->setAttribute(
@@ -475,8 +391,7 @@ namespace rnoh
475
391
  vector<std::string> opacityMatchPropertys;
476
392
  opacityMatchPropertys.push_back("opacity");
477
393
  vector<std::string> findOpacityAtr = findProperty(translateMatchPropertys, propertyAtr);
478
- if (findOpacityAtr.size() > 0)
479
- {
394
+ if (findOpacityAtr.size() > 0) {
480
395
  ArkUI_NumberValue opacityValue[] = {
481
396
  {.f32 = static_cast<float>(ctx.messagePayload["opacity"].asDouble())}};
482
397
  ArkUI_AttributeItem opacityItem = {opacityValue, sizeof(opacityValue) / sizeof(ArkUI_NumberValue)};
@@ -485,68 +400,58 @@ namespace rnoh
485
400
  &opacityItem);
486
401
  }
487
402
  }
488
- }
489
- else if (ctx.messageName == "unbind")
490
- {
491
-
403
+ } else if (ctx.messageName == "unbind") {
492
404
  auto eventType = (ctx.messagePayload["options"])["eventType"];
493
- if (eventType == "pan")
494
- {
405
+ if (eventType == "pan") {
495
406
  auto maybeTag = (ctx.messagePayload["options"])["token"];
496
407
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
497
408
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
498
- if (panGestureApi && componentInstance)
499
- {
409
+ if (panGestureApi && componentInstance) {
500
410
  panGestureApi->removeGestureFromNode(
501
411
  componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), panPanGesture);
502
412
  }
503
413
  ReactBindingxArkTSMessageHandler::getInstance()->isInterceptPan = false;
504
- }
505
- else if (eventType == "scroll")
506
- {
414
+ } else if (eventType == "scroll") {
507
415
  DLOG(INFO) << "ReactBindingXPackage::scroll unbind";
508
416
  auto maybeTag = (ctx.messagePayload["options"])["token"];
509
417
  DLOG(INFO) << "ReactBindingXPackage::event scroll unbind " << maybeTag.asDouble();
510
418
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
511
419
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag.asDouble());
512
- if (scrollGestureApi && componentInstance)
513
- {
420
+ if (scrollGestureApi && componentInstance) {
514
421
  scrollGestureApi->removeGestureFromNode(
515
422
  componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), scrollPanGesture);
516
423
  }
517
424
  }
518
- }
519
- else if (ctx.messageName == "eval")
520
- {
521
-
425
+ } else if (ctx.messageName == "eval") {
522
426
  auto msg = ctx.messagePayload["data"];
523
427
  ExpressHandleEval::getInstance()->init_mapping(ExpressHandleEval::getInstance()->op_mapping);
524
428
  double result = ExpressHandleEval::getInstance()->eval(msg.asString());
525
429
  std::ostringstream sstream;
526
430
  sstream << result;
527
431
  std::string eventType = ctx.messagePayload["eventType"].asString();
528
- if (eventType == "scroll")
529
- {
432
+ if (eventType == "scroll") {
530
433
  scrollEvalValue = result;
531
434
  }
532
- if (eventType == "timing")
533
- {
435
+ if (eventType == "timing") {
534
436
  rnInstance->postMessageToArkTS("eval", result);
535
437
  }
536
- }
537
- else if (ctx.messageName == "getComputedStyle")
538
- {
438
+ } else if (ctx.messageName == "getComputedStyle") {
539
439
  auto maybeTag = (ctx.messagePayload["element"]).asDouble();
540
440
  auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
541
441
  auto componentInstance = rnInstanceCAPI->findComponentInstanceByTag(maybeTag);
542
- float translate = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_TRANSLATE)->value[0].f32;
543
- float scale = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_SCALE)->value[0].f32;
544
- float roate = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_ROTATE)->value[3].f32;
545
- float opacity = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_OPACITY)->value[0].f32;
546
- float backgroundColor = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().getArkUINodeHandle(), NODE_BACKGROUND_COLOR)->value[0].u32;
442
+ float translate = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().
443
+ getArkUINodeHandle(), NODE_TRANSLATE)->value[0].f32;
444
+ float scale = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().
445
+ getArkUINodeHandle(), NODE_SCALE)->value[0].f32;
446
+ float roate = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().
447
+ getArkUINodeHandle(), NODE_ROTATE)->value[MESSAGE_HANDLER_THREE].f32;
448
+ float opacity = NativeNodeApi::getInstance()->getAttribute(componentInstance->getLocalRootArkUINode().
449
+ getArkUINodeHandle(), NODE_OPACITY)->value[0].f32;
450
+ float backgroundColor = NativeNodeApi::getInstance()->getAttribute(componentInstance->
451
+ getLocalRootArkUINode().getArkUINodeHandle(), NODE_BACKGROUND_COLOR)->value[0].u32;
547
452
  std::string computedStyle = "{translate:" + to_string(translate) + ",scale:" + to_string(scale) +
548
453
  ",roate:" + to_string(roate) + ",opacity:" + to_string(opacity) +
549
- ",background-color:" + to_string(backgroundColor) + "}";
454
+ ",background-color:" + to_string(backgroundColor) +"}";
550
455
  DLOG(INFO) << "ReactBindingXPackage::getComputedStyle post:" << computedStyle;
551
456
  rnInstance->postMessageToArkTS("style", computedStyle);
552
457
  }
@@ -554,8 +459,7 @@ namespace rnoh
554
459
 
555
460
  ReactBindingxArkTSMessageHandler *ReactBindingxArkTSMessageHandler::getInstance()
556
461
  {
557
- if (!m_reactBindingxArkTSMessageHandler)
558
- {
462
+ if (!m_reactBindingxArkTSMessageHandler) {
559
463
  m_reactBindingxArkTSMessageHandler = new ReactBindingxArkTSMessageHandler();
560
464
  }
561
465
  return m_reactBindingxArkTSMessageHandler;
@@ -68,7 +68,7 @@ namespace rnoh {
68
68
  static ReactBindingxArkTSMessageHandler *getInstance();
69
69
  float m_scrollY;
70
70
  std::map<std::string, std::string> styleMap;
71
- bool isInterceptPan = true;
71
+ bool isInterceptPan = true;
72
72
  public:
73
73
  void handleArkTSMessage(const Context &ctx) override;
74
74
 
@@ -22,9 +22,10 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import {RNPackage, TurboModuleContext, TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
26
- import type {TurboModule} from '@rnoh/react-native-openharmony/ts';
27
- import {ReactBindingXModule} from './ReactBindingXModule';
25
+ import { RNPackage, TurboModuleContext, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
26
+ import { RNOHPackage } from '@rnoh/react-native-openharmony'
27
+ import type { TurboModule } from '@rnoh/react-native-openharmony/ts';
28
+ import { ReactBindingXModule } from './ReactBindingXModule';
28
29
 
29
30
  class ReactBindingXTurboModulesFactory extends TurboModulesFactory {
30
31
  createTurboModule(name: string): TurboModule | null {
@@ -39,7 +40,7 @@ class ReactBindingXTurboModulesFactory extends TurboModulesFactory {
39
40
  }
40
41
  }
41
42
 
42
- export class ReactBindingXPackage extends RNPackage {
43
+ export class ReactBindingXPackage extends RNOHPackage {
43
44
  createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
44
45
  return new ReactBindingXTurboModulesFactory(ctx);
45
46
  }
@@ -22,5 +22,5 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export * from "./src/main/ets/ReactBindingXPackage"
25
+ export * from "./src/main/ets/ReactBindingXPackage.ets"
26
26
  export * from "./src/main/ets/ReactBindingXModule"
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-bindingx",
3
- "version": "1.0.4-rc.1",
3
+ "version": "1.0.4-rc.2",
4
4
  "scripts": {
5
5
  "prepublish": "",
6
6
  "test": "jest"
@@ -8,7 +8,13 @@
8
8
  "main": "lib/index.js",
9
9
  "nativePackage": true,
10
10
  "harmony": {
11
- "alias":"react-native-bindingx"
11
+ "alias": "react-native-bindingx",
12
+ "autolinking": {
13
+ "etsPackageClassName": "ReactBindingXPackage",
14
+ "cppPackageClassName": "ReactBindingXPackage",
15
+ "cmakeLibraryTargetName": "rnoh_bindingx",
16
+ "ohPackageName": "@react-native-ohos/react-native-bindingx"
17
+ }
12
18
  },
13
19
  "dependencies": {
14
20
  "bindingx-parser": "^0.0.2"
@@ -22,6 +28,6 @@
22
28
  ],
23
29
  "publishConfig": {
24
30
  "registry": "https://registry.npmjs.org/",
25
- "access": "public"
31
+ "access": "public"
26
32
  }
27
33
  }