@ray-js/ipc-player-integration 0.0.1-beta-45 → 0.0.1-beta-46

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.
@@ -4,3 +4,4 @@ export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
6
  export * from './usePtz';
7
+ export * from './useSchemaInfo.tsx';
@@ -3,4 +3,5 @@ export * from './useHumidity';
3
3
  export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
- export * from './usePtz';
6
+ export * from './usePtz';
7
+ export * from './useSchemaInfo.tsx';
@@ -0,0 +1,2 @@
1
+ import { Schema } from '../../utils/device';
2
+ export declare function useSchemaInfo<T extends string>(devId: string, dpCodes: T[]): [Record<T, Schema> | null];
@@ -0,0 +1,17 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { getDpSchemaByCodes, getDpSchemaByCodesSync } from '../../utils/device';
3
+ export function useSchemaInfo(devId, dpCodes) {
4
+ const [schemaInfo, setSchemaInfo] = useState(() => {
5
+ const info = getDpSchemaByCodesSync(devId, dpCodes);
6
+ if (info) return info;
7
+ return null;
8
+ });
9
+ useEffect(() => {
10
+ if (!schemaInfo) {
11
+ getDpSchemaByCodes(devId, dpCodes).then(res => {
12
+ setSchemaInfo(res);
13
+ });
14
+ }
15
+ }, [schemaInfo]);
16
+ return [schemaInfo];
17
+ }
@@ -39,7 +39,7 @@ export declare const Battery: import("react").FunctionComponent<{
39
39
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
40
40
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
41
41
  toast: import("../../ports.output").Toast;
42
- event: import("../../interface").EventInstance;
42
+ event: import("../..").EventInstance;
43
43
  } & {
44
44
  className?: string | undefined;
45
45
  }>;
@@ -83,7 +83,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
83
83
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
84
84
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
85
85
  toast: import("../../ports.output").Toast;
86
- event: import("../../interface").EventInstance;
86
+ event: import("../..").EventInstance;
87
87
  } & {
88
88
  className?: string | undefined;
89
89
  }>;
@@ -12,6 +12,7 @@ import { useDpState } from '../../hooks';
12
12
  import { useComponentHideState } from '../../ui/hooks';
13
13
  import { pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
14
14
  import { DIRECTION_CONTROL_DP_CODE } from './constant';
15
+ import { useStore } from '../../ctx/store';
15
16
  export function FullTravelRouteControl(props) {
16
17
  const [shouldHide] = useComponentHideState();
17
18
  const [isPtzActive, setIsPtzActive] = useState(false);
@@ -19,6 +20,11 @@ export function FullTravelRouteControl(props) {
19
20
  event
20
21
  } = useContext(UIEventContext);
21
22
  const prevRotate = useRef('-1');
23
+ const {
24
+ brandColor
25
+ } = useStore({
26
+ brandColor: props.brandColor
27
+ });
22
28
  const [state, _, sendDp] = useDpState({
23
29
  devId: props.devId,
24
30
  dpCodes: [DIRECTION_CONTROL_DP_CODE],
@@ -38,6 +44,10 @@ export function FullTravelRouteControl(props) {
38
44
  event.off('ptzControlHide', onPtzControlHide);
39
45
  };
40
46
  }, []);
47
+ const handTouchEnd = () => {
48
+ event.emit(startTimeToHideAllComponent);
49
+ sendDpValue('-1');
50
+ };
41
51
  const {
42
52
  run: sendDpValue
43
53
  } = useDebounceFn(value => {
@@ -65,9 +75,10 @@ export function FullTravelRouteControl(props) {
65
75
  event.emit(pauseTimeToHideAllComponent);
66
76
  sendDpValue(String(value));
67
77
  },
68
- onTouchEnd: () => {
69
- event.emit(startTimeToHideAllComponent);
70
- sendDpValue('-1');
71
- }
78
+ onTouchEnd: handTouchEnd,
79
+ onMoveNonIntersection: handTouchEnd,
80
+ showArcOnTouchInEdgeProximity: true,
81
+ arcEdgeProximityColor: brandColor,
82
+ touchDistanceThreshold: 50
72
83
  }));
73
84
  }
