@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
@@ -9,14 +9,12 @@ const TopRightContent = _ref => {
9
9
  children
10
10
  } = _ref;
11
11
  const {
12
- screenType,
13
- fullResolutionActive
12
+ screenType
14
13
  } = useStore({
15
14
  screenType: ctx.screenType,
16
- playState: ctx.playState,
17
- fullResolutionActive: ctx.fullResolutionActive
15
+ playState: ctx.playState
18
16
  });
19
- const [shouldHide] = useComponentHideState(screenType);
17
+ const [shouldHide] = useComponentHideState();
20
18
  return /*#__PURE__*/React.createElement(CoverView, {
21
19
  className: clsx('ipc-player-top-right-content-wrap')
22
20
  }, /*#__PURE__*/React.createElement(View, {
@@ -25,8 +23,8 @@ const TopRightContent = _ref => {
25
23
  paddingRight: screenType === 'vertical' ? 0 : '25px'
26
24
  },
27
25
  className: clsx('ipc-player-top-right-content-container', {
28
- 'ipc-player-top-right-content-hide': shouldHide || fullResolutionActive,
29
- 'ipc-player-top-right-content-show': !shouldHide && !fullResolutionActive
26
+ // 'ipc-player-top-right-content-hide': shouldHide,
27
+ // 'ipc-player-top-right-content-show': !shouldHide,
30
28
  })
31
29
  }, children));
32
30
  };
package/lib/ui/ui.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { PlayStatusData, UseCtx } from '../interface';
3
+ import { EventInstance } from './event';
3
4
  import './ui.less';
4
5
  type CtxInstance = ReturnType<UseCtx>;
5
6
  type CSSVariable = {
@@ -24,6 +25,7 @@ type Props = {
24
25
  CSSVariable?: Partial<CSSVariable>;
25
26
  brandColor?: string;
26
27
  verticalMic?: boolean;
28
+ eventRef?: React.RefObject<EventInstance>;
27
29
  };
28
30
  export declare const IPCPlayerIntegration: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
29
31
  export {};
package/lib/ui/ui.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import React, { useContext, useRef, useMemo, useEffect, useCallback } from 'react';
2
+ import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
3
3
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import IPCPlayer from '@ray-js/ray-ipc-player';
6
6
  import { PlayState, PlayerStreamStatus } from '../interface';
7
7
  import { useCtx } from '../ctx/ctx.composition';
8
- import { useStore, getDefaultStore } from '../ctx/store';
8
+ import { useStore } from '../ctx/store';
9
9
  import { getEventInstance } from './event';
10
10
  import { UIEventContext } from './context';
11
11
  import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent } from './constant';
@@ -13,6 +13,7 @@ import BottomLeftContent from './bottomLeftContent';
13
13
  import BottomRightContent from './bottomRightContent';
14
14
  import TopLeftContent from './topLeftContent';
15
15
  import TopRightContent from './topRightContent';
16
+ import { useMemoizedFn } from '../hooks';
16
17
  import './ui.less';
17
18
  function getCtxInstance(instance, devId) {
18
19
  if (instance) return instance;
@@ -46,18 +47,28 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
46
47
  privateState = false,
47
48
  deviceOnline = true,
48
49
  brandColor = '#FF592A',
49
- verticalMic = true
50
+ verticalMic = true,
51
+ eventRef: eventRefProp
50
52
  } = props;
51
53
  const instance = getCtxInstance(props.instance, devId);
52
54
  const {
53
55
  setPlayState,
54
56
  setScreenType,
55
- setFullResolutionActive,
56
57
  setBrandColor,
57
58
  setVerticalMic
58
59
  } = instance;
59
60
  const prevTriggerEvent = useRef();
61
+
62
+ /*
63
+ player 的UI效果期望有一些控件在初始化的时候都展示,在点击 Player 之后隐藏:
64
+ 在控件显示时,点击播放器期望隐藏控件
65
+ 在控件消失时,点击播放器期望展示控件
66
+ 这里用一个统一的状态标志期望控件是否展示
67
+ */
68
+ const [componentHideState, setComponentHideState] = useState(false);
69
+ prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
60
70
  const eventRef = useRef();
71
+ useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
61
72
  const timer = useRef();
