@ray-js/ipc-player-integration 0.0.15 → 0.0.16-beta-2

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/ctx/ctx.js CHANGED
@@ -114,6 +114,11 @@ export const createUseCtx = _ref => {
114
114
  });
115
115
  }
116
116
  }, [devId, _playState]);
117
+
118
+ // 获取content数据
119
+
120
+ // 根据类型更新content数据
121
+
117
122
  const changeContentHiddenData = (type, id, hidden) => {
118
123
  const store = getDefaultStore();
119
124
  let targetStore;
@@ -150,7 +155,6 @@ export const createUseCtx = _ref => {
150
155
  }
151
156
  const _setMute = async function (target) {
152
157
  let onlyUpdateAtom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
153
- console.log(target, '_setMute====');
154
158
  if (onlyUpdateAtom) {
155
159
  updateAtom(mute, target);
156
160
  return false;
@@ -159,7 +163,6 @@ export const createUseCtx = _ref => {
159
163
  IPCPlayerInstance.current.setMuted({
160
164
  mute: target,
161
165
  success: () => {
162
- console.log('=== set mute success ===', target);
163
166
  setMuteMemoryState(devId, target);
164
167
  updateAtom(mute, target);
165
168
  resolve(true);
@@ -452,6 +455,29 @@ export const createUseCtx = _ref => {
452
455
  updateAtom(absoluteContent, prevValue => prevValue.filter(item => item.id !== id));
453
456
  }
454
457
  },
458
+ getContent: () => {
459
+ const store = getDefaultStore();
460
+ return {
461
+ topLeft: store.get(topLeftContent),
462
+ topRight: store.get(topRightContent),
463
+ bottomLeft: store.get(bottomLeftContent),
464
+ bottomRight: store.get(bottomRightContent),
465
+ absolute: store.get(absoluteContent)
466
+ };
467
+ },
468
+ updateContent: (type, data) => {
469
+ if (type === 'topLeft') {
470
+ updateAtom(topLeftContent, data);
471
+ } else if (type === 'topRight') {
472
+ updateAtom(topRightContent, data);
473
+ } else if (type === 'bottomLeft') {
474
+ updateAtom(bottomLeftContent, data);
475
+ } else if (type === 'bottomRight') {
476
+ updateAtom(bottomRightContent, data);
477
+ } else {
478
+ updateAtom(absoluteContent, data);
479
+ }
480
+ },
455
481
  hideContent: (type, id) => {
456
482
  changeContentHiddenData(type, id, true);
457
483
  },
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { UseCtx } from '../../interface';
2
+ import { UseCtx, WidgetId } from '../../interface';
3
3
  import { FullScreen } from '../../widgets/fullScreen';
4
4
  type Ctx = ReturnType<UseCtx>;
5
5
  export declare function initPlayerWidgets(ctx: Ctx, options: {
@@ -10,4 +10,5 @@ export declare function initPlayerWidgets(ctx: Ctx, options: {
10
10
  hideKbsMenu?: boolean;
11
11
  directionControlProps?: Partial<React.ComponentProps<typeof FullScreen>['directionControlProps']>;
12
12
  }): Promise<void>;
13
+ export declare function updatePlayerWidgetProps(ctx: Ctx, area: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight', widgetId: WidgetId, newProps: Record<string, any>): Promise<void>;
13
14
  export {};
@@ -1,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import _cloneDeep from 'lodash/cloneDeep';
2
3
  import { defaultTopLeftContent, defaultTopRightContent, defaultBottomLeftContent, defaultBottomRightContent } from '../../ctx';
3
4
  import { hasDpCode } from '../../utils/device';
@@ -56,4 +57,20 @@ export async function initPlayerWidgets(ctx, options) {
56
57
  }, -1);
57
58
  }
58
59
  });
60
+ }
61
+ export async function updatePlayerWidgetProps(ctx, area, widgetId, newProps) {
62
+ const areaContent = ctx.getContent();
63
+ const targetArea = areaContent[area];
64
+ if (targetArea && Array.isArray(targetArea)) {
65
+ const widgetIndex = targetArea.findIndex(item => item.id === widgetId);
66
+ if (widgetIndex === -1) return;
67
+ const widget = targetArea[widgetIndex];
68
+ const mergedProps = _objectSpread(_objectSpread({}, widget.initProps), newProps);
69
+ const updatedWidget = _objectSpread(_objectSpread({}, widget), {}, {
70
+ initProps: mergedProps
71
+ });
72
+ const newAreaContent = [...targetArea];
73
+ newAreaContent[widgetIndex] = updatedWidget;
74
+ ctx.updateContent(area, newAreaContent);
75
+ }
59
76
  }
@@ -10,6 +10,7 @@ export type IpcContext = {
10
10
  };
11
11
  export type RetAtom<T> = PrimitiveAtom<T> & WithInitialValue<T>;
12
12
  export type ScreenType = 'full' | 'vertical';
13
+ export type WidgetId = 'BatteryFull' | 'TempHumidity' | 'VideoBitKBP' | 'FullSmallIntercom' | 'Screenshot' | 'RecordVideo' | 'Muted' | 'VerticalSmallIntercom' | 'Ptz' | 'Resolution' | 'FullScreen';
13
14
  export declare const enum PlayerStreamStatus {
14
15
  UnknownException = -1000,
15
16
  ConnectSuccess = 1001,
@@ -81,6 +82,8 @@ export type UseCtx = (options: {
81
82
  setPlayState: (value: PlayState) => void;
82
83
  addContent: <T>(type: ContentPlaceType, config: ComponentConfig<T> | ComponentConfig<T>[], position?: number) => void;
83
84
  deleteContent: (type: ContentPlaceType, id: string) => void;
85
+ getContent: () => ComponentConfig[];
86
+ updateContent: (type: ContentPlaceType, data: ComponentConfig[]) => void;
84
87
  hasContent: (type: ContentPlaceType, id: string) => boolean;
85
88
  hideContent: (type: ContentPlaceType, id: string) => void;
86
89
  showContent: (type: ContentPlaceType, id: string) => void;
@@ -38,6 +38,8 @@ export declare const Battery: import("react").FunctionComponent<{
38
38
  setPlayState: (value: import("../..").PlayState) => void;
39
39
  addContent: <T>(type: import("../..").ContentPlaceType, config: import("../..").ComponentConfig<T> | import("../..").ComponentConfig<T>[], position?: number | undefined) => void;
40
40
  deleteContent: (type: import("../..").ContentPlaceType, id: string) => void;
41
+ getContent: () => import("../..").ComponentConfig<any & Record<string, any>>[];
42
+ updateContent: (type: import("../..").ContentPlaceType, data: import("../..").ComponentConfig<any & Record<string, any>>[]) => void;
41
43
  hasContent: (type: import("../..").ContentPlaceType, id: string) => boolean;
42
44
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
43
45
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
@@ -85,6 +87,8 @@ export declare const BatteryFull: import("react").FunctionComponent<{
85
87
  setPlayState: (value: import("../..").PlayState) => void;
86
88
  addContent: <T>(type: import("../..").ContentPlaceType, config: import("../..").ComponentConfig<T> | import("../..").ComponentConfig<T>[], position?: number | undefined) => void;
87
89
  deleteContent: (type: import("../..").ContentPlaceType, id: string) => void;
90
+ getContent: () => import("../..").ComponentConfig<any & Record<string, any>>[];
91
+ updateContent: (type: import("../..").ContentPlaceType, data: import("../..").ComponentConfig<any & Record<string, any>>[]) => void;
88
92
  hasContent: (type: import("../..").ContentPlaceType, id: string) => boolean;
89
93
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
90
94
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
@@ -18,7 +18,6 @@
18
18
  .controlTipText {
19
19
  margin-top: calc(10px * var(--ipc-player-size-scale, 1));
20
20
  color: rgba(255,255,255,0.7);
21
- word-break: break-all;
22
21
  text-align: center;
23
22
  font-size: calc(12px * var(--ipc-player-size-scale, 1));
24
23
  font-weight: 400;
@@ -39,4 +38,4 @@
39
38
  font-size: calc(12px * var(--ipc-player-size-scale, 1));;
40
39
  color: #ffffff;
41
40
  }
42
- }
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.15",
3
+ "version": "0.0.16-beta-2",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,7 +38,7 @@
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.23",
41
+ "@ray-js/ray-ipc-player": "^2.0.24",
42
42
  "@ray-js/ray-ipc-utils": "^1.1.10",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",