@@ -1,12 +1,27 @@
1
- import React, { useCallback, useContext, useEffect, useState } from 'react';
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import React, { useCallback, useContext, useEffect, useState, useMemo } from 'react';
2
4
  import clsx from 'clsx';
3
5
  import { MoveInterActiveControlUI } from './moveInteractiveControlUI';
4
6
  import { playerTap, showAllComponent } from '../../ui/constant';
5
- import { useDpState } from '../../hooks';
7
+ import { useDpState, useSchemaInfo } from '../../hooks';
6
8
  import { UIEventContext } from '../../ui/context';
7
9
  import './moveInteractiveControl.less';
8
10
  const TYPE_CODE = 'ipc_manual_petting';
9
11
  const STATE_CODE = 'ipc_manual_petting_state';
12
+ const iconMap = {
13
+ '0': 'icon-panel-move-control-rotate-place',
14
+ '1': 'icon-panel-move-control-straight-line',
15
+ '2': 'icon-panel-move-control-8',
16
+ '3': 'icon-panel-move-control-rotation',
17
+ '4': 'icon-panel-move-control-big-rotation',
18
+ '5': 'icon-panel-move-control-z',
19
+ '6': 'icon-panel-move-control-wave',
20
+ '7': 'icon-panel-move-control-p-steering',
21
+ '8': 'icon-panel-move-control-chacha',
22
+ '9': 'icon-panel-tange1',
23
+ '10': 'icon-panel-move-control-waltz'
24
+ };
10
25
  export function MoveInteractiveControl(props) {
11
26
  const {
12
27
  devId
@@ -17,6 +32,17 @@ export function MoveInteractiveControl(props) {
17
32
  listenDpChange: false
18
33
  });
19
34
  console.log('state', state);
35
+ const [schemaInfo] = useSchemaInfo(devId, [TYPE_CODE]);
36
+ const menu = useMemo(() => {
37
+ if (!schemaInfo || !(schemaInfo !== null && schemaInfo !== void 0 && schemaInfo[TYPE_CODE])) {
38
+ return [];
39
+ }
40
+ return schemaInfo[TYPE_CODE].property.range.map(key => ({
41
+ key,
42
+ label: I18n.t(`dp_ipc_manual_petting_${key}`),
43
+ iconName: iconMap[key]
44
+ }));
45
+ }, [schemaInfo]);
20
46
  const {
21
47
  event
22
48
  } = useContext(UIEventContext);
@@ -40,6 +66,7 @@ export function MoveInteractiveControl(props) {
40
66
  wrapClsName: clsx('ipc-player-plugin-move-control', {
41
67
  'ipc-player-plugin-move-control-hide': hide
42
68
  }),
69
+ menu: menu,
43
70
  onClick: value => {
44
71
  sendDp({
45
72
  [TYPE_CODE]: value
@@ -70,7 +70,8 @@ export function MoveInterActiveControlUI(props) {
70
70
  activeKey,
71
71
  onClick
72
72
  } = props;
73
- const handClick = item => {
73
+ const handClick = (item, e) => {
74
+ e.origin.stopPropagation();
74
75
  onClick && onClick(item.key);
75
76
  };
76
77
  return /*#__PURE__*/React.createElement(View
@@ -88,7 +89,7 @@ export function MoveInterActiveControlUI(props) {
88
89
  }, /*#__PURE__*/React.createElement(View, {
89
90
  className: clsx('ipc-player-plugin-active-control', contentClsName)
90
91
  }, menu.map(item => /*#__PURE__*/React.createElement(View, {
91
- onClick: () => handClick(item),
92
+ onClick: e => handClick(item, e),
92
93
  key: item.key,
93
94
  className: clsx('ipc-player-plugin-active-control-item', {
94
95
  'ipc-player-plugin-active-control-item-active': activeKey === item.key
package/lib/ui/event.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- type Task = (...args: any[]) => void;
2
- export type EventInstance = {
3
- on: (type: string, cb: Task) => void;
4
- off: (type: string, cb: Task) => void;
5
- emit: (type: string, ...args: any[]) => void;
6
- };
1
+ import { EventInstance } from '../interface';
7
2
  export declare function getEventInstance(): EventInstance;
8
- export {};
package/lib/ui/ui.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { PlayStatusData, UseCtx } from '../interface';
3
- import { EventInstance } from './event';
2
+ import { PlayStatusData, UseCtx, EventInstance } from '../interface';
4
3
  import './ui.less';
5
4
  type CtxInstance = ReturnType<UseCtx>;
6
5
  type CSSVariable = {
@@ -43,27 +43,41 @@ export function getDeviceInfo(devId) {
43
43
  });
44
44
  });
45
45
  }
46
- export function getDpIdsByCodes(devId) {
47
- return new Promise((resolve, reject) => {
48
- ty.device.getDeviceInfo({
49
- deviceId: devId,
50
- success: res => {
51
- console.log('res', res);
52
- // console.log('res', res);
53
- // const { dps } = res;
54
- // // @ts-ignore
55
- // const ret: Record<T, any> = {};
56
- // options.dps.forEach(dpId => {
57
- // ret[dpId] = dps[dpId];
58
- // });
59
- // resolve(ret);
60
- },
61
- fail: err => {
62
- reject(err); // eslint-disable-line
46
+ const memorySchema = {};
47
+ export function getDpSchemaByCodes(devId, dpCodes) {
48
+ return new Promise(resolve => {
49
+ const ret = {};
50
+ if (memorySchema[devId]) {
51
+ dpCodes.forEach(code => {
52
+ ret[code] = memorySchema[devId][code];
53
+ });
54
+ resolve(ret);
55
+ return;
56
+ }
57
+ getDeviceInfo(devId).then(res => {
58
+ if (!memorySchema[devId]) {
59
+ memorySchema[devId] = {};
60
+ res.schema.forEach(item => {
61
+ memorySchema[devId][item.code] = item;
62
+ });
63
63
  }
64
+ dpCodes.forEach(code => {
65
+ ret[code] = memorySchema[devId][code];
66
+ });
67
+ resolve(ret);
64
68
  });
65
69
  });
66
70
  }
71
+ export function getDpSchemaByCodesSync(devId, dpCodes) {
72
+ const ret = {};
73
+ if (memorySchema[devId]) {
74
+ dpCodes.forEach(code => {
75
+ ret[code] = memorySchema[devId][code];
76
+ });
77
+ return ret;
78
+ }
79
+ return null;
80
+ }
67
81
  export const showMathPowValue = (value, scale) => {
68
82
  if (isNaN(Number(value))) {
69
83
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-45",
3
+ "version": "0.0.1-beta-46",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -32,7 +32,7 @@
32
32
  "test": "yarn jest"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ray-js/direction-control": "0.0.3-beta-1",
35
+ "@ray-js/direction-control": "0.0.7-beta-3",
36
36
  "ahooks": "^3.1.6"
37
37
  },
38
38
  "dependencies": {
@@ -48,7 +48,7 @@
48
48
  "@commitlint/cli": "^7.2.1",
49
49
  "@commitlint/config-conventional": "^9.0.1",
50
50
  "@ray-js/cli": "^1.4.9",
51
- "@ray-js/direction-control": "0.0.3-beta-1",
51
+ "@ray-js/direction-control": "0.0.7-beta-3",
52
52
  "@ray-js/ray": "^1.4.9",
53
53
  "@testing-library/react-hooks": "^8.0.1",
54
54
  "@types/jest": "^29.5.14",