@ray-js/ipc-player-integration 0.0.52-beta.0 → 0.0.52-beta.1

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.
@@ -6,6 +6,7 @@ import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/i
6
6
  import { createUseCtx } from './ctx';
7
7
  import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
8
8
  import { authorizeStatus } from '../utils/authorize';
9
+ import { PlayState } from '../interface';
9
10
  import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
10
11
  import { multiPrefix } from '../widgets/multiCamera/constants';
11
12
  const createPlayContext = ty.createIpcPlayerContext;
@@ -87,20 +88,29 @@ export const defaultBottomRightContent = [{
87
88
  content: FullScreen
88
89
  }];
89
90
  const absoluteContent = [];
91
+ const renderWhenPlaying = _ref => {
92
+ let {
93
+ playState
94
+ } = _ref;
95
+ return playState === PlayState.PLAYING;
96
+ };
90
97
  export const multiCameraAbsoluteContent = [{
91
98
  id: tileTipId,
92
99
  content: TileTip,
93
100
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
101
+ renderWhen: renderWhenPlaying,
94
102
  hidden: true
95
103
  }, {
96
104
  id: ptzMoveableTipId,
97
105
  content: PtzMoveableTip,
98
106
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
107
+ renderWhen: renderWhenPlaying,
99
108
  hidden: true
100
109
  }, {
101
110
  id: landscapeTipId,
102
111
  content: LandscapeTip,
103
112
  absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
113
+ renderWhen: renderWhenPlaying,
104
114
  hidden: true
105
115
  }, {
106
116
  id: tileActionsId,
@@ -112,12 +122,12 @@ export const multiCameraAbsoluteContent = [{
112
122
  absoluteNoCoverView: true,
113
123
  hidden: true
114
124
  }];
115
- const toast = _ref => {
125
+ const toast = _ref2 => {
116
126
  let {
117
127
  title,
118
128
  duration
119
- } = _ref,
120
- config = _objectWithoutProperties(_ref, _excluded);
129
+ } = _ref2,
130
+ config = _objectWithoutProperties(_ref2, _excluded);
121
131
  ty.showToast(_objectSpread({
122
132
  title,
123
133
  duration,
@@ -121,8 +121,12 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
121
121
  absoluteContentClassName?: string;
122
122
  absoluteContentStyle?: React.CSSProperties;
123
123
  absoluteNoCoverView?: boolean;
124
+ renderWhen?: (state: ComponentRenderState) => boolean;
124
125
  hidden?: boolean;
125
126
  };
127
+ export type ComponentRenderState = {
128
+ playState: PlayState;
129
+ };
126
130
  export type ComponentConfigProps = {
127
131
  IPCPlayerContext: IpcContext;
128
132
  } & ReturnType<UseCtx>;
@@ -0,0 +1,2 @@
1
+ import type { ComponentConfig, ComponentRenderState } from '../interface';
2
+ export declare function shouldRenderContent<T>(item: ComponentConfig<T>, state: ComponentRenderState): boolean;
@@ -0,0 +1,3 @@
1
+ export function shouldRenderContent(item, state) {
2
+ return !item.hidden && (!item.renderWhen || item.renderWhen(state));
3
+ }
package/lib/ui/ui.js CHANGED
@@ -26,6 +26,7 @@ import { updatePlayerWidgetProps } from '../features';
26
26
  import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
27
27
  import { getCaptureResultSummary } from '../utils/captureResult';
28
28
  import { lensCount } from '../widgets/zoomTurntable/lensSkill';
29
+ import { shouldRenderContent } from './absoluteContent';
29
30
  function getCtxInstance(instance, devId) {
30
31
  if (instance) return instance;
31
32
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -1212,13 +1213,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1212
1213
  }, renderBottomRightContent))), (() => {
1213
1214
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
1214
1215
  return absoluteContent.map(item => {
1215
- if (item.hidden) return null;
1216
+ if (!shouldRenderContent(item, {
1217
+ playState
1218
+ })) return null;
1219
+ const contentProps = _objectSpread(_objectSpread(_objectSpread({
1220
+ key: item.id
1221
+ }, item.initProps), instance), {}, {
1222
+ IPCPlayerContext: instance.IPCPlayerInstance
1223
+ });
1216
1224
  if (item.absoluteNoCoverView) {
1217
- return /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1218
- key: item.id
1219
- }, item.initProps), instance), {}, {
1220
- IPCPlayerContext: instance.IPCPlayerInstance
1221
- }));
1225
+ return /*#__PURE__*/React.createElement(item.content, contentProps);
1222
1226
  }
1223
1227
  return /*#__PURE__*/React.createElement(CoverView, {
1224
1228
  key: item.id,
@@ -1226,10 +1230,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1226
1230
  position: 'absolute'
1227
1231
  }, item.absolutePosition),
1228
1232
  className: item.absoluteContentClassName
1229
- }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1230
- key: item.id
1231
- }, item.initProps), instance), {}, {
1232
- IPCPlayerContext: instance.IPCPlayerInstance,
1233
+ }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
1233
1234
  // 添加通用变量单独组件类名
1234
1235
  className: clsx('absolute-item-container')
1235
1236
  })));
@@ -126,7 +126,10 @@ export const isSwitchChannelSupported = () => {
126
126
  const supported = typeof ((_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 ? void 0 : _ty.switchChannel) === 'function';
127
127
  if (!supported && !switchChannelMissingLogged) {
128
128
  switchChannelMissingLogged = true;
129
- console.warn('[zoomTurntable] 宿主不支持 ty.ipc.switchChannel,焦距转盘入口不展示');
129
+ // 只能用 log:本判定会在 render 期被调用,而 IDE 宿主下 render 期的 console.warn
130
+ // 会打坏 Ray 运行时,整个面板崩在 areHookInputsEqual / TDZ —— 且症状伪装成
131
+ // 「hook 顺序错位」(报 change in the order of Hooks),极难归因,勿改回 warn
132
+ console.log('[zoomTurntable] 宿主不支持 ty.ipc.switchChannel,焦距转盘入口不展示');
130
133
  dumpChannelApis();
131
134
  }
132
135
  return supported;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.52-beta.0",
3
+ "version": "0.0.52-beta.1",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [