@ray-js/ray-ipc-utils 1.1.0-beta-3 → 1.1.0-beta-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.
package/lib/index.d.ts CHANGED
@@ -1,42 +1,37 @@
1
1
  declare const IpcUtils: {
2
- getCameraConfigInfo: (deviceId: string) => Promise<import("./interface").IpcConfigInfo>;
3
- getCollectionPointsInfo: (deviceId: string) => Promise<any>;
4
- updateCollectionPointsInfo: (deviceId: string, id: number, name: string) => Promise<any>;
5
- delCollectionPointsInfo: (deviceId: string, pointData: [{
2
+ getCameraConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>;
3
+ getCollectionPointsInfo: <T_1>(deviceId: string) => Promise<IRes<T_1>>;
4
+ updateCollectionPointsInfo: <T_2>(deviceId: string, id: number, name: string) => Promise<IRes<T_2>>;
5
+ delCollectionPointsInfo: <T_3>(deviceId: string, pointData: [{
6
6
  devId: string;
7
7
  mpId: number;
8
- }]) => Promise<import("./kit/interface").IRes>;
9
- addCollectionPointsInfo: (deviceId: string, name: string) => Promise<any>;
10
- getServiceUrl: (deviceId: string, serveType: import("./interface").ServeTpe, paramData?: Record<string, any>, action?: boolean, utm_rtid?: string) => Promise<{
11
- code: number;
12
- msg?: string | undefined;
13
- url?: string | undefined;
14
- type?: number | undefined;
15
- }>;
8
+ }]) => Promise<IRes<T_3>>;
9
+ addCollectionPointsInfo: <T_4>(deviceId: string, name: string) => Promise<IRes<T_4>>;
10
+ getServiceUrl: <T_5>(deviceId: string, serveType: import("./interface").ServeTpe, paramData?: Record<string, any>, action?: boolean, utm_rtid?: string) => Promise<IRes<T_5>>;
16
11
  JsonUtil: any;
17
12
  getInitUtmTid: () => string;
18
- getDevInfo: <T>(deviceId: string) => Promise<import("./kit/interface").IRes>;
19
- getNativeStorage: <T_1>(key: string) => Promise<import("./kit/interface").IRes>;
20
- setNativeStorage: <T_2>(key: string, data: T_2) => Promise<import("./kit/interface").IRes>;
21
- removeNativeStorage: <T_3>(key: string) => Promise<import("./kit/interface").IRes>;
22
- publishDps: <T_4>(deviceId: string, dps: T_4) => Promise<import("./kit/interface").IRes>;
23
- getDpStateValue: (deviceId: string, dpCode: string) => Promise<import("./kit/interface").IRes>;
24
- getDpIdByCode: (deviceId: string, dpCode: string) => Promise<import("./kit/interface").IRes>;
25
- goToMiniProgramByShortLink: <T_5>(url: string, position?: string) => Promise<import("./kit/interface").IRes>;
26
- getVideoBitrateKbps: <T_6>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes>;
13
+ getDevInfo: <T_6>(deviceId: string) => Promise<import("./kit/interface").IRes<T_6>>;
14
+ getNativeStorage: <T_7>(key: string) => Promise<import("./kit/interface").IRes<T_7>>;
15
+ setNativeStorage: <T_8>(key: string, data: T_8) => Promise<import("./kit/interface").IRes<T_8>>;
16
+ removeNativeStorage: <T_9>(key: string) => Promise<import("./kit/interface").IRes<T_9>>;
17
+ publishDps: <T_10>(deviceId: string, dps: any) => Promise<import("./kit/interface").IRes<T_10>>;
18
+ getDpStateValue: (deviceId: string, dpCode: string) => Promise<import("./kit/interface").IRes<T>>;
19
+ getDpIdByCode: (deviceId: string, dpCode: string) => Promise<import("./kit/interface").IRes<T>>;
20
+ goToMiniProgramByShortLink: <T_11>(url: string, position?: string) => Promise<import("./kit/interface").IRes<T_11>>;
21
+ getVideoBitrateKbps: <T_12>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_12>>;
27
22
  networkStatusDidChangedEvent: (callback: any) => void;
28
- getMobileOrientation: <T_7>() => Promise<import("./kit/interface").IRes>;
29
- jumpToWebView: <T_8>(url: string) => Promise<import("./kit/interface").IRes>;
30
- setScreenOrientation: <T_9>(pageOrientation: string) => Promise<import("./kit/interface").IRes>;
31
- isSupportFloatWindow: <T_10>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes>;
32
- openFloatWindow: <T_11>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes>;
33
- isSupportedTalk: <T_12>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes>;
34
- getCurrentSupportedTalkMode: <T_13>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes>;
23
+ getMobileOrientation: <T_13>() => Promise<import("./kit/interface").IRes<T_13>>;
24
+ jumpToWebView: <T_14>(url: string) => Promise<import("./kit/interface").IRes<T_14>>;
25
+ setScreenOrientation: <T_15>(pageOrientation: string) => Promise<import("./kit/interface").IRes<T_15>>;
26
+ isSupportFloatWindow: <T_16>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_16>>;
27
+ openFloatWindow: <T_17>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_17>>;
28
+ isSupportedTalk: <T_18>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_18>>;
29
+ getCurrentSupportedTalkMode: <T_19>(deviceId: string, extendParam?: {}) => Promise<import("./kit/interface").IRes<T_19>>;
35
30
  goToIpcPageNativeRoute: (url: string, deviceId: string, theme?: "dark" | "light", extraParams?: {
36
31
  [key: string]: any;
37
- } | undefined, isGeneral?: false | undefined) => Promise<import("./kit/interface").IRes>;
38
- goToGeneralHelpMini: () => Promise<import("./kit/interface").IRes>;
39
- goToIpcHelpMini: (errCode: number, deviceId: string, helpNum: number, helpFeedBack: boolean, brandColor?: string) => Promise<import("./kit/interface").IRes>;
32
+ } | undefined, isGeneral?: false | undefined) => Promise<import("./kit/interface").IRes<T>>;
33
+ goToGeneralHelpMini: () => Promise<import("./kit/interface").IRes<T>>;
34
+ goToIpcHelpMini: (errCode: number, deviceId: string, helpNum: number, helpFeedBack: boolean, brandColor?: string) => Promise<import("./kit/interface").IRes<T>>;
40
35
  getIsSupprtedCloudStorageSync: (deviceId: string) => Promise<{
41
36
  code: number;
42
37
  data: boolean;
@@ -46,8 +41,8 @@ declare const IpcUtils: {
46
41
  data: boolean;
47
42
  msg: string | boolean | import("./kit/interface").IApiError | undefined;
48
43
  }>;
49
- requestWifiSignal: <T_14>(deviceId: string, dps?: {}) => Promise<import("./kit/interface").IRes>;
50
- wakeUpDevice: <T_15>(deviceId: string, dps?: {}) => Promise<import("./kit/interface").IRes>;
44
+ requestWifiSignal: <T_20>(deviceId: string, dps?: {}) => Promise<any>;
45
+ wakeUpDevice: <T_21>(deviceId: string, dps?: {}) => Promise<any>;
51
46
  useTrafficViewTip: () => boolean;
52
47
  };
