@ray-js/ray-ipc-utils 1.1.0 → 1.1.2-beta-1

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/lib/interface.js CHANGED
@@ -1,13 +1,19 @@
1
1
  export let ClarityType = /*#__PURE__*/function (ClarityType) {
2
2
  ClarityType["SS"] = "SS";
3
+ // 省流量
3
4
  ClarityType["SD"] = "SD";
5
+ // 标清
4
6
  ClarityType["HD"] = "HD";
7
+ // 高清
5
8
  ClarityType["UD"] = "UD";
9
+ // 超清
6
10
  ClarityType["SSP"] = "SSP";
11
+ // 超超清
7
12
  ClarityType["AUTO"] = "AUTO";
8
- ClarityType["AUDIO"] = "AUDIO";
13
+ // 自动
14
+ ClarityType["AUDIO"] = "AUDIO"; // 音频模式
9
15
  return ClarityType;
10
- }({}); // 音频模式
16
+ }({});
11
17
  export let IntercomMode = /*#__PURE__*/function (IntercomMode) {
12
18
  IntercomMode["OneWay"] = "OneWay";
13
19
  IntercomMode["TwoWay"] = "TwoWay";
@@ -1,6 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
2
3
  import "core-js/modules/esnext.iterator.map.js";
3
4
  import _find from 'lodash/find';
5
+ import { getSystemInfoSync } from '@ray-js/ray';
4
6
  // IPC Kit相关
5
7
  /**
6
8
  *
@@ -546,22 +548,36 @@ export const getCurrentSupportedTalkMode = function (deviceId) {
546
548
  let extendParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
547
549
  return new Promise(resolve => {
548
550
  try {
549
- ty.ipc.getCurrentSupportedTalkMode({
550
- deviceId,
551
- extendParam: extendParam,
552
- success: res => {
553
- resolve({
554
- code: 0,
555
- data: res
556
- });
557
- },
558
- fail: err => {
559
- resolve({
560
- code: -1,
561
- msg: err
562
- });
563
- }
564
- });
551
+ const systemInfo = getSystemInfoSync();
552
+ const {
553
+ platform
554
+ } = systemInfo;
555
+ if (platform === 'harmony') {
556
+ // 针对harmonyOS平台,暂默认返回支持双向对讲模式
557
+ resolve({
558
+ code: 0,
559
+ data: {
560
+ talkbackMode: 2
561
+ }
562
+ });
563
+ } else {
564
+ ty.ipc.getCurrentSupportedTalkMode({
565
+ deviceId,
566
+ extendParam: extendParam,
567
+ success: res => {
568
+ resolve({
569
+ code: 0,
570
+ data: res
571
+ });
572
+ },
573
+ fail: err => {
574
+ resolve({
575
+ code: -1,
576
+ msg: err
577
+ });
578
+ }
579
+ });
580
+ }
565
581
  } catch (err) {
566
582
  resolve({
567
583
  code: -1,
@@ -1,5 +1,11 @@
1
1
  import { ServeTpe } from '../interface';
2
2
  import { IRes } from '@/kit/interface';
3
+ /**
4
+ * 获取IPC设备配置信息
5
+ * @param deviceId 设备ID
6
+ *
7
+ */
8
+ export declare const getIpcConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>;
3
9
  /**
4
10
  * 获取IPC设备配置及缓存信息、
5
11
  * 包含: 视频清晰度、对讲方式、拾音器、视频缩放最大倍数
@@ -4,33 +4,13 @@ import "core-js/modules/esnext.iterator.map.js";
4
4
  import "core-js/modules/esnext.iterator.some.js";
5
5
  /* eslint-disable camelcase */
6
6
  import _trim from 'lodash/trim';
7
+ import { getIpcRtcConfig, getIpcPointList, updateIpcPointInfo, getVasUrlInfo } from '@ray-js/ray';
7
8
  import Strings from '../i18n';
8
9
  import { JsonUtil, getInitUtmTid } from '../utils';
9
10
  import { getDevInfo, getNativeStorage, setNativeStorage, publishDps, getDpStateValue, getDpIdByCode, jumpToWebView, goToMiniProgramByShortLink, getCurrentSupportedTalkMode, ipcTTTOperatorLog } from '../kit';
10
11
  import { ClarityType, IntercomMode, MuteMode, ServeTpe } from '../interface';
11
12
  const errStyle = 'background: red; color: #fff;';
12
13
 
13
- // 获取 IPC 配置信息
14
- const get_ipc_config_info_api = {
15
- url: 'm.ipc.v4.rtc.config.get',
16
- version: '1.0'
17
- };
18
- // 获取 IPC 收藏点信息
19
- const get_ipc_collect_info_api = {
20
- url: 'tuya.m.ipc.memory.point.list',
21
- version: '2.0'
22
- };
23
- // 更新 IPC 单个收藏点信息
24
- const update_ipc_collect_info_api = {
25
- url: 'tuya.m.ipc.memory.point.rename',
26
- version: '1.0'
27
- };
28
- // 获取 IPC 增值服务平台配置地址
29
- const get_ipc_cvas_url_api = {
30
- url: 'm.ecm.cvas.basic.url.config.get',
31
- version: '1.0'
32
- };
33
-
34
14
  /**
35
15
  * @description: 对讲模式
36
16
  */
@@ -84,19 +64,36 @@ const api = function (a, postData) {
84
64
  });
