@ray-js/ray-ipc-utils 1.1.0-beta-12 → 1.1.0-beta-14

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.
@@ -0,0 +1,30 @@
1
+ import { kit } from '@ray-js/panel-sdk';
2
+ declare const Strings: kit.I18N<{
3
+ en: {
4
+ ipc_utils_get_ipc_config_info_api_err: string;
5
+ ipc_utils_collect_name_empty: string;
6
+ ipc_utils_collect_name_limit_tip: string;
7
+ ipc_utils_collect_number_max_tip: string;
8
+ ipc_utils_cruise_ing_tip: string;
9
+ };
10
+ zh: {
11
+ ipc_utils_get_ipc_config_info_api_err: string;
12
+ ipc_utils_collect_name_empty: string;
13
+ ipc_utils_collect_name_limit_tip: string;
14
+ ipc_utils_collect_number_max_tip: string;
15
+ ipc_utils_cruise_ing_tip: string;
16
+ };
17
+ }, {
18
+ ipc_utils_get_ipc_config_info_api_err: string;
19
+ ipc_utils_collect_name_empty: string;
20
+ ipc_utils_collect_name_limit_tip: string;
21
+ ipc_utils_collect_number_max_tip: string;
22
+ ipc_utils_cruise_ing_tip: string;
23
+ } | {
24
+ ipc_utils_get_ipc_config_info_api_err: string;
25
+ ipc_utils_collect_name_empty: string;
26
+ ipc_utils_collect_name_limit_tip: string;
27
+ ipc_utils_collect_number_max_tip: string;
28
+ ipc_utils_cruise_ing_tip: string;
29
+ }>;
30
+ export default Strings;
@@ -0,0 +1,7 @@
1
+ import { kit } from '@ray-js/panel-sdk';
2
+ import strings from './strings';
3
+ const {
4
+ I18N
5
+ } = kit;
6
+ const Strings = new I18N(strings);
7
+ export default Strings;
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ en: {
3
+ ipc_utils_get_ipc_config_info_api_err: string;
4
+ ipc_utils_collect_name_empty: string;
5
+ ipc_utils_collect_name_limit_tip: string;
6
+ ipc_utils_collect_number_max_tip: string;
7
+ ipc_utils_cruise_ing_tip: string;
8
+ };
9
+ zh: {
10
+ ipc_utils_get_ipc_config_info_api_err: string;
11
+ ipc_utils_collect_name_empty: string;
12
+ ipc_utils_collect_name_limit_tip: string;
13
+ ipc_utils_collect_number_max_tip: string;
14
+ ipc_utils_cruise_ing_tip: string;
15
+ };
16
+ };
17
+ export default _default;
@@ -0,0 +1,16 @@
1
+ export default {
2
+ en: {
3
+ ipc_utils_get_ipc_config_info_api_err: 'Error in retrieving config information',
4
+ ipc_utils_collect_name_empty: 'Please enter a collection point name',
5
+ ipc_utils_collect_name_limit_tip: 'Collection point name cannot exceed 10 characters',
6
+ ipc_utils_collect_number_max_tip: 'You can add up to 6 collection points only',
7
+ ipc_utils_cruise_ing_tip: 'Cruising in progress, please stop first'
8
+ },
9
+ zh: {
10
+ ipc_utils_get_ipc_config_info_api_err: '配置信息获取出错',
11
+ ipc_utils_collect_name_empty: '请输入收藏点名称',
12
+ ipc_utils_collect_name_limit_tip: '收藏点名称不能超过10个字符',
13
+ ipc_utils_collect_number_max_tip: '最多只能添加6个收藏点',
14
+ ipc_utils_cruise_ing_tip: '正在巡航,请先停止巡航'
15
+ }
16
+ };
@@ -4,14 +4,15 @@ 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 Strings from '../i18n';
7
8
  import { JsonUtil, getInitUtmTid } from '../utils';