53
48
  export default IpcUtils;
@@ -6,8 +6,8 @@ export interface IApiError {
6
6
  errorCode: string | number;
7
7
  };
8
8
  }
9
- export interface IRes {
9
+ export interface IRes<T> {
10
10
  code?: number;
11
- data?: any;
11
+ data?: T;
12
12
  msg?: IApiError | string | boolean;
13
13
  }
@@ -4,99 +4,99 @@ import { IRes } from '../interface';
4
4
  * @param deviceId 设备id
5
5
  * @returns 获取设备信息
6
6
  */
7
- export declare const getDevInfo: <T>(deviceId: string) => Promise<IRes>;
7
+ export declare const getDevInfo: <T>(deviceId: string) => Promise<IRes<T>>;
8
8
  /**
9
9
  * 获取本地缓存
10
10
  * @param key 保存的key属性
11
11
  *
12
12
  */
13
- export declare const getNativeStorage: <T>(key: string) => Promise<IRes>;
13
+ export declare const getNativeStorage: <T>(key: string) => Promise<IRes<T>>;
14
14
  /**
15
15
  * 存储数据到本地缓存
16
16
  * @param key 保存的key属性
17
17
  *
18
18
  */
19
- export declare const setNativeStorage: <T>(key: string, data: T) => Promise<IRes>;
19
+ export declare const setNativeStorage: <T>(key: string, data: T) => Promise<IRes<T>>;
20
20
  /**
21
21
  * 清除本地缓存
22
22
  * @param key 保存的key属性
23
23
  *
24
24
  */
25
- export declare const removeNativeStorage: <T>(key: string) => Promise<IRes>;
25
+ export declare const removeNativeStorage: <T>(key: string) => Promise<IRes<T>>;
26
26
  /**
27
27
  * DP点下发, 包含针对低功耗设备情况下的DP点下发
28
28
  * @param key 保存的key属性
29
29
  *
30
30
  */
31
- export declare const publishDps: <T>(deviceId: string, dps: T) => Promise<IRes>;
31
+ export declare const publishDps: <T>(deviceId: string, dps: any) => Promise<IRes<T>>;
32
32
  /**
33
33
  * 根据DPCode获取最新的DP点的值
34
34
  * @param key 保存的key属性
35
35
  *
36
36
  */
37
- export declare const getDpStateValue: (deviceId: string, dpCode: string) => Promise<IRes>;
37
+ export declare const getDpStateValue: (deviceId: string, dpCode: string) => Promise<IRes<T>>;
38
38
  /**
39
39
  * 根据DPCode获取DpId
40
40
  * @param key 保存的key属性
41
41
  *
42
42
  */
43
- export declare const getDpIdByCode: (deviceId: string, dpCode: string) => Promise<IRes>;
43
+ export declare const getDpIdByCode: (deviceId: string, dpCode: string) => Promise<IRes<T>>;
44
44
  /**
45
45
  * 通过短链形式跳转小程序
46
46
  * @param url 小程序链接
47
47
  * @param position 弹出位置 bottom|right
48
48
  *
49
49
  */
50
- export declare const goToMiniProgramByShortLink: <T>(url: string, position?: string) => Promise<IRes>;
50
+ export declare const goToMiniProgramByShortLink: <T>(url: string, position?: string) => Promise<IRes<T>>;
51
51
  /**
52
52
  * 获取视频码率
53
53
  * @param deviceId
54
54
  * @param extendParam 扩展参数
55
55
  * @returns
56
56
  */
57
- export declare const getVideoBitrateKbps: <T>(deviceId: string, extendParam?: {}) => Promise<IRes>;
57
+ export declare const getVideoBitrateKbps: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
58
58
  export declare const networkStatusDidChangedEvent: (callback: any) => void;
59
59
  /**
60
60
  * 获取手机当前横竖屏状态
61
61
  * 需引入IPCKit,且在>=1.0.0-TTT432.1版本才可使用
62
62
  * @returns
63
63
  */
64
- export declare const getMobileOrientation: <T>() => Promise<IRes>;
64
+ export declare const getMobileOrientation: <T>() => Promise<IRes<T>>;
65
65
  /**
66
66
  * 跳转到webView
67
67
  * @param key 保存的key属性
68
68
  *
69
69
  */
70
- export declare const jumpToWebView: <T>(url: string) => Promise<IRes>;
71
- export declare const setScreenOrientation: <T>(pageOrientation: string) => Promise<IRes>;
70
+ export declare const jumpToWebView: <T>(url: string) => Promise<IRes<T>>;
71
+ export declare const setScreenOrientation: <T>(pageOrientation: string) => Promise<IRes<T>>;
72
72
  /**
73
73
  * 画中画:是否支持画中画:只有安卓在用
74
74
  * @param deviceId
75
75
  * @param extendParam 扩展参数
76
76
  * @returns
77
77
  */
78
- export declare const isSupportFloatWindow: <T>(deviceId: string, extendParam?: {}) => Promise<IRes>;
78
+ export declare const isSupportFloatWindow: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
79
79
  /**
80
80
  * 画中画:开启画中画
81
81
  * @param deviceId
82
82
  * @param extendParam 扩展参数
83
83
  * @returns
84
84
  */
85
- export declare const openFloatWindow: <T>(deviceId: string, extendParam?: {}) => Promise<IRes>;
85
+ export declare const openFloatWindow: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
86
86
  /**
87
87
  * IPC-APP 缓存支持的对讲方式:是否支持对讲
88
88
  * @param deviceId
89
89
  * @param extendParam 扩展参数
90
90
  * @returns
91
91
  */
92
- export declare const isSupportedTalk: <T>(deviceId: string, extendParam?: {}) => Promise<IRes>;
92
+ export declare const isSupportedTalk: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
93
93
  /**
94
94
  * 设备支持的对讲模式
95
95
  * @param deviceId
96
96
  * @param extendParam 扩展参数
97
97
  * @returns 设备支持的对讲模式。回掉方法的参数为数值型,0 未知;1:单向对讲;2:双向对讲。
98
98
  */
99
- export declare const getCurrentSupportedTalkMode: <T>(deviceId: string, extendParam?: {}) => Promise<IRes>;
99
+ export declare const getCurrentSupportedTalkMode: <T>(deviceId: string, extendParam?: {}) => Promise<IRes<T>>;
100
100
  /**
101
101
  * 跳转 APP 原生页面
102
102
  * @param {string} url 页面路由
@@ -108,11 +108,11 @@ export declare const getCurrentSupportedTalkMode: <T>(deviceId: string, extendPa
108
108
  */
109
109
  export declare const goToIpcPageNativeRoute: (url: string, deviceId: string, theme?: 'dark' | 'light', extraParams?: {
110
110
  [key: string]: any;
111
- } | undefined, isGeneral?: false) => Promise<IRes>;
111
+ } | undefined, isGeneral?: false) => Promise<IRes<T>>;
112
112
  /**
113
113
  * 跳转 通用帮助反馈小程序
114
114
  */
