@ray-js/ray-ipc-utils 1.1.3 → 1.1.4

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.
@@ -11,7 +11,7 @@ export declare const getIpcConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>
11
11
  * 包含: 视频清晰度、对讲方式、拾音器、视频缩放最大倍数
12
12
  * @param {string} deviceId 设备id
13
13
  */
14
- export declare const getCameraConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>;
14
+ export declare const getCameraConfigInfo: <T>(deviceId: string, type?: 'mini' | 'native') => Promise<IRes<T>>;
15
15
  /**
16
16
  * 获取IPC设备配置收藏点信息列表
17
17
  * @param {string} deviceId 设备id
@@ -102,7 +102,8 @@ export const getIpcConfigInfo = async deviceId => {
102
102
  * @param {string} deviceId 设备id
103
103
  */
104
104
  // eslint-disable-next-line consistent-return
105
- export const getCameraConfigInfo = async deviceId => {
105
+ export const getCameraConfigInfo = async function (deviceId) {
106
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'native';
106
107
  try {
107
108
  const devInfo = await getDevInfo(deviceId);
108
109
  if (devInfo.code !== 0) {
@@ -111,6 +112,7 @@ export const getCameraConfigInfo = async deviceId => {
111
112
  const {
112
113
  isVirtualDevice
113
114
  } = devInfo === null || devInfo === void 0 ? void 0 : devInfo.data;
115
+ console.log(isVirtualDevice, 'isVirtualDevice----');
114
116
  ipcTTTOperatorLog(`Utils: config info isVirtualDevice status: ${isVirtualDevice}`);
115
117
  // 配置默认值
116
118
  const defaultResolution = ClarityType.HD;
@@ -139,13 +141,15 @@ export const getCameraConfigInfo = async deviceId => {
139
141
 
140
142
  const nativeStorageInfo = await Promise.all([`${deviceId}_resolution`, `${deviceId}_intercom`, `${deviceId}_microphone`, `${deviceId}_maxZoomSettings`].map(key => getNativeStorage(key)));
141
143
  ipcTTTOperatorLog(`Utils: nativeStorageInfo: ${nativeStorageInfo}`);
142
- console.log(nativeStorageInfo, 'nativeStorageInfo');
144
+ console.log(nativeStorageInfo, 'dsahdsahkdh');
143
145
  const [resolutionStorage, intercomStorage, microphoneStorage, maxZoomSettingsStorage] = nativeStorageInfo;
144
146
  // 任意缓存为空,则请求接口
145
- if (nativeStorageInfo.some(item => {
147
+
148
+ const noCache = nativeStorageInfo.some(item => {
146
149
  var _item$data;
147
150
  return !(item !== null && item !== void 0 && (_item$data = item.data) !== null && _item$data !== void 0 && _item$data.data);
148
- })) {
151
+ });
152
+ if (noCache) {
149
153
  // 非虚拟机设备,请求接口
150
154
  if (!isVirtualDevice) {
151
155
  var _microphoneStorage$da, _intercomStorage$data, _resolutionStorage$da, _maxZoomSettingsStora;
@@ -175,12 +179,18 @@ export const getCameraConfigInfo = async deviceId => {
175
179
  intercomInfo.defaultIntercomMode = intercomCallMode[supportedIntercomModes[0]];
176
180
  intercomInfo.supportedIntercomModes = supportedIntercomModes.map(mode => intercomCallMode[mode]);
177
181
  // 获取APP当前存储的对讲模式, 因目前设置页对讲设置使用的还是原生页面,需要读取APP缓存保持一致
178
- const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
179
- if (appIntercomCached.code !== 0) {
180
- intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
182
+
183
+ if (type === 'native') {
184
+ const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
185
+ if (appIntercomCached.code !== 0) {
186
+ intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
187
+ } else {
188
+ var _appIntercomCached$da;
189
+ intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
190
+ }
181
191
  } 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];
192
+ // 针对mini程序,直接使用接口返回的第一项数据
193
+ intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
184
194
  }
185
195
  }
186
196
 
@@ -192,6 +202,7 @@ export const getCameraConfigInfo = async deviceId => {
192
202
  // 4. 最大倍数模块
193
203
  maxZoomSettings = (rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes) !== 0 ? rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes : 6;
194
204
  }
205
+
195
206
  // 由于utils为统一返回,多加了一层data,所以需要取data.data
196
207
  // 1. 设置拾音器缓存
197
208
  const microphoneStorageData = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da = microphoneStorage.data) === null || _microphoneStorage$da === void 0 ? void 0 : _microphoneStorage$da.data;
@@ -215,27 +226,43 @@ export const getCameraConfigInfo = async deviceId => {
215
226
  if (!maxZoomSettingsStorageData) {
216
227
  setNativeStorage(`${deviceId}_maxZoomSettings`, maxZoomSettings);
217
228
  }
229
+ } else {
230
+ // 针对虚拟设备未有数据时设置缓存
231
+ setNativeStorage(`${deviceId}_microphone`, microphoneSettings);
232
+ if (type === 'native') {
233
+ const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
234
+ // 如果接口返回成功,则取接口返回值
235
+ if (appIntercomCached.code === 0) {
236
+ var _appIntercomCached$da2;
237
+ intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da2 = appIntercomCached.data) === null || _appIntercomCached$da2 === void 0 ? void 0 : _appIntercomCached$da2.talkbackMode];
238
+ }
239
+ }
240
+ setNativeStorage(`${deviceId}_intercom`, intercomInfo);
241
+ setNativeStorage(`${deviceId}_resolution`, videoResolution);
242
+ setNativeStorage(`${deviceId}_maxZoomSettings`, maxZoomSettings);
218
243
  }
219
244
  } else {
220
245
  var _intercomStorage$data2, _resolutionStorage$da2, _microphoneStorage$da2, _maxZoomSettingsStora2;
246
+ // 都有缓存的情况下,直接返回取缓存
221
247
  // 对于对讲缓存的方式每次需从APP获取更新
222
248
  const intercomStorageData = intercomStorage === null || intercomStorage === void 0 || (_intercomStorage$data2 = intercomStorage.data) === null || _intercomStorage$data2 === void 0 ? void 0 : _intercomStorage$data2.data;
223
249
  intercomInfo = intercomStorageData;
224
- const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
225
- if (appIntercomCached.code !== 0) {
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];
230
- }
231
- if (intercomStorageData.cachedIntercomMode !== intercomInfo.cachedIntercomMode) {
232
- setNativeStorage(`${deviceId}_intercom`, intercomInfo);
250
+ if (type === 'native') {
251
+ const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
252
+ if (appIntercomCached.code !== 0) {
253
+ intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
254
+ } else {
255
+ var _appIntercomCached$da3;
256
+ intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da3 = appIntercomCached.data) === null || _appIntercomCached$da3 === void 0 ? void 0 : _appIntercomCached$da3.talkbackMode];
257
+ }
258
+ if (intercomStorageData.cachedIntercomMode !== intercomInfo.cachedIntercomMode) {
259
+ setNativeStorage(`${deviceId}_intercom`, intercomInfo);
260
+ }
233
261
  }
234
262
  videoResolution = resolutionStorage === null || resolutionStorage === void 0 || (_resolutionStorage$da2 = resolutionStorage.data) === null || _resolutionStorage$da2 === void 0 ? void 0 : _resolutionStorage$da2.data;
235
263
  microphoneSettings = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da2 = microphoneStorage.data) === null || _microphoneStorage$da2 === void 0 ? void 0 : _microphoneStorage$da2.data;
236
264
  maxZoomSettings = maxZoomSettingsStorage === null || maxZoomSettingsStorage === void 0 || (_maxZoomSettingsStora2 = maxZoomSettingsStorage.data) === null || _maxZoomSettingsStora2 === void 0 ? void 0 : _maxZoomSettingsStora2.data;
237
265
  }
238
- console.log(videoResolution, intercomInfo, microphoneSettings, maxZoomSettings, '_____');
239
266
  const ipcConfig = {
240
267
  videoResolution,
241
268
  intercomInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-utils",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "IPC 工具库",
5
5
  "main": "lib/index",
6
6
  "files": [