62
73
  if (!eventRef.current) {
63
74
  eventRef.current = getEventInstance();
@@ -92,7 +103,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
92
103
  absoluteContent,
93
104
  screenType,
94
105
  playState,
95
- fullResolutionActive,
96
106
  resolution,
97
107
  mute
98
108
  } = useStore({
@@ -103,7 +113,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
103
113
  absoluteContent: instance.absoluteContent,
104
114
  screenType: instance.screenType,
105
115
  playState: instance.playState,
106
- fullResolutionActive: instance.fullResolutionActive,
107
116
  resolution: instance.resolution,
108
117
  mute: instance.mute
109
118
  });
@@ -117,7 +126,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
117
126
  */
118
127
  const renderTopLeftContent = useMemo(() => {
119
128
  if (!topLeftContent || !(topLeftContent !== null && topLeftContent !== void 0 && topLeftContent.length)) return null;
120
- return topLeftContent.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
129
+ return topLeftContent.map(item => item.hidden ? null : /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
121
130
  key: item.id
122
131
  }, item.initProps), instance), {}, {
123
132
  IPCPlayerContext: instance.IPCPlayerInstance,
@@ -131,7 +140,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
131
140
  */
132
141
  const renderTopRightContent = useMemo(() => {
133
142
  if (!topRightContent || !(topRightContent !== null && topRightContent !== void 0 && topRightContent.length)) return null;
134
- return topRightContent.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
143
+ return topRightContent.map(item => item.hidden ? null : /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
135
144
  key: item.id
136
145
  }, item.initProps), instance), {}, {
137
146
  IPCPlayerContext: instance.IPCPlayerInstance,
@@ -145,7 +154,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
145
154
  */
146
155
  const renderBottomLeftContent = useMemo(() => {
147
156
  if (!bottomLeftContent || !(bottomLeftContent !== null && bottomLeftContent !== void 0 && bottomLeftContent.length)) return null;
148
- return bottomLeftContent.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({}, item.initProps), {}, {
157
+ return bottomLeftContent.map(item => item.hidden ? null : /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({}, item.initProps), {}, {
149
158
  key: item.id
150
159
  }, instance), {}, {
151
160
  IPCPlayerContext: instance.IPCPlayerInstance,
@@ -159,7 +168,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
159
168
  */
160
169
  const renderBottomRightContent = useMemo(() => {
161
170
  if (!bottomRightContent || !(bottomRightContent !== null && bottomRightContent !== void 0 && bottomRightContent.length)) return null;
162
- return bottomRightContent.map(item => /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({}, item.initProps), {}, {
171
+ return bottomRightContent.map(item => item.hidden ? null : /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({}, item.initProps), {}, {
163
172
  key: item.id
164
173
  }, instance), {}, {
165
174
  IPCPlayerContext: instance.IPCPlayerInstance,
@@ -173,10 +182,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
173
182
  */
174
183
 
175
184
  const triggerEvent = type => {
176
- getDefaultStore();
177
- console.log('_______Dsahdjashjdhsjah');
178
- // const _screenType = store.get(instance.screenType);
179
- // if (prevTriggerEvent.current === type || _screenType === 'vertical') return;
180
185
  if (prevTriggerEvent.current === type) return;
181
186
  if (timer.current) {
182
187
  clearTimeout(timer.current);
@@ -189,9 +194,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
189
194
  }, HIDE_COMPONENT_TIME);
190
195
  }
191
196
  eventRef.current.emit(type);
192
- prevTriggerEvent.current = type;
193
197
  };
194
- const listenStart = useCallback(() => {
198
+ const listenStart = useMemoizedFn(() => {
195
199
  timer.current && clearTimeout(timer.current);
196
200
  // 重新开始计时
197
201
  if (!timer.current) {
@@ -200,27 +204,34 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
200
204
  triggerEvent(hideAllComponent);
201
205
  }, HIDE_COMPONENT_TIME);
202
206
  }
203
- }, []);
204
- const listenPause = useCallback(() => {
207
+ });
208
+ const listenPause = useMemoizedFn(() => {
205
209
  timer.current && clearTimeout(timer.current);
206
210
  timer.current = null;
207
- }, []);
211
+ });
212
+ const listenHideEvent = useMemoizedFn(() => {
213
+ setComponentHideState(true);
214
+ });
215
+ const listenShowEvent = useMemoizedFn(() => {
216
+ setComponentHideState(false);
217
+ });
208
218
  useEffect(() => {
209
219
  eventRef.current.on(startTimeToHideAllComponent, listenStart);
210
- return () => {
211
- eventRef.current.off(startTimeToHideAllComponent, listenStart);
212
- };
213
- }, [listenStart]);
214
- useEffect(() => {
215
220
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
221
+ eventRef.current.on(showAllComponent, listenShowEvent);
222
+ eventRef.current.on(hideAllComponent, listenHideEvent);
216
223
  return () => {
224
+ eventRef.current.off(startTimeToHideAllComponent, listenStart);
217
225
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
226
+ eventRef.current.off(showAllComponent, listenShowEvent);
227
+ eventRef.current.off(hideAllComponent, listenHideEvent);
218
228
  };
219
- });
229
+ }, []);
220
230
  const playerReady = playState === PlayState.PLAYING;
221
231
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
222
232
  value: {
223
- event: eventRef.current
233
+ event: eventRef.current,
234
+ componentHideState
224
235
  }
225
236
  }, /*#__PURE__*/React.createElement(View, {
226
237
  className: clsx('ipc-player-content', className),
@@ -274,18 +285,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
274
285
  privateState: privateState,
275
286
  onPlayerTap: data => {
276
287
  console.log('res===on onVideoTap', data);
277
- const store = getDefaultStore();
278
- const _screenType = store.get(instance.screenType);
279
- const _fullResolutionActive = store.get(instance.fullResolutionActive);
280
288
  eventRef.current.emit(playerTap);
281
- // 如果全屏清晰度展开, 则点击关闭全屏清晰度, 展示所有组件
282
- if (_fullResolutionActive && _screenType === 'full') {
283
- setFullResolutionActive(false);
284
- // 展示相应菜单启动自动隐藏定时
285
- triggerEvent(showAllComponent);
286
- event.emit(startTimeToHideAllComponent);
287
- return false;
288
- }
289
289
  console.log(prevTriggerEvent.current, 'prevTriggerEvent.current');
290
290
  if (prevTriggerEvent.current === hideAllComponent) {
291
291
  triggerEvent(showAllComponent);
@@ -294,17 +294,34 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
294
294
  }
295
295
  return false;
296
296
  } // 对应原来的onVideoTap
297
- }), /*#__PURE__*/React.createElement(TopLeftContent, {
297
+ }), /*#__PURE__*/React.createElement(View, {
298
+ className: clsx('ipc-player-top-content', {
299
+ 'ipc-player-top-content-hide': componentHideState,
300
+ 'ipc-player-top-content-show': !componentHideState
301
+ }),
302
+ style: {
303
+ height: screenType === 'vertical' ? '48px' : '60px'
304
+ }
305
+ }, /*#__PURE__*/React.createElement(TopLeftContent, {
298
306
  ctx: instance
299
307
  }, renderTopLeftContent), /*#__PURE__*/React.createElement(TopRightContent, {
300
308
  ctx: instance
301
- }, renderTopRightContent), /*#__PURE__*/React.createElement(BottomLeftContent, {
309
+ }, renderTopRightContent)), /*#__PURE__*/React.createElement(View, {
310
+ className: clsx('ipc-player-bottom-content', {
311
+ 'ipc-player-bottom-content-hide': componentHideState,
312
+ 'ipc-player-bottom-content-show': !componentHideState
313
+ }),
314
+ style: {
315
+ height: screenType === 'vertical' ? '48px' : '60px'
316
+ }
317
+ }, /*#__PURE__*/React.createElement(BottomLeftContent, {
302
318
  ctx: instance
303
319
  }, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
304
320
  ctx: instance
305
- }, renderBottomRightContent), playerReady && (() => {
321
+ }, renderBottomRightContent)), playerReady && (() => {
306
322
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
307
323
  return absoluteContent.map(item => {
324
+ if (item.hidden) return null;
308
325
  return /*#__PURE__*/React.createElement(CoverView, {
309
326
  key: item.id,
310
327
  style: _objectSpread({
package/lib/ui/ui.less CHANGED
@@ -2,6 +2,50 @@
2
2
  position: relative;
3
3
  overflow: hidden;
4
4
 
5
+ // 顶部长条
6
+ .ipc-player-top-content {
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+ right: 0;
11
+ z-index: 90;
12
+ height: 60px;
13
+ background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
14
+ }
15
+ // 底部长条
16
+ .ipc-player-bottom-content {
17
+ position: absolute;
18
+ bottom: 0;
19
+ left: 0;
20
+ right: 0;
21
+ padding-top: 12px;
22
+ z-index: 90;
23
+ height: 60px;
24
+ background: linear-gradient(360deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);;
25
+ }
26
+
27
+ // 顶部整条内容隐藏
28
+ .ipc-player-top-content-show {
29
+ transform: translate(0, 0);
30
+ transition: transform ease-in 0.3s;
31
+ }
32
+
33
+ .ipc-player-top-content-hide {
34
+ transform: translate(0, -110%);
35
+ transition: transform 0.3s ease-in-out;
36
+ }
37
+
38
+ // 底部整条内容隐藏
39
+ .ipc-player-bottom-content-show {
40
+ transform: translate(0, 0);
41
+ transition: transform ease-in 0.3s;
42
+ }
43
+
44
+ .ipc-player-bottom-content-hide {
45
+ transform: translate(0, 110%);
46
+ transition: transform 0.3s ease-in-out;
47
+ }
48
+
5
49
  // 左上角容器样式
6
50
  .ipc-player-top-left-content-wrap {
7
51
  position: absolute;
@@ -106,13 +150,6 @@
106
150
  flex-direction: inherit;
107
151
  }
108
152
 
109
- .ipc-player-bottom-right-content-wrap {
110
- position: absolute;
111
- z-index: 100;
112
- right: 0;
113
- bottom: 0;
114
- }
115
-
116
153
  .ipc-player-bottom-right-item-container {
117
154
  padding: 0 8px;
118
155
  height: 100%;
@@ -153,14 +190,14 @@
153
190
 
154
191
  // 左下角子元素容器
155
192
  .bottom-left-item-container {
156
- padding: 0 8px;
193
+ padding: 0 12px;
157
194
  }
158
195
 
159
196
  .bottom-left-item-container:first-of-type {
160
- padding: 0 8px 0 16px;
197
+ padding: 0 12px 0 16px;
161
198
  }
162
199
  .bottom-left-item-container:last-of-type {
163
- padding: 0 0 0 8px;
200
+ padding: 0 0 0 12px;
164
201
  }
165
202
  .bottom-left-item-container:only-of-type{
166
203
  padding: 0 0 0 16px;
@@ -172,10 +209,10 @@
172
209
  }
173
210
 
174
211
  .bottom-right-item-container:first-of-type {
175
- padding: 0 8px 0 0;
212
+ padding: 0 12px 0 0;
176
213
  }
177
214
  .bottom-right-item-container:last-of-type {
178
- padding: 0 16px 0 8px;
215
+ padding: 0 16px 0 12px;
179
216
  }
180
217
  .bottom-right-item-container:only-of-type {
181
218
  padding: 0 16px 0 0;
@@ -9,6 +9,8 @@ export interface IDpCode {
9
9
  time: number;
10
10
  type: string;
11
11
  }
12
+ type ReturnDeviceInfo = Parameters<Parameters<typeof ty.device.getDeviceInfo>[0]['success']>[0];
13
+ export declare function getDeviceInfo(devId: string): Promise<ReturnDeviceInfo>;
12
14
  export declare function getDpIdsByCodes<T extends string>(devId: string, dpIds: T[]): Promise<Record<T, string>>;
13
15
  export declare const showMathPowValue: (value: any, scale: any) => string | 0;
14
16
  export declare const getDevInfo: <T>(deviceId: string) => Promise<any>;
@@ -17,3 +19,5 @@ export declare const getDevInfo: <T>(deviceId: string) => Promise<any>;
17
19
  * @param result: {code: number, msg: string}
18
20
  */
19
21
  export declare const getEnumRangeIsValid: (devId: any, dpCode: any, rangValue: any) => Promise<any>;
22
+ export declare function hasDpCode(devId: string, code: string): Promise<boolean>;
23
+ export {};
@@ -21,6 +21,25 @@ export function getDpValue(options) {
21
21
  });
22
22
  });
23
23
  }
24
+ const memoryDevInfo = {};
25
+ export function getDeviceInfo(devId) {
26
+ return new Promise((resolve, reject) => {
27
+ if (memoryDevInfo[devId]) {
28
+ resolve(memoryDevInfo[devId]);
29
+ return;
30
+ }
31
+ ty.device.getDeviceInfo({
32
+ deviceId: devId,
33
+ success: res => {
34
+ memoryDevInfo[devId] = res;
35
+ resolve(res);
36
+ },
37
+ fail: err => {
38
+ reject(err); // eslint-disable-line
39
+ }
40
+ });
41
+ });
42
+ }
24
43
  export function getDpIdsByCodes(devId) {
25
44
  return new Promise((resolve, reject) => {
26
45
  ty.device.getDeviceInfo({
@@ -104,4 +123,11 @@ export const getEnumRangeIsValid = async (devId, dpCode, rangValue) => {
104
123
  return false;
105
124
  }
106
125
  return false;
107
- };
126
+ };
127
+ export function hasDpCode(devId, code) {
128
+ return new Promise((resolve, reject) => {
129
+ getDeviceInfo(devId).then(res => {
130
+ resolve(res.dpCodes[code] !== undefined);
131
+ }, err => reject(err));
132
+ });
133
+ }
@@ -0,0 +1,4 @@
1
+ import { UseCtx } from '../../interface';
2
+ type Ctx = ReturnType<UseCtx>;
3
+ export declare function initPlayerPlugins(ctx: Ctx): Promise<void>;
4
+ export {};
@@ -0,0 +1,20 @@
1
+ import { defaultTopLeftContent, defaultTopRightContent, defaultBottomLeftContent, defaultBottomRightContent } from '../../ctx';
2
+ import { hasDpCode } from '../../utils/device';
3
+ import { MoveInteractiveControlButton } from '../../plugins/moveInteractiveControl';
4
+ // 根据当前 dp 信息决定设置哪些 plugin
5
+ export async function initPlayerPlugins(ctx) {
6
+ ctx.addContent('topLeft', defaultTopLeftContent);
7
+ ctx.addContent('topRight', defaultTopRightContent);
8
+ ctx.addContent('bottomLeft', defaultBottomLeftContent);
9
+ ctx.addContent('bottomRight', defaultBottomRightContent);
10
+
11
+ // 根据 ipc_manual_petting 是否存在,决定是否要插入控件 moveInteractiveControl
12
+ hasDpCode(ctx.devId, 'ipc_manual_petting').then(res => {
13
+ if (res) {
14
+ ctx.addContent('bottomLeft', {
15
+ id: 'MoveInteractiveControlButton',
16
+ content: MoveInteractiveControlButton
17
+ }, -1);
18
+ }
19
+ });
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-32",
3
+ "version": "0.0.1-beta-34",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -31,7 +31,10 @@
31
31
  "release-it": "standard-version",
32
32
  "test": "yarn jest"
33
33
  },
34
- "peerDependencies": {},
34
+ "peerDependencies": {
35
+ "@ray-js/direction-control": "0.0.3-beta-1",
36
+ "ahooks": "^3.1.6"
37
+ },
35
38
  "dependencies": {
36
39
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-4",
37
40
  "@ray-js/panel-sdk": "^1.13.1",
@@ -45,9 +48,11 @@
45
48
  "@commitlint/cli": "^7.2.1",
46
49
  "@commitlint/config-conventional": "^9.0.1",
47
50
  "@ray-js/cli": "^1.4.9",
51
+ "@ray-js/direction-control": "0.0.3-beta-1",
48
52
  "@ray-js/ray": "^1.4.9",
49
53
  "@testing-library/react-hooks": "^8.0.1",
50
54
  "@types/jest": "^29.5.14",
55
+ "ahooks": "^3.8.4",
51
56
  "core-js": "^3.19.1",
52
57
  "eslint-config-tuya-panel": "^0.4.2",
53
58
  "husky": "^1.2.0",