115
- export declare const goToGeneralHelpMini: () => Promise<IRes>;
115
+ export declare const goToGeneralHelpMini: () => Promise<IRes<T>>;
116
116
  /**
117
117
  * 跳转 Ipc帮助反馈小程序
118
118
  * @param {number} errCode 错误码
@@ -121,7 +121,7 @@ export declare const goToGeneralHelpMini: () => Promise<IRes>;
121
121
  * @param {boolean} helpFeedBack 是否是反馈
122
122
  * @param {string} brandColor 品牌色
123
123
  */
124
- export declare const goToIpcHelpMini: (errCode: number, deviceId: string, helpNum: number, helpFeedBack: boolean, brandColor?: string) => Promise<IRes>;
124
+ export declare const goToIpcHelpMini: (errCode: number, deviceId: string, helpNum: number, helpFeedBack: boolean, brandColor?: string) => Promise<IRes<T>>;
125
125
  /**
126
126
  *
127
127
  * @param deviceId 设备id
@@ -563,7 +563,7 @@ export const getCurrentSupportedTalkMode = function (deviceId) {
563
563
  /**
564
564
  * 处理 IPC URL 跳转
565
565
  * @param {string} nativeUrl - 构建好的目标 URL。
566
- * @returns {Promise<IRes>} 返回操作结果。
566
+ * @returns {Promise<IRes<T>>} 返回操作结果。
567
567
  */