8
- import { getDevInfo, getNativeStorage, setNativeStorage, publishDps, getDpStateValue, getDpIdByCode, jumpToWebView, goToMiniProgramByShortLink, getCurrentSupportedTalkMode } from '../kit';
9
+ import { getDevInfo, getNativeStorage, setNativeStorage, publishDps, getDpStateValue, getDpIdByCode, jumpToWebView, goToMiniProgramByShortLink, getCurrentSupportedTalkMode, ipcTTTOperatorLog } from '../kit';
9
10
  import { ClarityType, IntercomMode, MuteMode, ServeTpe } from '../interface';
10
11
  const errStyle = 'background: red; color: #fff;';
11
12
 
12
13
  // 获取 IPC 配置信息
13
14
  const get_ipc_config_info_api = {
14
- url: 'tuya.m.rtc.config.get',
15
+ url: 'm.ipc.v4.rtc.config.get',
15
16
  version: '1.0'
16
17
  };
17
18
  // 获取 IPC 收藏点信息
@@ -111,7 +112,8 @@ export const getCameraConfigInfo = async deviceId => {
111
112
  }
112
113
  const {
113
114
  isVirtualDevice
114
- } = devInfo.data;
115
+ } = devInfo === null || devInfo === void 0 ? void 0 : devInfo.data;
116
+ ipcTTTOperatorLog(`Utils: config info isVirtualDevice status: ${isVirtualDevice}`);
115
117
  // 配置默认值
116
118
  const defaultResolution = ClarityType.HD;
117
119
  const supportedResolutions = [ClarityType.HD, ClarityType.SD];
