hunter-open-sdk 2.0.0-beta.33 → 2.0.0-beta.34

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.
@@ -25,10 +25,7 @@ class Activate {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -43,7 +43,7 @@ const getResourcePath = () => {
43
43
  * @param {String} params 参数
44
44
  * @returns {String} 发布配对结果
45
45
  */
46
- const publishPair = async (udid, payload, once = false) => {
46
+ const publishPair = async (udid, payload, once = true) => {
47
47
  // 防止设备拔出后仍一直循环占用cpu资源
48
48
  if (!_deviceHelper.deviceHelper.hasUdid(udid)) {
49
49
  return false;
@@ -54,7 +54,7 @@ const publishPair = async (udid, payload, once = false) => {
54
54
  const {
55
55
  code,
56
56
  data
57
- } = publishPairRes.payload;
57
+ } = publishPairRes;
58
58
  if (code == 0 && data === true) {
59
59
  return true;
60
60
  } else if (!once) {
@@ -71,7 +71,7 @@ const publishPair = async (udid, payload, once = false) => {
71
71
  * @param {String} params 参数
72
72
  * @returns {String} 发布配对结果
73
73
  */
74
- const trustStatus = async (udid, payload, once = false) => {
74
+ const trustStatus = async (udid, payload, once = true) => {
75
75
  // 防止设备拔出后仍一直循环占用cpu资源
76
76
  if (!_deviceHelper.deviceHelper.hasUdid(udid)) {
77
77
  return false;
@@ -82,12 +82,12 @@ const trustStatus = async (udid, payload, once = false) => {
82
82
  const {
83
83
  code,
84
84
  data
85
- } = trustStatusRes.payload;
85
+ } = trustStatusRes;
86
86
  if (code == 0 && data === true) {
87
87
  return true;
88
88
  } else if (!once) {
89
89
  await (0, _utils2.sleep)();
90
- return await trustStatus(udid, payload);
90
+ return await trustStatus(udid, payload, once);
91
91
  }
92
92
  }
93
93
  return false;
@@ -116,16 +116,22 @@ const DevicePair = async (udid = '', params) => {
116
116
  });
117
117
  };
118
118
 
119
- // 发起单次配对请求 已配对会直接通过
120
- const publishPairOnceRes = await trustStatus(udid, payload, true);
121
- if (publishPairOnceRes) {
119
+ // 获取一次信任状态 已配对会直接通过
120
+ const trustStatusOnceRes = await trustStatus(udid, payload);
121
+ if (trustStatusOnceRes) {
122
122
  callBack();
123
123
  return;
124
124
  }
125
125
 
126
- // 未通过持续发起配对
127
- const publishPairRes = await publishPair(udid, payload);
128
- publishPairRes && callBack();
126
+ // 执行一次配对发布
127
+ publishPair(udid, payload);
128
+
129
+ // 持续判定信任状态
130
+ const trustStatusRes = await trustStatus(udid, payload, false);
131
+ if (trustStatusRes) {
132
+ callBack();
133
+ }
134
+ return;
129
135
  };
130
136
 
131
137
  // 写入dll文件version
@@ -25,10 +25,7 @@ class GetAndroidReport {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -19,9 +19,7 @@ function onMainMessage(event, retryCount = 0) {
19
19
  } = event.data;
20
20
  const reportRes = abilityCallKit('general_report', payload);
21
21
  const {
22
- payload: {
23
- code
24
- } = {}
22
+ code
25
23
  } = reportRes;
26
24
 
27
25
  // 如果获取报告失败,则重试一次
@@ -25,10 +25,7 @@ class GetSaaSReport {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -25,10 +25,7 @@ class GetUltimateReport {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -25,10 +25,7 @@ class InstallApp {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -25,10 +25,7 @@ class Reboot {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -25,10 +25,7 @@ class Shutdown {
25
25
  }
26
26
  initWorkerListener() {
27
27
  this.worker && this.worker.addEventListener('message', event => {
28
- const {
29
- payload
30
- } = event.data;
31
- this.callback(payload);
28
+ this.callback(event.data);
32
29
  this.callback = null;
33
30
  });
34
31
  }
@@ -129,23 +129,17 @@ function abilityCallKit(cmd, payload) {
129
129
  } = payload;
130
130
  if (!params) {
131
131
  return {
132
- type: 'fail',
133
- payload: {
134
- code: -1,
135
- data: {},
136
- message: `调用【${cmd}】方法缺少必要参数`
137
- }
132
+ code: -1,
133
+ data: {},
134
+ message: `调用【${cmd}】方法缺少必要参数`
138
135
  };
139
136
  }
140
137
  const res = callHunterInspectionKit('InspectionKit', biz, cmd, params);
141
138
  if (!res) {
142
139
  return {
143
- type: 'fail',
144
- payload: {
145
- code: -1,
146
- data: {},
147
- message: `【${cmd}】方法执行失败`
148
- }
140
+ code: -1,
141
+ data: {},
142
+ message: `【${cmd}】方法执行失败`
149
143
  };
150
144
  }
151
145
  const resObj = JSON.parse(res);
@@ -156,20 +150,14 @@ function abilityCallKit(cmd, payload) {
156
150
  } = resObj;
157
151
  if (Code == 0) {
158
152
  return {
159
- type: 'success',
160
- payload: {
161
- code: 0,
162
- data: Data,
163
- message: `【${cmd}】方法执行成功`
164
- }
153
+ code: 0,
154
+ data: Data,
155
+ message: `【${cmd}】方法执行成功`
165
156
  };
166
157
  }
167
158
  return {
168
- type: 'fail',
169
- payload: {
170
- code: -1,
171
- data: {},
172
- message: Message || `【${cmd}】方法执行失败`
173
- }
159
+ code: -1,
160
+ data: {},
161
+ message: Message || `【${cmd}】方法执行失败`
174
162
  };
175
163
  }
@@ -49,7 +49,7 @@ class WorkerPool {
49
49
  worker.removeEventListener('message', onMessage);
50
50
  worker.removeEventListener('error', onError);
51
51
  try {
52
- callback(event.data.payload);
52
+ callback(event.data);
53
53
  } finally {
54
54
  this._finish(worker);
55
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hunter-open-sdk",
3
- "version": "2.0.0-beta.33",
3
+ "version": "2.0.0-beta.34",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",
@@ -18,7 +18,8 @@
18
18
  "dev-doc": "zz doc --dev",
19
19
  "build-doc": "zz doc",
20
20
  "cz": "zz cz",
21
- "test": "zz test"
21
+ "test": "zz test",
22
+ "yalc": "npm run build && yalc publish"
22
23
  },
23
24
  "main": "lib/index.js",
24
25
  "module": "lib/index.mjs",