568
568
  const handleIpcUrl = nativeUrl => {
569
569
  return new Promise(resolve => {
@@ -595,7 +595,7 @@ const handleIpcUrl = nativeUrl => {
595
595
  /**
596
596
  * 处理通用 URL 跳转
597
597
  * @param {string} nativeUrl - 目标url。
598
- * @returns {Promise<IRes>} 返回操作结果。
598
+ * @returns {Promise<IRes<T>>} 返回操作结果。
599
599
  */
600
600
  const handleGeneralUrl = nativeUrl => {
601
601
  return new Promise(resolve => {
@@ -1,35 +1,36 @@
1
- import { IpcConfigInfo, ServeTpe } from '../interface';
1
+ import { ServeTpe } from '../interface';
2
+ import { IRes } from '@/kit/interface';
2
3
  /**
3
4
  * 获取IPC设备配置及缓存信息、
4
5
  * 包含: 视频清晰度、对讲方式、拾音器、视频缩放最大倍数
5
6
  * @param {string} deviceId 设备id
6
7
  */
7
- export declare const getCameraConfigInfo: (deviceId: string) => Promise<IpcConfigInfo>;
8
+ export declare const getCameraConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>;
8
9
  /**
9
10
  * 获取IPC设备配置收藏点信息列表
10
11
  * @param {string} deviceId 设备id
11
12
  */
12
- export declare const getCollectionPointsInfo: (deviceId: string) => Promise<any>;
13
+ export declare const getCollectionPointsInfo: <T>(deviceId: string) => Promise<IRes<T>>;
13
14
  /**
14
15
  * 更新IPC设备单个收藏点信息
15
16
  * @param {string} deviceId 设备id
16
17
  * @param {number} id 收藏点id
17
18
  * @param {string} name 收藏点名称
18
19
  */
19
- export declare const updateCollectionPointsInfo: (deviceId: string, id: number, name: string) => Promise<any>;
20
+ export declare const updateCollectionPointsInfo: <T>(deviceId: string, id: number, name: string) => Promise<IRes<T>>;
20
21
  /**
21
22
  * 删除IPC设备单个收藏点信息
22
23
  * @param {string} deviceId 设备id
23
24
  */
24
- export declare const delCollectionPointsInfo: (deviceId: string, pointData: [{
25
+ export declare const delCollectionPointsInfo: <T>(deviceId: string, pointData: [{
25
26
  devId: string;
26
27
  mpId: number;
27
- }]) => Promise<import("../kit/interface").IRes>;
28
+ }]) => Promise<IRes<T>>;
28
29
  /**
29
30
  * 添加IPC设备单个收藏点信息
30
31
  * @param {string} deviceId 设备id
31
32
  */
32
- export declare const addCollectionPointsInfo: (deviceId: string, name: string) => Promise<any>;
33
+ export declare const addCollectionPointsInfo: <T>(deviceId: string, name: string) => Promise<IRes<T>>;
33
34
  /**
34
35
  * 获取增值服务大类链接及是否直接跳转
35
36
  * @param {string} deviceId 设备id
@@ -39,9 +40,4 @@ export declare const addCollectionPointsInfo: (deviceId: string, name: string) =
39
40
  * @param {string} utm_rtid 链路ID
40
41
  *
41
42
  */
42
- export declare const getServiceUrl: (deviceId: string, serveType: ServeTpe, paramData?: Record<string, any>, action?: boolean, utm_rtid?: string) => Promise<{
43
- code: number;
44
- msg?: string;
45
- url?: string;
46
- type?: number;
47
- }>;
43
+ export declare const getServiceUrl: <T>(deviceId: string, serveType: ServeTpe, paramData?: Record<string, any>, action?: boolean, utm_rtid?: string) => Promise<IRes<T>>;
@@ -66,7 +66,10 @@ const api = function (a, postData) {
66
66
  }), {}, {
67
67
  success: d => {
68
68
  const data = typeof d === 'string' ? JsonUtil.parseJSON(d) : d;
69
- resolve(data);
69
+ resolve({
70
+ code: 0,
71
+ data: data
72
+ });
70
73
  },
71
74
  fail: err => {
72
75
  const e = typeof err === 'string' ? JsonUtil.parseJSON(err) : err;
@@ -220,16 +223,19 @@ export const getCameraConfigInfo = async deviceId => {
220
223
  microphoneSettings,
221
224
  maxZoomSettings
222
225
  };
223
- return ipcConfig;
226
+ return Promise.resolve({
227
+ code: 0,
228
+ data: ipcConfig
229
+ });
224
230
  } catch (err) {
225
231
  ty.showToast({
226
232
  title: I18n.t('get_ipc_config_info_api_err'),
227
233
  icon: 'error'
228
234
  });
229
- return {
235
+ return Promise.resolve({
230
236
  code: -1,
231
237
  msg: String(err)
232
- };
238
+ });
233
239
  }
234
240
  };
235
241
 
@@ -265,20 +271,20 @@ export const updateCollectionPointsInfo = (deviceId, id, name) => {
265
271
  icon: 'error',
266
272
  title: '请输入收藏点名称'
267
273
  });
268
- return {
274
+ return Promise.resolve({
269
275
  code: -1,
270
276
  msg: '请输入收藏点名称'
271
- };
277
+ });
272
278
  }
273
279
  if (_trim(name).length > 10) {
274
280
  ty.showToast({
275
281
  icon: 'error',
276
282
  title: '收藏点名称不能超过10个字符'
277
283
  });
278
- return {
284
+ return Promise.resolve({
279
285
  code: -1,
280
286
  msg: '收藏点名称不能超过10个字符'
281
- };
287
+ });
282
288
  }
283
289
  return api(url, {
284
290
  devId: deviceId,
@@ -339,7 +345,10 @@ export const delCollectionPointsInfo = async (deviceId, pointData) => {
339
345
  title: publishResult.msg
340
346
  });
341
347
  }
342
- return publishResult;
348
+ return Promise.resolve({
349
+ code: 0,
350
+ data: publishResult
351
+ });
343
352
  };
344
353
 
345
354
  /**
@@ -426,7 +435,10 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
426
435
  title: publishResult.msg
427
436
  });
428
437
  }
429
- return publishResult;
438
+ return {
439
+ code: 0,
440
+ data: publishResult.data
441
+ };
430
442
  };
431
443
 
432
444
  /**
@@ -485,13 +497,13 @@ export const getServiceUrl = async function (deviceId, serveType) {
485
497
  if (!action) {
486
498
  return result;
487
499
  }
488
- if ((result === null || result === void 0 ? void 0 : result.type) === 2) {
500
+ if ((result === null || result === void 0 ? void 0 : result.data.type) === 2) {
489
501
  // 跳转小程序
490
- const minResult = await goToMiniProgramByShortLink(result === null || result === void 0 ? void 0 : result.url);
502
+ const minResult = await goToMiniProgramByShortLink(result === null || result === void 0 ? void 0 : result.data.url);
491
503
  return minResult;
492
504
  }
493
505
  // 跳转H5
494
- const webResult = await jumpToWebView(result === null || result === void 0 ? void 0 : result.url);
506
+ const webResult = await jumpToWebView(result === null || result === void 0 ? void 0 : result.data.url);
495
507
  return webResult;
496
508
  } catch (err) {
497
509
  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-3",
3
+ "version": "1.1.0-beta-4",
4
4
  "description": "IPC 工具库",
5
5
  "main": "lib/index",
6
6
  "files": [