85
65
  };
86
66
 
67
+ /**
68
+ * @description: 通用 IPC 标准能力接口基础封装
69
+ */
70
+
71
+ const wrapIpcApiCall = async (apiFunc, params) => {
72
+ try {
73
+ const res = await apiFunc(params);
74
+ return {
75
+ code: 0,
76
+ data: res
77
+ };
78
+ } catch (err) {
79
+ const e = typeof err === 'string' ? JsonUtil.parseJSON(err) : err;
80
+ return {
81
+ code: -1,
82
+ msg: (e === null || e === void 0 ? void 0 : e.message) || (e === null || e === void 0 ? void 0 : e.errorMsg) || String(e)
83
+ };
84
+ }
85
+ };
86
+
87
87
  /**
88
88
  * 获取IPC设备配置信息
89
89
  * @param deviceId 设备ID
90
90
  *
91
91
  */
92
- const getIpcConfigInfo = deviceId => {
93
- const {
94
- url,
95
- version
96
- } = get_ipc_config_info_api;
97
- return api(url, {
92
+
93
+ export const getIpcConfigInfo = async deviceId => {
94
+ return wrapIpcApiCall(getIpcRtcConfig, {
98
95
  devId: deviceId
99
- }, version);
96
+ });
100
97
  };
101
98
 
102
99
  /**
@@ -175,15 +172,16 @@ export const getCameraConfigInfo = async deviceId => {
175
172
  // 获取支持的对讲方式
176
173
  const supportedIntercomModes = rtcApiResult === null || rtcApiResult === void 0 || (_rtcApiResult$audioAt3 = rtcApiResult.audioAttributes) === null || _rtcApiResult$audioAt3 === void 0 ? void 0 : _rtcApiResult$audioAt3.callMode;
177
174
  if (isIntercomSupported && supportedIntercomModes.length > 0) {
178
- var _appIntercomCached$da;
179
175
  intercomInfo.defaultIntercomMode = intercomCallMode[supportedIntercomModes[0]];
180
176
  intercomInfo.supportedIntercomModes = supportedIntercomModes.map(mode => intercomCallMode[mode]);
181
177
  // 获取APP当前存储的对讲模式, 因目前设置页对讲设置使用的还是原生页面,需要读取APP缓存保持一致
182
178
  const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
183
179
  if (appIntercomCached.code !== 0) {
184
- throw appIntercomCached.msg;
180
+ intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
181
+ } else {
182
+ var _appIntercomCached$da;
183
+ intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
185
184
  }
186
- intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
187
185
  }
188
186
 
189
187
  // 3. 视频分辨率模块
@@ -219,15 +217,17 @@ export const getCameraConfigInfo = async deviceId => {
219
217
  }
220
218
  }
221
219
  } else {
222
- var _intercomStorage$data2, _appIntercomCached$da2, _resolutionStorage$da2, _microphoneStorage$da2, _maxZoomSettingsStora2;
220
+ var _intercomStorage$data2, _resolutionStorage$da2, _microphoneStorage$da2, _maxZoomSettingsStora2;
223
221
  // 对于对讲缓存的方式每次需从APP获取更新
224
222
  const intercomStorageData = intercomStorage === null || intercomStorage === void 0 || (_intercomStorage$data2 = intercomStorage.data) === null || _intercomStorage$data2 === void 0 ? void 0 : _intercomStorage$data2.data;
225
223
  intercomInfo = intercomStorageData;
226
224
  const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
227
225
  if (appIntercomCached.code !== 0) {
228
- throw appIntercomCached.msg;
226
+ intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
227
+ } else {
228
+ var _appIntercomCached$da2;
229
+ intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da2 = appIntercomCached.data) === null || _appIntercomCached$da2 === void 0 ? void 0 : _appIntercomCached$da2.talkbackMode];
229
230
  }
230
- intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da2 = appIntercomCached.data) === null || _appIntercomCached$da2 === void 0 ? void 0 : _appIntercomCached$da2.talkbackMode];
231
231
  if (intercomStorageData.cachedIntercomMode !== intercomInfo.cachedIntercomMode) {
232
232
  setNativeStorage(`${deviceId}_intercom`, intercomInfo);
233
233
  }
@@ -249,10 +249,6 @@ export const getCameraConfigInfo = async deviceId => {
249
249
  } catch (err) {
250
250
  console.log(err, 'err');
251
251
  ipcTTTOperatorLog(`UTILS: getCameraConfigInfo_error_info: ${JSON.stringify(err)}`);
252
- // ty.showToast({
253
- // title: Strings.getLang('ipc_utils_get_ipc_config_info_api_err'),
254
- // icon: 'error',
255
- // });
256
252
  return Promise.resolve({
257
253
  code: -1,
258
254
  msg: err.errorMsg ? err.errorMsg : String(err)
@@ -265,14 +261,10 @@ export const getCameraConfigInfo = async deviceId => {
265
261
  * @param {string} deviceId 设备id
266
262
  */
267
263
 
268
- export const getCollectionPointsInfo = deviceId => {
269
- const {
270
- url,
271
- version
272
- } = get_ipc_collect_info_api;
273
- return api(url, {
264
+ export const getCollectionPointsInfo = async deviceId => {
265
+ return wrapIpcApiCall(getIpcPointList, {
274
266
  devId: deviceId
275
- }, version);
267
+ });
276
268
  };
277
269
 
278
270
  /**
@@ -282,11 +274,7 @@ export const getCollectionPointsInfo = deviceId => {
282
274
  * @param {string} name 收藏点名称
283
275
  */
284
276
 
285
- export const updateCollectionPointsInfo = (deviceId, id, name) => {
286
- const {
287
- url,
288
- version
289
- } = update_ipc_collect_info_api;
277
+ export const updateCollectionPointsInfo = async (deviceId, id, name) => {
290
278
  if (_trim(name) === '') {
291
279
  ty.showToast({
292
280
  icon: 'error',
@@ -307,11 +295,11 @@ export const updateCollectionPointsInfo = (deviceId, id, name) => {
307
295
  msg: Strings.getLang('ipc_utils_collect_name_limit_tip')
308
296
  });
309
297
  }
310
- return api(url, {
298
+ return wrapIpcApiCall(updateIpcPointInfo, {
311
299
  devId: deviceId,
312
300
  id,
313
301
  name
314
- }, version);
302
+ });
315
303
  };
316
304
 
317
305
  /**
@@ -499,7 +487,7 @@ export const getServiceUrl = async function (deviceId, serveType) {
499
487
  isSupportMini: true,
500
488
  homeId,
501
489
  param: frontParams,
502
- categoryCode: serveType || ServeTpe.securityCloudService,
490
+ categoryCode: serveType || ServeTpe.securityCloudService || '',
503
491
  deviceId,
504
492
  utmRtid: utm_rtid
505
493
  };
@@ -508,11 +496,7 @@ export const getServiceUrl = async function (deviceId, serveType) {
508
496
  params.categoryCode = '';
509
497
  params.path = 'pages/aiInspection/reportDetails/index';
510
498
  }
511
- const {
512
- url,
513
- version
514
- } = get_ipc_cvas_url_api;
515
- const result = await api(url, params, version);
499
+ const result = await wrapIpcApiCall(getVasUrlInfo, params);
516
500
  if ((result === null || result === void 0 ? void 0 : result.code) === -1) {
517
501
  return result;
518
502
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.2-beta-1",
4
4
  "description": "IPC 工具库",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -32,22 +32,23 @@
32
32
  "test": "yarn jest"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ray-js/ray": "^1.4.9"
35
+ "@ray-js/ray": "^1.7.13"
36
36
  },
37
37
  "dependencies": {
38
- "clsx": "^1.2.1",
39
- "@ray-js/panel-sdk": "^1.13.1"
38
+ "@ray-js/panel-sdk": "^1.13.1",
39
+ "clsx": "^1.2.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@commitlint/cli": "^7.2.1",
43
43
  "@commitlint/config-conventional": "^9.0.1",
44
- "@ray-js/cli": "^1.4.9",
45
- "@ray-js/ray": "^1.4.9",
44
+ "@ray-js/cli": "^1.7.13",
45
+ "@ray-js/ray": "^1.7.13",
46
46
  "@testing-library/react-hooks": "^8.0.1",
47
47
  "@types/jest": "^29.5.14",
48
48
  "core-js": "^3.19.1",
49
49
  "eslint-config-tuya-panel": "^0.4.2",
50
50
  "husky": "^1.2.0",
51
+ "less-loader": "^12.3.0",
51
52
  "lint-staged": "^10.2.11",
52
53
  "standard-version": "9.3.2"
53
54
  },