@ray-js/ipc-player-integration 0.0.8-beta-2 → 0.0.8-beta-3

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/ui/ui.d.ts CHANGED
@@ -15,6 +15,8 @@ type CSSVariable = {
15
15
  };
16
16
  type Props = {
17
17
  devId: string;
18
+ isShare?: boolean;
19
+ ignoreHideStopPreview?: boolean;
18
20
  instance?: CtxInstance;
19
21
  className?: string;
20
22
  onPlayStatus?: (data: PlayStatusData) => void;
package/lib/ui/ui.js CHANGED
@@ -45,6 +45,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
45
45
  className,
46
46
  devId,
47
47
  style,
48
+ isShare = false,
49
+ ignoreHideStopPreview = false,
48
50
  CSSVariable = defaultCSSVariable,
49
51
  privateState = false,
50
52
  deviceOnline = true,
@@ -433,6 +435,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
433
435
  defaultMute: mute,
434
436
  devId: devId,
435
437
  onlineStatus: deviceOnline,
438
+ isShare: isShare,
439
+ ignoreHideStopPreview: ignoreHideStopPreview,
436
440
  ipcPlayerContext: instance.IPCPlayerInstance,
437
441
  onChangeStreamStatus: onChangeStreamStatus
438
442
  // onCtx={getIpcPlayerCtx}
@@ -1,3 +1,4 @@
1
+ /// <reference types="jest" />
1
2
  /**
2
3
  * 麦克风对讲按钮径向渐变
3
4
  */
@@ -7,3 +8,8 @@ export declare const adjustBrightness: (hex: any, factor: any) => string;
7
8
  * 前置补零
8
9
  */
9
10
  export declare const addZero: (num: string, length: number) => string;
11
+ export declare const promisify: <TParams extends Record<string, any>, TSuccessResult = any>(apiFunction: (params: TParams & {
12
+ success?: ((result: TSuccessResult) => void) | undefined;
13
+ fail?: ((error: any) => void) | undefined;
14
+ complete?: (() => void) | undefined;
15
+ }) => void) => (params: Omit<TParams, "complete" | "success" | "fail">) => Promise<TSuccessResult>;
@@ -1,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  /**
2
3
  * 麦克风对讲按钮径向渐变
3
4
  */
@@ -25,4 +26,14 @@ export const addZero = (num, length) => {
25
26
  return numStr;
26
27
  }
27
28
  return addZero(`0${numStr}`, length);
29
+ };
30
+ export const promisify = apiFunction => {
31
+ return params => {
32
+ return new Promise((resolve, reject) => {
33
+ apiFunction(_objectSpread(_objectSpread({}, params), {}, {
34
+ success: result => resolve(result),
35
+ fail: error => reject(error)
36
+ }));
37
+ });
38
+ };
28
39
  };
@@ -0,0 +1,9 @@
1
+ export declare class Storage {
2
+ private prefix;
3
+ constructor(prefix: string);
4
+ get(key: string): Promise<any>;
5
+ set(key: string, value: any): Promise<null>;
6
+ remove(key: string): Promise<null>;
7
+ private getFullKey;
8
+ }
9
+ export declare const storage: Storage;
@@ -0,0 +1,29 @@
1
+ import { getStorage, setStorage, removeStorage, getLaunchOptionsSync } from '@ray-js/ray';
2
+ import { promisify } from '..';
3
+ export class Storage {
4
+ constructor(prefix) {
5
+ this.prefix = prefix;
6
+ }
7
+ async get(key) {
8
+ var _res$data;
9
+ const res = await promisify(getStorage)({
10
+ key: this.getFullKey(key)
11
+ });
12
+ return JSON.parse((_res$data = res.data) !== null && _res$data !== void 0 ? _res$data : 'null');
13
+ }
14
+ set(key, value) {
15
+ return promisify(setStorage)({
16
+ key: this.getFullKey(key),
17
+ data: JSON.stringify(value)
18
+ });
19
+ }
20
+ remove(key) {
21
+ return promisify(removeStorage)({
22
+ key: this.getFullKey(key)
23
+ });
24
+ }
25
+ getFullKey(key) {
26
+ return `${this.prefix}_${key}`;
27
+ }
28
+ }
29
+ export const storage = new Storage(getLaunchOptionsSync().query.deviceId);
@@ -1,11 +1,12 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext, useEffect, useRef, useState } from 'react';
3
- import { CoverView, getStorage } from '@ray-js/ray';
3
+ import { CoverView } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import _find from 'lodash/find';
6
6
  import _get from 'lodash/get';
