@ray-js/ipc-player-integration 0.0.1-beta-32 → 0.0.1-beta-34

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.
Files changed (77) hide show
  1. package/lib/ctx/ctx.composition.d.ts +9 -0
  2. package/lib/ctx/ctx.composition.js +10 -9
  3. package/lib/ctx/ctx.js +57 -16
  4. package/lib/hooks/index.d.ts +1 -0
  5. package/lib/hooks/index.js +2 -1
  6. package/lib/hooks/useDpState/useDpState.d.ts +6 -1
  7. package/lib/hooks/useDpState/useDpState.js +33 -5
  8. package/lib/hooks/useMemoizedFn/index.d.ts +1 -0
  9. package/lib/hooks/useMemoizedFn/index.js +1 -0
  10. package/lib/iconfont/iconfont.css +67 -8
  11. package/lib/iconfont/iconfont.js +13 -13
  12. package/lib/iconfont/iconfont.json +112 -7
  13. package/lib/iconfont/iconfont.ttf +0 -0
  14. package/lib/iconfont/iconfont.woff +0 -0
  15. package/lib/iconfont/iconfont.woff2 +0 -0
  16. package/lib/interface.d.ts +9 -9
  17. package/lib/plugins/battery/battery.composition.d.ts +14 -18
  18. package/lib/plugins/battery/battery.js +2 -2
  19. package/lib/plugins/battery/battery.less +3 -3
  20. package/lib/plugins/fullScreen/constant.d.ts +1 -0
  21. package/lib/plugins/fullScreen/constant.js +1 -0
  22. package/lib/plugins/fullScreen/fullScreen.d.ts +3 -1
  23. package/lib/plugins/fullScreen/fullScreen.js +49 -32
  24. package/lib/plugins/fullScreen/fullScreen.less +6 -1
  25. package/lib/plugins/fullScreen/fullTravelRouteControl.d.ts +8 -0
  26. package/lib/plugins/fullScreen/fullTravelRouteControl.js +73 -0
  27. package/lib/plugins/fullScreen/fullVoiceIntercom.d.ts +3 -0
  28. package/lib/plugins/fullScreen/fullVoiceIntercom.js +22 -13
  29. package/lib/plugins/fullScreen/verticalScreen.d.ts +1 -0
  30. package/lib/plugins/fullSmallIntercom/fullSmallIntercom.d.ts +3 -1
  31. package/lib/plugins/fullSmallIntercom/fullSmallIntercom.js +2 -4
  32. package/lib/plugins/index.d.ts +1 -0
  33. package/lib/plugins/index.js +2 -1
  34. package/lib/plugins/moveInteractiveControl/controlButton.d.ts +8 -0
  35. package/lib/plugins/moveInteractiveControl/controlButton.js +44 -0
  36. package/lib/plugins/moveInteractiveControl/controlButton.less +4 -0
  37. package/lib/plugins/moveInteractiveControl/index.d.ts +2 -0
  38. package/lib/plugins/moveInteractiveControl/index.js +2 -0
  39. package/lib/plugins/moveInteractiveControl/moveInteractiveControl.d.ts +6 -0
  40. package/lib/plugins/moveInteractiveControl/moveInteractiveControl.js +50 -0
  41. package/lib/plugins/moveInteractiveControl/moveInteractiveControl.less +38 -0
  42. package/lib/plugins/moveInteractiveControl/moveInteractiveControlUI.d.ts +28 -0
  43. package/lib/plugins/moveInteractiveControl/moveInteractiveControlUI.js +103 -0
  44. package/lib/plugins/moveInteractiveControl/moveInteractiveControlUI.less +71 -0
  45. package/lib/plugins/ptz/ptz.d.ts +5 -1
  46. package/lib/plugins/ptz/ptz.js +21 -7
  47. package/lib/plugins/ptz/ptz.less +26 -6
  48. package/lib/plugins/ptz/ptzControl.js +16 -7
  49. package/lib/plugins/resolution/fullResolutionControl.js +26 -12
  50. package/lib/plugins/resolution/resolution.d.ts +8 -2
  51. package/lib/plugins/resolution/resolution.js +25 -23
  52. package/lib/plugins/resolution/resolution.less +13 -2
  53. package/lib/plugins/verticalSmallIntercom/verticalSmallIntercom.d.ts +3 -1
  54. package/lib/plugins/verticalSmallIntercom/verticalSmallIntercom.js +0 -1
  55. package/lib/plugins/videoBitKBP/videoBitKBP.d.ts +3 -1
  56. package/lib/ui/bottomLeftContent.js +5 -7
  57. package/lib/ui/bottomRightContent.js +5 -7
  58. package/lib/ui/constant.d.ts +1 -0
  59. package/lib/ui/constant.js +1 -0
  60. package/lib/ui/context.d.ts +1 -0
  61. package/lib/ui/context.js +2 -1
  62. package/lib/ui/hooks.d.ts +1 -1
  63. package/lib/ui/hooks.js +3 -21
  64. package/lib/ui/index.d.ts +1 -0
  65. package/lib/ui/topLeftContent.d.ts +2 -2
  66. package/lib/ui/topLeftContent.js +6 -8
  67. package/lib/ui/topRightContent.js +5 -7
  68. package/lib/ui/ui.d.ts +2 -0
  69. package/lib/ui/ui.js +57 -40
  70. package/lib/ui/ui.less +49 -12
  71. package/lib/utils/device/index.d.ts +4 -0
  72. package/lib/utils/device/index.js +27 -1
  73. package/lib/utils/plugins/index.d.ts +4 -0
  74. package/lib/utils/plugins/index.js +20 -0
  75. package/package.json +7 -2
  76. package/lib/iconfont/demo.css +0 -539
  77. package/lib/iconfont/demo_index.html +0 -1062
