@ray-js/ray-ipc-utils 1.1.1 → 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
  /**
@@ -252,10 +249,6 @@ export const getCameraConfigInfo = async deviceId => {
252
249
  } catch (err) {
253
250
  console.log(err, 'err');
254
251
  ipcTTTOperatorLog(`UTILS: getCameraConfigInfo_error_info: ${JSON.stringify(err)}`);
255
- // ty.showToast({
256
- // title: Strings.getLang('ipc_utils_get_ipc_config_info_api_err'),
257
- // icon: 'error',
258
- // });
259
252
  return Promise.resolve({
260
253
  code: -1,
261
254
  msg: err.errorMsg ? err.errorMsg : String(err)
@@ -268,14 +261,10 @@ export const getCameraConfigInfo = async deviceId => {
268
261
  * @param {string} deviceId 设备id
269
262
  */
270
263
 
271
- export const getCollectionPointsInfo = deviceId => {
272
- const {
273
- url,
274
- version
275
- } = get_ipc_collect_info_api;
276
- return api(url, {
264
+ export const getCollectionPointsInfo = async deviceId => {
265
+ return wrapIpcApiCall(getIpcPointList, {
277
266
  devId: deviceId
278
- }, version);
267
+ });
279
268
  };
280
269
 
281
270
  /**
@@ -285,11 +274,7 @@ export const getCollectionPointsInfo = deviceId => {
285
274
  * @param {string} name 收藏点名称
286
275
  */
287
276
 
288
- export const updateCollectionPointsInfo = (deviceId, id, name) => {
289
- const {
290
- url,
291
- version
292
- } = update_ipc_collect_info_api;
277
+ export const updateCollectionPointsInfo = async (deviceId, id, name) => {
293
278
  if (_trim(name) === '') {
294
279
  ty.showToast({
295
280
  icon: 'error',
@@ -310,11 +295,11 @@ export const updateCollectionPointsInfo = (deviceId, id, name) => {
310
295
  msg: Strings.getLang('ipc_utils_collect_name_limit_tip')
311
296
  });
312
297
  }
313
- return api(url, {
298
+ return wrapIpcApiCall(updateIpcPointInfo, {
314
299
  devId: deviceId,
315
300
  id,
316
301
  name
317
- }, version);
302
+ });
318
303
  };
319
304
 
320
305
  /**
@@ -502,7 +487,7 @@ export const getServiceUrl = async function (deviceId, serveType) {
502
487
  isSupportMini: true,
503
488
  homeId,
504
489
  param: frontParams,
505
- categoryCode: serveType || ServeTpe.securityCloudService,
490
+ categoryCode: serveType || ServeTpe.securityCloudService || '',
506
491
  deviceId,
507
492
  utmRtid: utm_rtid
508
493
  };
@@ -511,11 +496,7 @@ export const getServiceUrl = async function (deviceId, serveType) {
511
496
  params.categoryCode = '';
512
497
  params.path = 'pages/aiInspection/reportDetails/index';
513
498
  }
514
- const {
515
- url,
516
- version
517
- } = get_ipc_cvas_url_api;
518
- const result = await api(url, params, version);
499
+ const result = await wrapIpcApiCall(getVasUrlInfo, params);
519
500
  if ((result === null || result === void 0 ? void 0 : result.code) === -1) {
520
501
  return result;
521
502
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-utils",
3
- "version": "1.1.1",
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
  },