@video-lab/react-frame 4.0.0 → 4.0.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.
package/README.md CHANGED
@@ -121,6 +121,7 @@ MIT
121
121
  ## 完整事件与命令失败
122
122
 
123
123
  `onPlayerEvent` 交付完整 `PlayerEvent`,其顶层 `delivery` 包含生产端排序、去重与迟到事件证据。
124
+ `PlayerEvent` 用 `event` 字段区分类型(如 `e.event === 'ready'`),数据在 `payload`;它没有 `type` 字段。
124
125
  旧 iframe 的事件可缺少该字段。宿主主动调用的每次可失败命令都应处理 rejection,可在业务封装层
125
126
  集中处理,不必在每个按钮里重复写 `catch`。命令 rejection 不保证产生 `error`,播放期 `error`
126
127
  也不保证对应某个命令 rejection。`void ref.current?.play()` 不会处理 Promise rejection。
package/dist/index.cjs CHANGED
@@ -168,6 +168,10 @@ function useFrameConnection(props, hasCustomPoster = false, hasCustomPause = fal
168
168
  pauseIntentPendingRef.current = false;
169
169
  setHostPauseVisible(false);
170
170
  awaitingNewSourceRef.current = "switching";
171
+ setLoadingOverlay({
172
+ phase: firstFrameSeenRef.current ? "runtime" : "initial",
173
+ reason: "source_switching"
174
+ });
171
175
  handleRef.current?.setSourceSwitching(true).catch(() => {});
172
176
  forwardWithDelivery({
173
177
  event: "playablechange",
@@ -310,17 +314,18 @@ function useFrameConnection(props, hasCustomPoster = false, hasCustomPause = fal
310
314
  }
311
315
  }
312
316
  if (event.event === "firstframe" || event.event === "timeupdate") if (awaitingNewSourceRef.current === "switching") {} else {
313
- if (awaitingNewSourceRef.current === "new-source") awaitingNewSourceRef.current = false;
317
+ const newSourceArrived = awaitingNewSourceRef.current === "new-source";
318
+ if (newSourceArrived) awaitingNewSourceRef.current = false;
314
319
  firstFrameSeenRef.current = true;
315
320
  setHostPosterVisible(false);
316
- setLoadingOverlay(null);
321
+ setLoadingOverlay((prev) => newSourceArrived || prev?.phase !== "runtime" ? null : prev);
317
322
  }
318
323
  else if (event.event === "playablechange") {
319
324
  const { playable, recoverable, reason, action = "none" } = event.payload;
320
325
  const terminalError = !playable && !recoverable && reason === "error";
321
326
  const blockingAction = !playable && !recoverable && action !== "none";
322
327
  if (terminalError) setHostPosterVisible(false);
323
- setLoadingOverlay(!firstFrameSeenRef.current ? terminalError || blockingAction ? null : {
328
+ if (!(awaitingNewSourceRef.current !== false && (reason === "initializing" || reason === "ok"))) setLoadingOverlay(!firstFrameSeenRef.current ? terminalError || blockingAction ? null : {
324
329
  phase: "initial",
325
330
  reason
326
331
  } : !playable && recoverable && reason !== "initializing" ? {
package/dist/index.d.cts CHANGED
@@ -301,4 +301,3 @@ interface VideoPlayerFrameHandle {
301
301
  declare const VideoPlayerFrame: import("react").ForwardRefExoticComponent<VideoPlayerFrameProps & import("react").RefAttributes<VideoPlayerFrameHandle>>;
302
302
  //#endregion
303
303
  export { type DanmakuConfig, type DanmakuItem, type LoadingOverlayContext, type MediaSource, type PageFullscreenAdapter, type PageFullscreenState, type PlayerError, type PlayerHandle, PlayerProvider, type PlayerProviderProps, type QualityLevel, type ResolveSource, type SubtitleTrackInfo, VideoPlayerFrame, type VideoPlayerFrameHandle, type VideoPlayerFrameProps, usePlayerI18n };
304
- //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -301,4 +301,3 @@ interface VideoPlayerFrameHandle {
301
301
  declare const VideoPlayerFrame: import("react").ForwardRefExoticComponent<VideoPlayerFrameProps & import("react").RefAttributes<VideoPlayerFrameHandle>>;
302
302
  //#endregion
303
303
  export { type DanmakuConfig, type DanmakuItem, type LoadingOverlayContext, type MediaSource, type PageFullscreenAdapter, type PageFullscreenState, type PlayerError, type PlayerHandle, PlayerProvider, type PlayerProviderProps, type QualityLevel, type ResolveSource, type SubtitleTrackInfo, VideoPlayerFrame, type VideoPlayerFrameHandle, type VideoPlayerFrameProps, usePlayerI18n };
304
- //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -167,6 +167,10 @@ function useFrameConnection(props, hasCustomPoster = false, hasCustomPause = fal
167
167
  pauseIntentPendingRef.current = false;
168
168
  setHostPauseVisible(false);
169
169
  awaitingNewSourceRef.current = "switching";
170
+ setLoadingOverlay({
171
+ phase: firstFrameSeenRef.current ? "runtime" : "initial",
172
+ reason: "source_switching"
173
+ });
170
174
  handleRef.current?.setSourceSwitching(true).catch(() => {});
171
175
  forwardWithDelivery({
172
176
  event: "playablechange",
@@ -309,17 +313,18 @@ function useFrameConnection(props, hasCustomPoster = false, hasCustomPause = fal
309
313
  }
310
314
  }
311
315
  if (event.event === "firstframe" || event.event === "timeupdate") if (awaitingNewSourceRef.current === "switching") {} else {
312
- if (awaitingNewSourceRef.current === "new-source") awaitingNewSourceRef.current = false;
316
+ const newSourceArrived = awaitingNewSourceRef.current === "new-source";
317
+ if (newSourceArrived) awaitingNewSourceRef.current = false;
313
318
  firstFrameSeenRef.current = true;
314
319
  setHostPosterVisible(false);
315
- setLoadingOverlay(null);
320
+ setLoadingOverlay((prev) => newSourceArrived || prev?.phase !== "runtime" ? null : prev);
316
321
  }
317
322
  else if (event.event === "playablechange") {
318
323
  const { playable, recoverable, reason, action = "none" } = event.payload;
319
324
  const terminalError = !playable && !recoverable && reason === "error";
320
325
  const blockingAction = !playable && !recoverable && action !== "none";
321
326
  if (terminalError) setHostPosterVisible(false);
322
- setLoadingOverlay(!firstFrameSeenRef.current ? terminalError || blockingAction ? null : {
327
+ if (!(awaitingNewSourceRef.current !== false && (reason === "initializing" || reason === "ok"))) setLoadingOverlay(!firstFrameSeenRef.current ? terminalError || blockingAction ? null : {
323
328
  phase: "initial",
324
329
  reason
325
330
  } : !playable && recoverable && reason !== "initializing" ? {
@@ -826,4 +831,3 @@ const VideoPlayerFrame = forwardRef(function VideoPlayerFrame(rawProps, ref) {
826
831
  //#endregion
827
832
  export { PlayerProvider, VideoPlayerFrame, usePlayerI18n };
828
833
 
829
- //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@video-lab/react-frame",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -34,9 +34,9 @@
34
34
  "react-dom": ">=19.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@video-lab/protocol": "4.0.0",
38
- "@video-lab/react-config": "4.0.0",
39
- "@video-lab/frame-core": "4.0.0"
37
+ "@video-lab/protocol": "4.0.1",
38
+ "@video-lab/react-config": "4.0.1",
39
+ "@video-lab/frame-core": "4.0.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@testing-library/jest-dom": "^6.0.0",
@@ -3,8 +3,8 @@ name: video-lab-host-integration
3
3
  skillVersion: 1
4
4
  sdkMajor: 4
5
5
  supportedPackages:
6
- - '@video-lab/react-frame@4.0.0'
7
- - '@video-lab/vue-frame@4.0.0'
6
+ - '@video-lab/react-frame@4.0.1'
7
+ - '@video-lab/vue-frame@4.0.1'
8
8
  description: >-
9
9
  在业务宿主项目中接入 Video Lab Player 时使用。选择五种接入面之一,完成可验证 demo,
10
10
  并交接 SDK、宿主与服务端责任;不用于修改 SDK 契约或设计品牌 UI。