@@ -1 +1,10 @@
1
+ import { FullScreen } from '../plugins';
2
+ import { ComponentConfig } from '../interface';
3
+ export declare const defaultTopLeftContent: ComponentConfig[];
4
+ export declare const defaultTopRightContent: ComponentConfig[];
5
+ export declare const defaultBottomLeftContent: ComponentConfig[];
6
+ export declare const defaultBottomRightContent: {
7
+ id: string;
8
+ content: typeof FullScreen;
9
+ }[];
1
10
  export declare const useCtx: import("../interface").UseCtx;
@@ -9,11 +9,11 @@ import { authorizeStatus } from '../utils/authorize';
9
9
  const createPlayContext = ty.createIpcPlayerContext;
10
10
  // const createPlayContext = () => null;
11
11
 
12
- const topLeftContent = [{
12
+ export const defaultTopLeftContent = [{
13
13
  id: 'Battery',
14
14
  content: Battery
15
15
  }];
16
- const topRightContent = [{
16
+ export const defaultTopRightContent = [{
17
17
  id: 'BatteryFull',
18
18
  content: BatteryFull
19
19
  }, {
@@ -23,9 +23,10 @@ const topRightContent = [{
23
23
  id: 'VideoBitKBP',
24
24
  content: VideoBitKBP
25
25
  }];
26
- const bottomLeftContent = [{
26
+ export const defaultBottomLeftContent = [{
27
27
  id: 'FullSmallIntercom',
28
- content: FullSmallIntercom
28
+ content: FullSmallIntercom,
29
+ hidden: true
29
30
  }, {
30
31
  id: 'Screenshot',
31
32
  content: Screenshot
@@ -45,7 +46,7 @@ const bottomLeftContent = [{
45
46
  id: 'Resolution',
46
47
  content: Resolution
47
48
  }];
48
- const bottomRightContent = [{
49
+ export const defaultBottomRightContent = [{
49
50
  id: 'FullScreen',
50
51
  content: FullScreen
51
52
  }];
@@ -105,10 +106,10 @@ const setMuteMemoryState = (devId, value) => {
105
106
  };
106
107
  export const useCtx = createUseCtx({
107
108
  createPlayContext,
108
- defaultTopLeftContent: topLeftContent,
109
- defaultTopRightContent: topRightContent,
110
- defaultBottomLeftContent: bottomLeftContent,
111
- defaultBottomRightContent: bottomRightContent,
109
+ defaultTopLeftContent: [],
110
+ defaultTopRightContent: [],
111
+ defaultBottomLeftContent: [],
112
+ defaultBottomRightContent: [],
112
113
  defaultAbsoluteContent: absoluteContent,
113
114
  authorizeStatus: authorizeStatus,
114
115
  toast,
package/lib/ctx/ctx.js CHANGED
@@ -46,9 +46,6 @@ export const createUseCtx = _ref => {
46
46
  // 竖屏下是否展示对讲, 默认展示
47
47
  const [verticalMic, setVerticalMic] = useAtom(true);
48
48
 
49
- // ptz 是否点击
50
- const [ptzActive, setPtzActive] = useAtom(false);
51
-
52
49
  // resolution 当前清晰度
53
50
  const [resolution] = useAtom('HD');
54
51
  // resolution 清晰度列表
@@ -57,9 +54,6 @@ export const createUseCtx = _ref => {
57
54
  // 单向对讲还是双向对讲
58
55
  const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
59
56
 
60
- // 全屏清晰度UI切换是否展示
61
- const [fullResolutionActive, setFullResolutionActive] = useAtom(false);
62
-
63
57
  // 对讲中
64
58
  const [intercom] = useAtom(false);
65
59
  const [playState] = useAtom(PlayState.CONNECTING);
@@ -83,11 +77,41 @@ export const createUseCtx = _ref => {
83
77
  console.log('==== getMemoryState ====', res);
84
78
  _setMute(res.mute);
85
79
  setIntercomMode(res.intercomMode);
86
- _setResolution(res.resolution, 'res.resolution');
80
+ _setResolution(res.resolution);
87
81
  setResolutionList(res.resolutionList);
88
82
  });
89
83
  }
90
84
  }, [devId, _playState]);
85
+ const changeContentHiddenData = (type, id, hidden) => {
86
+ const store = getDefaultStore();
87
+ let targetStore;
88
+ if (type === 'topLeft') {
89
+ targetStore = topLeftContent;
90
+ } else if (type === 'topRight') {
91
+ targetStore = topRightContent;
92
+ } else if (type === 'bottomLeft') {
93
+ targetStore = bottomLeftContent;
94
+ } else if (type === 'bottomRight') {
95
+ targetStore = bottomRightContent;
96
+ } else {
97
+ targetStore = absoluteContent;
98
+ }
99
+ const contentList = store.get(targetStore);
100
+ let hasChange = false;
101
+ const newData = contentList.map(item => {
102
+ if (item.id === id && item.hidden !== hidden) {
103
+ item.hidden = hidden;
104
+ hasChange = true;
105
+ }
106
+ return item;
107
+ });
108
+ if (hasChange) {
109
+ updateAtom(targetStore, newData);
110
+ }
111
+ };
112
+
113
+ // 判断是否已经有了对应id的content
114
+
91
115
  const IPCPlayerInstance = useRef();
92
116
  if (!IPCPlayerInstance.current) {
93
117
  IPCPlayerInstance.current = createPlayContext(devId);
@@ -153,8 +177,6 @@ export const createUseCtx = _ref => {
153
177
  mute,
154
178
  resolution,
155
179
  resolutionList,
156
- ptzActive,
157
- fullResolutionActive,
158
180
  intercom,
159
181
  intercomMode,
160
182
  playState,
@@ -244,8 +266,6 @@ export const createUseCtx = _ref => {
244
266
  });
245
267
  },
246
268
  setRecordingDisabled,
247
- setPtzActive,
248
- setFullResolutionActive,
249
269
  setScreenType,
250
270
  topLeftContent,
251
271
  topRightContent,
@@ -256,11 +276,9 @@ export const createUseCtx = _ref => {
256
276
  let position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
257
277
  // 组合数据, 保存到对应位置, 并去重
258
278
  const createNewData = (originData, newData, position) => {
259
- // 如果newData是数组, 则插入整个数组
260
- if (Array.isArray(newData)) {
261
- return [...originData.slice(0, position), ...newData, ...originData.slice(position)];
262
- }
263
- return [...originData.slice(0, position), newData, ...originData.slice(position)];
279
+ const _newData = Array.isArray(newData) ? newData : [newData];
280
+ if (position === -1) return [...originData, ..._newData];
281
+ return [...originData.slice(0, position), ..._newData, ...originData.slice(position)];
264
282
  };
265
283
  if (type === 'topLeft') {
266
284
  updateAtom(topLeftContent, prevValue => createNewData(prevValue, config, position));
@@ -287,6 +305,29 @@ export const createUseCtx = _ref => {
287
305
  updateAtom(absoluteContent, prevValue => prevValue.filter(item => item.id !== id));
288
306
  }
289
307
  },
308
+ hideContent: (type, id) => {
309
+ changeContentHiddenData(type, id, true);
310
+ },
311
+ showContent: (type, id) => {
312
+ changeContentHiddenData(type, id, false);
313
+ },
314
+ hasContent: (type, id) => {
315
+ const store = getDefaultStore();
316
+ let contentList;
317
+ if (type === 'topLeft') {
318
+ contentList = store.get(topLeftContent);
319
+ } else if (type === 'topRight') {
320
+ contentList = store.get(topRightContent);
321
+ } else if (type === 'bottomLeft') {
322
+ contentList = store.get(bottomLeftContent);
323
+ } else if (type === 'bottomRight') {
324
+ contentList = store.get(bottomRightContent);
325
+ } else {
326
+ contentList = store.get(absoluteContent);
327
+ }
328
+ const target = contentList.find(item => item.id === id);
329
+ return !!target;
330
+ },
290
331
  IPCPlayerInstance: IPCPlayerInstance.current,
291
332
  changeStreamStatus: status => {
292
333
  streamStatus.current = status;
@@ -2,3 +2,4 @@ export * from './useBattery';
2
2
  export * from './useHumidity';
3
3
  export * from './useTemperature';
4
4
  export * from './useDpState';
5
+ export * from './useMemoizedFn';
@@ -1,4 +1,5 @@
1
1
  export * from './useBattery';
2
2
  export * from './useHumidity';
3
3
  export * from './useTemperature';
4
- export * from './useDpState';
4
+ export * from './useDpState';
5
+ export * from './useMemoizedFn';
@@ -1,6 +1,7 @@
1
1
  type Options<T> = {
2
2
  devId: string;
3
3
  dpCodes: T[];
4
+ listenDpChange?: boolean;
4
5
  };
5
6
  type Schema = {
6
7
  id: number;
@@ -16,5 +17,9 @@ type Schema = {
16
17
  range?: Array<unknown>;
17
18
  };
18
19
  };
19
- export declare function useDpState<T extends string>(options: Options<T>): [Record<T, number | string | boolean>, Record<string, Schema>];
20
+ export declare function useDpState<T extends string>(options: Options<T>): [
21
+ Record<T, number | string | boolean>,
22
+ Record<string, Schema>,
23
+ (data: Partial<Record<T, number | string | boolean>>) => void
24
+ ];
20
25
  export {};
@@ -1,6 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { useState, useEffect, useRef, useCallback } from 'react';
3
3
  import { getDeviceInfo, onDpDataChange, offDpDataChange } from '@ray-js/ray';
4
+ import { useMemoizedFn } from '../useMemoizedFn';
4
5
  function getInitData(codes) {
5
6
  return codes.reduce((ret, key) => {
6
7
  return _objectSpread(_objectSpread({}, ret), {}, {
@@ -11,9 +12,11 @@ function getInitData(codes) {
11
12
  export function useDpState(options) {
12
13
  const {
13
14
  devId,
14
- dpCodes
15
+ dpCodes,
16
+ listenDpChange: listenDpChangeFlag = true
15
17
  } = options;
16
18
  const codeMapToIdRef = useRef();
19
+ const idMapToCode = useRef();
17
20
  const dpCodeSchemaMapsRef = useRef();
18
21
  const [values, setValues] = useState(() => {
19
22
  return getInitData(options.dpCodes);
@@ -30,7 +33,7 @@ export function useDpState(options) {
30
33
  let hasChange = false;
31
34
  const newValue = _objectSpread({}, valueRef.current);
32
35
  Object.keys(dps).forEach(dpId => {
33
- const dpCode = codeMapToIdRef.current[dpId];
36
+ const dpCode = idMapToCode.current[dpId];
34
37
  const currentValue = dps[dpId];
35
38
  if (dpCode && typeof currentValue !== 'undefined') {
36
39
  hasChange = hasChange || true;
@@ -51,6 +54,7 @@ export function useDpState(options) {
51
54
  schema
52
55
  } = res;
53
56
  const IdMapToCode = {};
57
+ const codeMapToId = {};
54
58
  const dpCodeSchemaMaps = {};
55
59
  let count = 0;
56
60
  for (const schemaItem of schema) {
@@ -60,11 +64,14 @@ export function useDpState(options) {
60
64
  IdMapToCode[schemaItem.id] = schemaItem.code;
61
65
  // @ts-ignore
62
66
  dpCodeSchemaMaps[schemaItem.code] = schemaItem;
67
+ // @ts-ignore
68
+ codeMapToId[schemaItem.code] = schemaItem.id;
63
69
  count += 1;
64
70
  }
65
71
  if (count >= dpCodes.length) break;
66
72
  }
67
- codeMapToIdRef.current = IdMapToCode;
73
+ idMapToCode.current = IdMapToCode;
74
+ codeMapToIdRef.current = codeMapToId;
68
75
  dpCodeSchemaMapsRef.current = dpCodeSchemaMaps;
69
76
  const initValue = options.dpCodes.reduce((ret, key) => {
70
77
  return _objectSpread(_objectSpread({}, ret), {}, {
@@ -77,10 +84,31 @@ export function useDpState(options) {
77
84
  }
78
85
  }, [devId]);
79
86
  useEffect(() => {
80
- onDpDataChange(listenDpChange);
87
+ if (listenDpChangeFlag) {
88
+ onDpDataChange(listenDpChange);
89
+ }
81
90
  return () => {
82
91
  offDpDataChange(listenDpChange);
83
92
  };
84
93
  }, [listenDpChange]);
85
- return [values, dpCodeSchemaMapsRef.current];
94
+ const sendDp = useMemoizedFn(data => {
95
+ const sendData = {};
96
+ Object.keys(data).forEach(key => {
97
+ sendData[codeMapToIdRef.current[key]] = data[key];
98
+ });
99
+ ty.device.publishDps({
100
+ deviceId: devId,
101
+ mode: 1,
102
+ dps: sendData,
103
+ pipelines: [0, 1, 2, 3, 4, 5, 6],
104
+ options: {},
105
+ success: res => {
106
+ console.log('publishDps success', res);
107
+ },
108
+ fail: error => {
109
+ console.log('publishDps fail', error);
110
+ }
111
+ });
112
+ });
113
+ return [values, dpCodeSchemaMapsRef.current, sendDp];
86
114
  }
@@ -0,0 +1 @@
1
+ export { useMemoizedFn } from 'ahooks';
@@ -0,0 +1 @@
1
+ export { useMemoizedFn } from 'ahooks';
@@ -1,18 +1,81 @@
1
1
  @font-face {
2
2
  font-family: "icon-panel"; /* Project id 4727767 */
3
- src: url('iconfont.woff2?t=1736394199505') format('woff2'),
4
- url('iconfont.woff?t=1736394199505') format('woff'),
5
- url('iconfont.ttf?t=1736394199505') format('truetype');
3
+ src: url('iconfont.woff2?t=1739342026633') format('woff2'),
4
+ url('iconfont.woff?t=1739342026633') format('woff'),
5
+ url('iconfont.ttf?t=1739342026633') format('truetype');
6
6
  }
7
7
 
8
8
  .icon-panel {
9
9
  font-family: "icon-panel" !important;
10
- font-size: 16px;
11
10
  font-style: normal;
12
11
  -webkit-font-smoothing: antialiased;
13
12
  -moz-osx-font-smoothing: grayscale;
14
13
  }
15
14
 
15
+ .icon-panel-close:before {
16
+ content: "\e646";
17
+ }
18
+
19
+ .icon-panel-move-control-interactive:before {
20
+ content: "\e645";
21
+ }
22
+
23
+ .icon-panel-move-control-waltz:before {
24
+ content: "\e642";
25
+ }
26
+
27
+ .icon-panel-move-control-8:before {
28
+ content: "\e648";
29
+ }
30
+
31
+ .icon-panel-move-control-p-steering:before {
32
+ content: "\e649";
33
+ }
34
+
35
+ .icon-panel-move-control-straight-line:before {
36
+ content: "\e64a";
37
+ }
38
+
39
+ .icon-panel-move-control-rotate-place:before {
40
+ content: "\e64b";
41
+ }
42
+
43
+ .icon-panel-move-control-chacha:before {
44
+ content: "\e64c";
45
+ }
46
+
47
+ .icon-panel-tange1:before {
48
+ content: "\e64e";
49
+ }
50
+
51
+ .icon-panel-move-control-big-rotation:before {
52
+ content: "\e64f";
53
+ }
54
+
55
+ .icon-panel-move-control-wave:before {
56
+ content: "\e650";
57
+ }
58
+
59
+ .icon-panel-move-control-z:before {
60
+ content: "\e651";
61
+ }
62
+
63
+ .icon-panel-move-control-rotation:before {
64
+ content: "\e647";
65
+ }
66
+
67
+ .icon-panel-yuyin:before {
68
+ content: "\e63c";
69
+ }
70
+
71
+ .icon-panel-cloud-storage:before {
72
+ content: "\e63b";
73
+ }
74
+
75
+ .icon-panel-talking:before {
76
+ content: "\e63a";
77
+ }
78
+
16
79
  .icon-panel-record-play:before {
17
80
  content: "\e637";
18
81
  }
@@ -125,10 +188,6 @@
125
188
  content: "\e612";
126
189
  }
127
190
 
128
- .icon-panel-one-way-intercom:before {
129
- content: "\e611";
130
- }
131
-
132
191
  .icon-panel-playback:before {
133
192
  content: "\e610";
134
193
  }