@react-native-ohos/react-native-bindingx 1.0.4-rc.2 → 1.1.0

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