7
7
  import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
8
8
  import { getDpIdByCode, publishDps } from '@ray-js/ray-ipc-utils';
9
+ import { Storage } from '../../utils/storage';
9
10
  import { useMemoizedFn } from '../../hooks';
10
11
  import { useComponentHideState } from '../../ui/hooks';
11
12
  import { UIEventContext } from '../../ui/context';
@@ -51,31 +52,18 @@ export const PtzControl = props => {
51
52
  });
52
53
  const [shouldHide] = useComponentHideState();
53
54
  const [isPtzActive, setIsPtzActive] = useState(true);
54
- const [showPtzControlTip, setShowPtzControlTip] = useState(false);
55
55
  const {
56
56
  event
57
57
  } = useContext(UIEventContext);
58
58
  const ptzTimeId = useRef(null);
59
59
  const ptzData = useRef(getPtzData(devId));
60
+ const showPtzControlTip = useRef(true);
60
61
  const onPtzControlHide = useMemoizedFn(() => {
61
62
  setIsPtzActive(false);
62
63
  });
63
64
  const onPtzControlShow = useMemoizedFn(() => {
64
65
  setIsPtzActive(true);
65
66
  });
66
-
67
- // 获取是否有ptz控制tip
68
- useEffect(() => {
69
- getStorage({
70
- key: `${devId}_ptzControlTip}`,
71
- success: res => {
72
- console.log(res, 'ptzControlTip');
73
- if (!res.data) {
74
- setShowPtzControlTip(true);
75
- }
76
- }
77
- });
78
- }, []);
79
67
  useEffect(() => {
80
68
  event.on('ptzControlHide', onPtzControlHide);
81
69
  event.on('ptzControlShow', onPtzControlShow);
@@ -113,15 +101,22 @@ export const PtzControl = props => {
113
101
  });
114
102
  }, 1000);
115
103
  }
116
- if (showPtzControlTip) {
117
- addContent('absolute', {
118
- id: ptzControlTipId,
119
- content: props => {
120
- return /*#__PURE__*/React.createElement(PtzControlTip, props);
121
- },
122
- absoluteContentClassName: 'ipc-player-plugin-ptz-control-tip-wrap',
123
- initProps: _objectSpread({}, props)
124
- });
104
+
105
+ // ptz 操作提示
106
+ if (showPtzControlTip.current) {
107
+ const storage = new Storage(devId);
108
+ const res = await storage.get('ptzControlTip');
109
+ if (!res) {
110
+ showPtzControlTip.current = false;
111
+ addContent('absolute', {
112
+ id: ptzControlTipId,
113
+ content: props => {
114
+ return /*#__PURE__*/React.createElement(PtzControlTip, props);
115
+ },
116
+ absoluteContentClassName: 'ipc-player-plugin-ptz-control-tip-wrap',
117
+ initProps: _objectSpread({}, props)
118
+ });
119
+ }
125
120
  }
126
121
  });
127
122
  return /*#__PURE__*/React.createElement(CoverView, {
@@ -23,7 +23,7 @@ export const PtzControlTip = props => {
23
23
  setShowTipModal(false);
24
24
  deleteContent('absolute', ptzControlTipId);
25
25
  setStorage({
26
- key: `${devId}_ptzControlTip}`,
26
+ key: `${devId}_ptzControlTip`,
27
27
  data: 'true'
28
28
  });
29
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.8-beta-2",
3
+ "version": "0.0.8-beta-3",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,8 +38,8 @@
38
38
  "@ray-js/ipc-ptz-zoom": "^0.0.2",
39
39
  "@ray-js/panel-sdk": "^1.13.1",
40
40
  "@ray-js/direction-control": "^0.0.8",
41
- "@ray-js/ray-ipc-player": "2.0.21-beta-2",
42
- "@ray-js/ray-ipc-utils": "1.1.6-beta-1",
41
+ "@ray-js/ray-ipc-player": "2.0.21-beta-4",
42
+ "@ray-js/ray-ipc-utils": "1.1.8-beta-1",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",
45
45
  "jotai": "^2.10.2"