@ray-js/ipc-player-integration 0.0.1-beta-15 → 0.0.1-beta-17

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.
@@ -2,5 +2,19 @@ type Options<T> = {
2
2
  devId: string;
3
3
  dpCodes: T[];
4
4
  };
5
- export declare function useDpState<T extends string>(options: Options<T>): [Record<T, number | string | boolean>];
5
+ type Schema = {
6
+ id: number;
7
+ code: string;
8
+ mode: string;
9
+ property: {
10
+ type: 'value' | 'enum' | 'bool';
11
+ unit?: string;
12
+ min?: number;
13
+ max?: number;
14
+ scale?: number;
15
+ step?: number;
16
+ range?: Array<unknown>;
17
+ };
18
+ };
19
+ export declare function useDpState<T extends string>(options: Options<T>): [Record<T, number | string | boolean>, Record<string, Schema>];
6
20
  export {};
@@ -14,6 +14,7 @@ export function useDpState(options) {
14
14
  dpCodes
15
15
  } = options;
16
16
  const codeMapToIdRef = useRef();
17
+ const dpCodeSchemaMapsRef = useRef();
17
18
  const [values, setValues] = useState(() => {
18
19
  return getInitData(options.dpCodes);
19
20
  });
@@ -42,38 +43,44 @@ export function useDpState(options) {
42
43
  }
43
44
  }, [devId]);
44
45
  useEffect(() => {
45
- getDeviceInfo({
46
- deviceId: devId,
47
- success: res => {
48
- const {
49
- schema
50
- } = res;
51
- const IdMapToCode = {};
52
- let count = 0;
53
- for (const schemaItem of schema) {
54
- // @ts-ignore
55
- if (dpCodes.includes(schemaItem.code)) {
46
+ if (devId) {
47
+ getDeviceInfo({
48
+ deviceId: devId,
49
+ success: res => {
50
+ const {
51
+ schema
52
+ } = res;
53
+ const IdMapToCode = {};
54
+ const dpCodeSchemaMaps = {};
55
+ let count = 0;
56
+ for (const schemaItem of schema) {
56
57
  // @ts-ignore
57
- IdMapToCode[schemaItem.id] = schemaItem.code;
58
- count += 1;
58
+ if (dpCodes.includes(schemaItem.code)) {
59
+ // @ts-ignore
60
+ IdMapToCode[schemaItem.id] = schemaItem.code;
61
+ // @ts-ignore
62
+ dpCodeSchemaMaps[schemaItem.code] = schemaItem;
63
+ count += 1;
64
+ }
65
+ if (count >= dpCodes.length) break;
59
66
  }
60
- if (count >= dpCodes.length) break;
67
+ codeMapToIdRef.current = IdMapToCode;
68
+ dpCodeSchemaMapsRef.current = dpCodeSchemaMaps;
69
+ const initValue = options.dpCodes.reduce((ret, key) => {
70
+ return _objectSpread(_objectSpread({}, ret), {}, {
71
+ [key]: res.dpCodes[key]
72
+ });
73
+ }, {});
74
+ setValues(initValue);
61
75
  }
62
- codeMapToIdRef.current = IdMapToCode;
63
- const initValue = options.dpCodes.reduce((ret, key) => {
64
- return _objectSpread(_objectSpread({}, ret), {}, {
65
- [key]: res.dpCodes[key]
66
- });
67
- }, {});
68
- setValues(initValue);
69
- }
70
- });
71
- }, [options.devId]);
76
+ });
77
+ }
78
+ }, [devId]);
72
79
  useEffect(() => {
73
80
  onDpDataChange(listenDpChange);
74
81
  return () => {
75
82
  offDpDataChange(listenDpChange);
76
83
  };
77
84
  }, [listenDpChange]);
78
- return [values];
85
+ return [values, dpCodeSchemaMapsRef.current];
79
86
  }
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import React, { useContext } from 'react';
3
2
  import { CoverView } from '@ray-js/ray';
4
3
  import clsx from 'clsx';
@@ -10,19 +9,21 @@ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../
10
9
  import './ptz.less';
11
10
  export const PtzControl = props => {
12
11
  const {
13
- screenType
12
+ screenType,
13
+ brandColor
14
14
  } = useStore({
15
- screenType: props.screenType
15
+ screenType: props.screenType,
16
+ brandColor: props.brandColor
16
17
  });
17
18
  const [shouldHide] = useComponentHideState(screenType);
18
19
  const {
19
20
  event
20
21
  } = useContext(UIEventContext);
21
- return /*#__PURE__*/React.createElement(CoverView, _extends({
22
+ return /*#__PURE__*/React.createElement(CoverView, {
22
23
  className: clsx('ipc-player-plugin-full-screen-ptz-control', {
23
24
  'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide
24
25
  })
25
- }, props), /*#__PURE__*/React.createElement(IpcPtzZoom, {
26
+ }, /*#__PURE__*/React.createElement(IpcPtzZoom, {
26
27
  ptzSize: "172px",
27
28
  zoomData: [],
28
29
  ptzData: [{
@@ -58,7 +59,7 @@ export const PtzControl = props => {
58
59
  console.log('dsads');
59
60
  event.emit(startTimeToHideAllComponent);
60
61
  },
61
- brandColor: "red",
62
+ brandColor: brandColor,
62
63
  iconClassName: clsx('arrow-icon-wrapper')
63
64
  }));
64
65
  };
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import React, { useContext } from 'react';
3
2
  import { Text, View } from '@ray-js/ray';
4
3
  import clsx from 'clsx';
@@ -42,19 +41,16 @@ export const FullResolutionControl = props => {
42
41
  setFullResolutionActive(false);
43
42
  }
44
43
  };
45
- console.log(brandColor, 'brandColor');
46
- console.log(resolution, 'resolution');
47
- console.log(resolutionList, 'resolutionList');
48
- return /*#__PURE__*/React.createElement(View, _extends({
44
+ return /*#__PURE__*/React.createElement(View, {
49
45
  className: clsx('ipc-player-plugin-full-resolution-control', {
50
46
  'ipc-player-plugin-full-resolution-control-hide': shouldHide || !fullResolutionActive
51
47
  })
52
- }, props), resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
48
+ }, resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
53
49
  onClick: () => changeResolution(item),
54
50
  key: item,
55
51
  className: clsx('ipc-player-plugin-full-resolution-control-text'),
56
52
  style: item === resolution && {
57
53
  color: brandColor
58
54
  }
59
- }, Strings.getLang(`ipc_player_resolution_${item}`))));
55
+ }, I18n.t(`ipc_player_resolution_${item}`))));
60
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-15",
3
+ "version": "0.0.1-beta-17",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [