Skip to content

Commit 1eae0d1

Browse files
committed
fix(core): type the health report and restore the player hook's complexity directive
1 parent 723e5c4 commit 1eae0d1

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎packages/core/src/runtime/playbackHealth.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { postRuntimeMessage } from "./bridge";
2+
import type { RuntimePreviewHealthMessage } from "./types";
23

34
/** What counts as a choppy preview; every number of the rule lives here. */
45
export const PLAYBACK_HEALTH = {
@@ -32,7 +33,7 @@ let key = "";
3233
let posted = false;
3334
let postedAtMs = 0;
3435

35-
function post(health: Record<string, unknown> | null): void {
36+
function post(health: RuntimePreviewHealthMessage["health"]): void {
3637
postRuntimeMessage({ source: "hf-preview", type: "preview-health", health });
3738
}
3839

@@ -51,7 +52,7 @@ export function restartPlaybackHealth(): void {
5152

5253
function measure(nowMs: number, fps: number, rate: number): void {
5354
const windowMs = PLAYBACK_HEALTH.windowSeconds * 1000;
54-
while (samples.length > 0 && samples[0].atMs < nowMs - windowMs) samples.shift();
55+
while (samples[0] && samples[0].atMs < nowMs - windowMs) samples.shift();
5556
const first = samples[0];
5657
if (!first) return;
5758
const spanMs = nowMs - (first.atMs - first.gapMs);

‎packages/studio/src/player/hooks/previewMessageRouter.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,18 @@ function handleTimelineMessage(
116116
}
117117

118118
const STORE_REPORTS = new Map<string, (data: PreviewMessage) => void>([
119-
["preview-copies", (data) => usePlayerStore.getState().setPreviewCopies(parsePreviewCopies(data.copies))],
120-
["preview-health", (data) => usePlayerStore.getState().setPlaybackHealth(parsePlaybackHealth(data.health))],
121-
["preview-facts", (data) => usePlayerStore.getState().setPreviewFacts(parsePreviewFacts(data.facts))],
119+
[
120+
"preview-copies",
121+
(data) => usePlayerStore.getState().setPreviewCopies(parsePreviewCopies(data.copies)),
122+
],
123+
[
124+
"preview-health",
125+
(data) => usePlayerStore.getState().setPlaybackHealth(parsePlaybackHealth(data.health)),
126+
],
127+
[
128+
"preview-facts",
129+
(data) => usePlayerStore.getState().setPreviewFacts(parsePreviewFacts(data.facts)),
130+
],
122131
]);
123132

124133
export function createPreviewMessageHandler(

‎packages/studio/src/player/hooks/useTimelinePlayer.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface UseTimelinePlayerOptions {
5656
const publishSeek = (time: number, options?: { follow?: boolean }) =>
5757
options?.follow === false ? liveTime.notify(time) : liveTime.notifySeek(time);
5858

59+
// fallow-ignore-next-line complexity
5960
export function useTimelinePlayer({
6061
onShadowPromoted,
6162
onPreviewReloadFailed,

0 commit comments

Comments
 (0)