@@ -138,6 +140,7 @@ export const getCameraConfigInfo = async deviceId => {
138
140
  // native 缓存Key值
139
141
 
140
142
  const nativeStorageInfo = await Promise.all([`${deviceId}_resolution`, `${deviceId}_intercom`, `${deviceId}_microphone`, `${deviceId}_maxZoomSettings`].map(key => getNativeStorage(key)));
143
+ ipcTTTOperatorLog(`Utils: nativeStorageInfo: ${nativeStorageInfo}`);
141
144
  console.log(nativeStorageInfo, 'nativeStorageInfo');
142
145
  const [resolutionStorage, intercomStorage, microphoneStorage, maxZoomSettingsStorage] = nativeStorageInfo;
143
146
  // 任意缓存为空,则请求接口
@@ -149,9 +152,15 @@ export const getCameraConfigInfo = async deviceId => {
149
152
  if (!isVirtualDevice) {
150
153
  var _microphoneStorage$da, _intercomStorage$data, _resolutionStorage$da, _maxZoomSettingsStora;
151
154
  const rtcInfo = await getIpcConfigInfo(deviceId);
155
+ ipcTTTOperatorLog(`Utils: rtcInfo: ${rtcInfo}`);
152
156
  if (rtcInfo.code === 0) {
153
157
  var _rtcApiResult$audioAt, _rtcApiResult$audioAt2, _rtcApiResult$audioAt3;
154
158
  const rtcApiResult = rtcInfo.data;
159
+ const {
160
+ p2pType
161
+ } = rtcApiResult;
162
+ const p2p4 = p2pType >= 8;
163
+ ipcTTTOperatorLog(`Utils: p2p4: ${p2p4}`);
155
164
  // 1. 拾音器模块
156
165
  const isMicrophoneSupported = rtcApiResult === null || rtcApiResult === void 0 || (_rtcApiResult$audioAt = rtcApiResult.audioAttributes) === null || _rtcApiResult$audioAt === void 0 || (_rtcApiResult$audioAt = _rtcApiResult$audioAt.hardwareCapability) === null || _rtcApiResult$audioAt === void 0 ? void 0 : _rtcApiResult$audioAt.includes(1);
157
166
  // 拾音器默认声音都为关闭, 若接口返回不支持,则将缓存值设置为关闭
@@ -177,9 +186,8 @@ export const getCameraConfigInfo = async deviceId => {
177
186
  }
178
187
 
179
188
  // 3. 视频分辨率模块
180
- videoResolution.defaultResolution = videoResolutionMode[rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClarity];
181
- console.log(rtcApiResult, 'rtcApiResult');
182
- const supportedVideoClarity = rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClaritys;
189
+ videoResolution.defaultResolution = p2p4 ? videoResolutionMode[rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.videoClarity] : videoResolutionMode[rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClarity];
190
+ const supportedVideoClarity = p2p4 ? rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.videoClaritys : rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.vedioClaritys;
183
191
  videoResolution.availableResolutions = supportedVideoClarity.map(mode => videoResolutionMode[mode]);
184
192
 
185
193
  // 4. 最大倍数模块
@@ -226,6 +234,7 @@ export const getCameraConfigInfo = async deviceId => {
226
234
  microphoneSettings = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da2 = microphoneStorage.data) === null || _microphoneStorage$da2 === void 0 ? void 0 : _microphoneStorage$da2.data;
227
235
  maxZoomSettings = maxZoomSettingsStorage === null || maxZoomSettingsStorage === void 0 || (_maxZoomSettingsStora2 = maxZoomSettingsStorage.data) === null || _maxZoomSettingsStora2 === void 0 ? void 0 : _maxZoomSettingsStora2.data;
228
236
  }
237
+ console.log(videoResolution, intercomInfo, microphoneSettings, maxZoomSettings, '_____');
229
238
  const ipcConfig = {
230
239
  videoResolution,
231
240
  intercomInfo,
@@ -238,10 +247,11 @@ export const getCameraConfigInfo = async deviceId => {
238
247
  });
239
248
  } catch (err) {
240
249
  console.log(err, 'err');
241
- ty.showToast({
242
- title: I18n.t('get_ipc_config_info_api_err'),
243
- icon: 'error'
244
- });
250
+ ipcTTTOperatorLog(`UTILS: getCameraConfigInfo_error_info: ${JSON.stringify(err)}`);
251
+ // ty.showToast({
252
+ // title: Strings.getLang('ipc_utils_get_ipc_config_info_api_err'),
253
+ // icon: 'error',
254
+ // });
245
255
  return Promise.resolve({
246
256
  code: -1,
247
257
  msg: err.errorMsg ? err.errorMsg : String(err)
@@ -279,21 +289,21 @@ export const updateCollectionPointsInfo = (deviceId, id, name) => {
279
289
  if (_trim(name) === '') {
280
290
  ty.showToast({
281
291
  icon: 'error',
282
- title: '请输入收藏点名称'
292
+ title: Strings.getLang('ipc_utils_collect_name_empty')
283
293
  });
284
294
  return Promise.resolve({
285
295
  code: -1,
286
- msg: '请输入收藏点名称'
296
+ msg: Strings.getLang('ipc_utils_collect_name_empty')
287
297
  });
288
298
  }
289
299
  if (_trim(name).length > 10) {
290
300
  ty.showToast({
291
301
  icon: 'error',
292
- title: '收藏点名称不能超过10个字符'
302
+ title: Strings.getLang('ipc_utils_collect_name_limit_tip')
293
303
  });
294
304
  return Promise.resolve({
295
305
  code: -1,
296
- msg: '收藏点名称不能超过10个字符'
306
+ msg: Strings.getLang('ipc_utils_collect_name_limit_tip')
297
307
  });
298
308
  }
299
309
  return api(url, {
@@ -322,11 +332,11 @@ export const delCollectionPointsInfo = async (deviceId, pointData) => {
322
332
  }
323
333
  if (cruiseSwitchInfo.data) {
324
334
  ty.showToast({
325
- title: '正在巡航,请先停止巡航'
335
+ title: Strings.getLang('ipc_utils_cruise_ing_tip')
326
336
  });
327
337
  return {
328
338
  code: -1,
329
- msg: '正在巡航,请先停止巡航'
339
+ msg: Strings.getLang('ipc_utils_cruise_ing_tip')
330
340
  };
331
341
  }
332
342
  // 2. 下发DP删除收藏点 dpCode: memory_point_set
@@ -371,11 +381,11 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
371
381
  if (pointsInfo.data.length >= 6) {
372
382
  ty.showToast({
373
383
  icon: 'error',
374
- title: '最多只能添加6个收藏点'
384
+ title: Strings.getLang('ipc_utils_collect_number_max_tip')
375
385
  });
376
386
  return {
377
387
  code: -1,
378
- msg: '最多只能添加6个收藏点'
388
+ msg: Strings.getLang('ipc_utils_collect_number_max_tip')
379
389
  };
380
390
  }
381
391
  const cruiseSwitchInfo = await getDpStateValue(deviceId, 'cruise_switch');
@@ -392,11 +402,11 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
392
402
  if (cruiseSwitchInfo.data) {
393
403
  ty.showToast({
394
404
  icon: 'error',
395
- title: '正在巡航,请先停止巡航'
405
+ title: Strings.getLang('ipc_utils_cruise_ing_tip')
396
406
  });
397
407
  return {
398
408
  code: -1,
399
- msg: '正在巡航,请先停止巡航'
409
+ msg: Strings.getLang('ipc_utils_cruise_ing_tip')
400
410
  };
401
411
  }
402
412
  // 2. 下发DP删除收藏点 dpCode: memory_point_set
@@ -414,21 +424,21 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
414
424
  if (_trim(name) === '') {
415
425
  ty.showToast({
416
426
  icon: 'error',
417
- title: '请输入收藏点名称'
427
+ title: Strings.getLang('ipc_utils_collect_name_empty')
418
428
  });
419
429
  return {
420
430
  code: -1,
421
- msg: '请输入收藏点名称'
431
+ msg: Strings.getLang('ipc_utils_collect_name_empty')
422
432
  };
423
433
  }
424
434
  if (_trim(name).length > 10) {
425
435
  ty.showToast({
426
436
  icon: 'error',
427
- title: '收藏点名称不能超过10个字符'
437
+ title: Strings.getLang('ipc_utils_collect_name_limit_tip')
428
438
  });
429
439
  return {
430
440
  code: -1,
431
- msg: '收藏点名称不能超过10个字符'
441
+ msg: Strings.getLang('ipc_utils_collect_name_limit_tip')
432
442
  };
433
443
  }
434
444
  const publishResult = await publishDps(deviceId, {
@@ -466,6 +476,7 @@ export const getServiceUrl = async function (deviceId, serveType) {
466
476
  let action = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
467
477
  let utm_rtid = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : getInitUtmTid();
468
478
  try {
479
+ var _result$data, _result$data3;
469
480
  const {
470
481
  homeId
471
482
  } = await ty.home.getCurrentHomeInfo();
@@ -507,13 +518,14 @@ export const getServiceUrl = async function (deviceId, serveType) {
507
518
  if (!action) {
508
519
  return result;
509
520
  }
510
- if ((result === null || result === void 0 ? void 0 : result.data.type) === 2) {
521
+ if ((result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.type) === 2) {
522
+ var _result$data2;
511
523
  // 跳转小程序
512
- const minResult = await goToMiniProgramByShortLink(result === null || result === void 0 ? void 0 : result.data.url);
524
+ const minResult = await goToMiniProgramByShortLink(result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.url);
513
525
  return minResult;
514
526
  }
515
527
  // 跳转H5
516
- const webResult = await jumpToWebView(result === null || result === void 0 ? void 0 : result.data.url);
528
+ const webResult = await jumpToWebView(result === null || result === void 0 || (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.url);
517
529
  return webResult;
518
530
  } catch (err) {
519
531
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-utils",
3
- "version": "1.1.0-beta-12",
3
+ "version": "1.1.0-beta-14",
4
4
  "description": "IPC 工具库",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -35,13 +35,13 @@
35
35
  "@ray-js/ray": "^1.4.9"
36
36
  },
37
37
  "dependencies": {
38
- "clsx": "^1.2.1"
38
+ "clsx": "^1.2.1",
39
+ "@ray-js/panel-sdk": "^1.13.1"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@commitlint/cli": "^7.2.1",
42
43
  "@commitlint/config-conventional": "^9.0.1",
43
44
  "@ray-js/cli": "^1.4.9",
44
- "@ray-js/panel-sdk": "^1.13.0-storage.7",
45
45
  "@ray-js/ray": "^1.4.9",
46
46
  "@testing-library/react-hooks": "^8.0.1",
47
47
  "@types/jest": "^29.5.14",